module Derive.Scale.Java (scales, old_scales) where
import qualified Data.Map as Map
import qualified Data.Vector as Vector
import qualified Util.Lists as Lists
import qualified Derive.Derive as Derive
import qualified Derive.Scale as Scale
import qualified Derive.Scale.BaliScales as BaliScales
import qualified Derive.Scale.JavaScales as JavaScales
import qualified Derive.Sig as Sig
import qualified Perform.Pitch as Pitch
import Global
type Pathet = Text
scales :: Map Derive.CallName Derive.ScaleCall
scales :: Map CallName ScaleCall
scales = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (CallName
"pelog", ScaleCall
s_pelog)
]
s_pelog :: Derive.ScaleCall
s_pelog :: ScaleCall
s_pelog = CallName -> Doc -> (ScaleF, [ArgDoc]) -> ScaleCall
Derive.scale_call CallName
"pelog" Doc
"doc" forall a b. (a -> b) -> a -> b
$
forall a. Parser a -> (a -> Deriver Scale) -> (ScaleF, [ArgDoc])
Scale.call ((,)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a deflt.
(Typecheck a, ToVal deflt) =>
ArgName -> deflt -> Doc -> Parser a
Sig.defaulted ArgName
"pathet" (Text
"lima" :: Text) Doc
"doc"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall a deflt.
(Typecheck a, ToVal deflt) =>
ArgName -> deflt -> Doc -> Parser a
Sig.defaulted ArgName
"scale-inst" (forall a. Maybe a
Nothing :: Maybe Text) Doc
"doc"
) forall a b. (a -> b) -> a -> b
$ \(Text
pathet, Maybe Text
mb_scale_inst) -> do
Layout
layout <- forall a. HasCallStack => Text -> Maybe a -> Deriver a
Derive.require (Text
"unknown pathet: " forall a. Semigroup a => a -> a -> a
<> Text
pathet) forall a b. (a -> b) -> a -> b
$
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
pathet Map Text Layout
keys
Maybe Instrument
mb_inst <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse
(\Text
inst -> forall a. HasCallStack => Text -> Maybe a -> Deriver a
Derive.require (Text
"unknown scale-inst: " forall a. Semigroup a => a -> a -> a
<> Text
inst) forall a b. (a -> b) -> a -> b
$
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
inst Map Text Instrument
instruments)
Maybe Text
mb_scale_inst
let name :: Text
name = Text
"pelog" forall a. Semigroup a => a -> a -> a
<> Text
"-" forall a. Semigroup a => a -> a -> a
<> Text
pathet forall a. Semigroup a => a -> a -> a
<> forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
"" (Text
"-"<>) Maybe Text
mb_scale_inst
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
name Layout
layout Maybe Instrument
mb_inst
make_scale :: Text -> JavaScales.Layout -> Maybe JavaScales.Instrument
-> Scale.Scale
make_scale :: Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
name Layout
layout Maybe Instrument
mb_inst = Text -> ScaleMap -> Doc -> Scale
JavaScales.make_scale Text
name ScaleMap
smap Doc
"doc"
where
smap :: ScaleMap
smap = JavaScales.ScaleMap
{ Layout
$sel:layout:ScaleMap :: Layout
layout :: Layout
layout
, Laras
default_laras :: Laras
$sel:default_laras:ScaleMap :: Laras
default_laras
, Map Text Laras
laras_map :: Map Text Laras
$sel:laras_map:ScaleMap :: Map Text Laras
laras_map
, $sel:format:ScaleMap :: Format
format = case Maybe Instrument
mb_inst of
Maybe Instrument
Nothing -> Layout -> Format
JavaScales.cipher_absolute Layout
layout
Just Instrument
inst -> Layout -> Instrument -> Format
JavaScales.cipher_octave_relative Layout
layout Instrument
inst
}
keys :: Map Pathet JavaScales.Layout
keys :: Map Text Layout
keys = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (Text
"lima", Int -> [Int] -> Layout
JavaScales.make_layout Int
0 [Int
1, Int
1, Int
2, Int
1, Int
2])
, (Text
"nem", Int -> [Int] -> Layout
JavaScales.make_layout Int
0 [Int
1, Int
1, Int
2, Int
1, Int
2])
, (Text
"barang", Int -> [Int] -> Layout
JavaScales.make_layout Int
1 [Int
1, Int
2, Int
1, Int
1, Int
2])
]
instruments :: Map Text JavaScales.Instrument
instruments :: Map Text Instrument
instruments = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ ( Text
"gender-barung"
, JavaScales.Instrument
{ $sel:center:Instrument :: Int
center = Int
3
, $sel:bottom:Instrument :: Absolute
bottom = Int -> Int -> Absolute
JavaScales.Absolute Int
1 Int
6
, $sel:top:Instrument :: Absolute
top = Int -> Int -> Absolute
JavaScales.Absolute Int
4 Int
3
}
)
, (Text
"gender-panerus"
, JavaScales.Instrument
{ $sel:center:Instrument :: Int
center = Int
4
, $sel:bottom:Instrument :: Absolute
bottom = Int -> Int -> Absolute
JavaScales.Absolute Int
2 Int
6
, $sel:top:Instrument :: Absolute
top = Int -> Int -> Absolute
JavaScales.Absolute Int
5 Int
3
}
)
]
laras_map :: Map Text BaliScales.Laras
laras_map :: Map Text Laras
laras_map = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall a b. (a -> b) -> a -> b
$ forall a k. (a -> k) -> [a] -> [(k, a)]
Lists.keyOn Laras -> Text
BaliScales.laras_name
[ Laras
laras_sequoia_pelog
]
default_laras :: BaliScales.Laras
default_laras :: Laras
default_laras = Laras
laras_sequoia_pelog
sequoia_pelog :: JavaScales.Laras
sequoia_pelog :: Laras
sequoia_pelog = JavaScales.Laras
{ $sel:name:Laras :: Text
name = Text
"sequoia-pelog"
, $sel:doc:Laras :: Doc
doc = Doc
"Tuning of Sekar Sequoia."
, $sel:base:Laras :: Pitch
base = forall pc. Enum pc => Int -> pc -> Pitch
Pitch.pitch Int
1 Integer
5
, $sel:umbang:Laras :: Vector NoteNumber
umbang = forall a. [a] -> Vector a
Vector.fromList
[ NoteNumber
46.68
, NoteNumber
48.13
, NoteNumber
50.18
, NoteNumber
51.65
, NoteNumber
53
, NoteNumber
56
, NoteNumber
57.05
, NoteNumber
58.68
, NoteNumber
60.13
, NoteNumber
62.18
, NoteNumber
63.65
, NoteNumber
65
, NoteNumber
68
, NoteNumber
69.05
, NoteNumber
70.5
, NoteNumber
72.14
, NoteNumber
74.25
, NoteNumber
75.68
, NoteNumber
77
, NoteNumber
80
, NoteNumber
81.03
, NoteNumber
82.48
, NoteNumber
84.14
, NoteNumber
86.4
, NoteNumber
87.7
, NoteNumber
88.98
]
, $sel:isep:Laras :: Vector NoteNumber
isep = forall a. Monoid a => a
mempty
}
laras_sequoia_pelog :: BaliScales.Laras
laras_sequoia_pelog :: Laras
laras_sequoia_pelog = Text
-> Pitch
-> ([NoteNumber] -> [NoteNumber])
-> Doc
-> [(NoteNumber, NoteNumber)]
-> Laras
BaliScales.laras Text
"sequoia-pelog" (forall pc. Enum pc => Int -> pc -> Pitch
Pitch.pitch Int
1 Integer
5) forall a. a -> a
id
Doc
"Tuning of Sekar Sequoia." forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (\NoteNumber
nn -> (NoteNumber
nn, NoteNumber
nn)) forall a b. (a -> b) -> a -> b
$
[ NoteNumber
46.68
, NoteNumber
48.13
, NoteNumber
50.18
, NoteNumber
51.65
, NoteNumber
53
, NoteNumber
56
, NoteNumber
57.05
, NoteNumber
58.68
, NoteNumber
60.13
, NoteNumber
62.18
, NoteNumber
63.65
, NoteNumber
65
, NoteNumber
68
, NoteNumber
69.05
, NoteNumber
70.5
, NoteNumber
72.14
, NoteNumber
74.25
, NoteNumber
75.68
, NoteNumber
77
, NoteNumber
80
, NoteNumber
81.03
, NoteNumber
82.48
, NoteNumber
84.14
, NoteNumber
86.4
, NoteNumber
87.7
, NoteNumber
88.98
]
forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map (forall a. Num a => a -> a -> a
+NoteNumber
12)
[ NoteNumber
80
, NoteNumber
81.03
, NoteNumber
82.48
, NoteNumber
84.14
, NoteNumber
86.4
, NoteNumber
87.7
, NoteNumber
88.98
]
old_scales :: [Scale.Definition]
old_scales :: [Definition]
old_scales = forall a b. (a -> b) -> [a] -> [b]
map Scale -> Definition
Scale.Simple forall a b. (a -> b) -> a -> b
$
[ Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
"pelog-lima" Layout
lima forall a. Maybe a
Nothing
, Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
"pelog-nem" Layout
lima forall a. Maybe a
Nothing
, Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
"pelog-barang" Layout
barang forall a. Maybe a
Nothing
] forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Text -> Instrument -> [Scale]
inst_scale) (forall k a. Map k a -> [(k, a)]
Map.toList Map Text Instrument
instruments)
where
lima :: Layout
lima = Int -> [Int] -> Layout
JavaScales.make_layout Int
0 [Int
1, Int
1, Int
2, Int
1, Int
2]
barang :: Layout
barang = Int -> [Int] -> Layout
JavaScales.make_layout Int
1 [Int
1, Int
2, Int
1, Int
1, Int
2]
inst_scale :: Text -> Instrument -> [Scale]
inst_scale Text
name Instrument
inst =
[ Text -> Layout -> Maybe Instrument -> Scale
make_scale (Text
"pelog-lima-" forall a. Semigroup a => a -> a -> a
<> Text
name) Layout
lima (forall a. a -> Maybe a
Just Instrument
inst)
, Text -> Layout -> Maybe Instrument -> Scale
make_scale (Text
"pelog-barang-" forall a. Semigroup a => a -> a -> a
<> Text
name) Layout
barang (forall a. a -> Maybe a
Just Instrument
inst)
]
make_scale :: Text -> Layout -> Maybe Instrument -> Scale
make_scale Text
name Layout
layout Maybe Instrument
mb_inst = Text -> ScaleMap -> Doc -> Scale
JavaScales.make_scale Text
name ScaleMap
smap Doc
"doc"
where
smap :: ScaleMap
smap = JavaScales.ScaleMap
{ Layout
layout :: Layout
$sel:layout:ScaleMap :: Layout
layout
, Laras
default_laras :: Laras
$sel:default_laras:ScaleMap :: Laras
default_laras
, Map Text Laras
laras_map :: Map Text Laras
$sel:laras_map:ScaleMap :: Map Text Laras
laras_map
, $sel:format:ScaleMap :: Format
format = case Maybe Instrument
mb_inst of
Maybe Instrument
Nothing -> Layout -> Format
JavaScales.cipher_absolute Layout
layout
Just Instrument
inst -> Layout -> Instrument -> Format
JavaScales.cipher_octave_relative Layout
layout Instrument
inst
}