-- | <http://www.microtonal-synthesis.com/scales.html>
module Music.Theory.Tuning.Db.Microtonal_Synthesis where

import Music.Theory.Tuning {- hmt -}
import Music.Theory.Tuning.Type {- hmt -}

-- | Ratios for 'pythagorean'.
pythagorean_12_r :: [Rational]
pythagorean_12_r :: [Rational]
pythagorean_12_r =
    [Rational
1,Rational
2187forall a. Fractional a => a -> a -> a
/Rational
2048 {- 256/243 -}
    ,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
32forall a. Fractional a => a -> a -> a
/Rational
27
    ,Rational
81forall a. Fractional a => a -> a -> a
/Rational
64
    ,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
729forall a. Fractional a => a -> a -> a
/Rational
512
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
6561forall a. Fractional a => a -> a -> a
/Rational
4096 {- 128/81 -}
    ,Rational
27forall a. Fractional a => a -> a -> a
/Rational
16,Rational
16forall a. Fractional a => a -> a -> a
/Rational
9
    ,Rational
243forall a. Fractional a => a -> a -> a
/Rational
128]

-- | Pythagorean tuning, <http://www.microtonal-synthesis.com/scale_pythagorean.html>.
--
-- > cents_i pythagorean_12 == [0,114,204,294,408,498,612,702,816,906,996,1110]
--
-- > scl <- scl_load "pyth_12"
-- > cents_i (scale_tuning 0.1 scl) == cents_i pythagorean_12
pythagorean_12 :: Tuning
pythagorean_12 :: Tuning
pythagorean_12 = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
pythagorean_12_r) forall a. Maybe a
Nothing

-- | Ratios for 'five_limit_tuning'.
--
-- > let c = [0,112,204,316,386,498,590,702,814,884,996,1088]
-- > in map (round . ratio_to_cents) five_limit_tuning_r == c
five_limit_tuning_r :: [Rational]
five_limit_tuning_r :: [Rational]
five_limit_tuning_r =
    [Rational
1,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15
    ,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4
    ,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
45forall a. Fractional a => a -> a -> a
/Rational
32 {- 64/45 -}
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
16forall a. Fractional a => a -> a -> a
/Rational
9 {- 9/5 -}
    ,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8]

-- | Five-limit tuning (five limit just intonation), Alexander Malcolm's Monochord (1721).
--
-- > cents_i five_limit_tuning == [0,112,204,316,386,498,590,702,814,884,996,1088]
--
-- > scl <- scl_load "malcolm"
-- > cents_i (scale_tuning 0.1 scl) == cents_i five_limit_tuning
five_limit_tuning :: Tuning
five_limit_tuning :: Tuning
five_limit_tuning = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
five_limit_tuning_r) forall a. Maybe a
Nothing

-- | Ratios for 'septimal_tritone_just_intonation'.
--
-- > let c = [0,112,204,316,386,498,583,702,814,884,1018,1088]
-- > in map (round . ratio_to_cents) septimal_tritone_just_intonation == c
septimal_tritone_just_intonation_r :: [Rational]
septimal_tritone_just_intonation_r :: [Rational]
septimal_tritone_just_intonation_r =
    [Rational
1,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15
    ,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4
    ,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
7forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
9forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8]

-- | Septimal tritone Just Intonation, see
-- <http://www.microtonal-synthesis.com/scale_just_intonation.html>
--
-- > let c = [0,112,204,316,386,498,583,702,814,884,1018,1088]
-- > in cents_i septimal_tritone_just_intonation == c
--
-- > scl <- scl_load "ji_12"
-- > cents_i (scale_tuning 0.1 scl) == cents_i septimal_tritone_just_intonation
septimal_tritone_just_intonation :: Tuning
septimal_tritone_just_intonation :: Tuning
septimal_tritone_just_intonation = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
septimal_tritone_just_intonation_r) forall a. Maybe a
Nothing

-- | Ratios for 'seven_limit_just_intonation'.
--
-- > let c = [0,112,204,316,386,498,583,702,814,884,969,1088]
-- > in map (round . ratio_to_cents) seven_limit_just_intonation == c
seven_limit_just_intonation_r :: [Rational]
seven_limit_just_intonation_r :: [Rational]
seven_limit_just_intonation_r =
    [Rational
1,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15
    ,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4
    ,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
7forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5
    ,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
7forall a. Fractional a => a -> a -> a
/Rational
4
    ,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8]

-- | Seven limit Just Intonation.
--
-- > cents_i seven_limit_just_intonation == [0,112,204,316,386,498,583,702,814,884,969,1088]
seven_limit_just_intonation :: Tuning
seven_limit_just_intonation :: Tuning
seven_limit_just_intonation = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
seven_limit_just_intonation_r) forall a. Maybe a
Nothing

-- | Approximate ratios for 'kirnberger_iii'.
--
-- > let c = [0,90,193,294,386,498,590,697,792,890,996,1088]
-- > in map (round.to_cents) kirnberger_iii_ar == c
kirnberger_iii_ar :: [Approximate_Ratio]
kirnberger_iii_ar :: [Approximate_Ratio]
kirnberger_iii_ar =
    [Approximate_Ratio
1,Approximate_Ratio
256forall a. Fractional a => a -> a -> a
/Approximate_Ratio
243
    ,forall a. Floating a => a -> a
sqrt Approximate_Ratio
5 forall a. Fractional a => a -> a -> a
/ Approximate_Ratio
2,Approximate_Ratio
32forall a. Fractional a => a -> a -> a
/Approximate_Ratio
27
    ,Approximate_Ratio
5forall a. Fractional a => a -> a -> a
/Approximate_Ratio
4
    ,Approximate_Ratio
4forall a. Fractional a => a -> a -> a
/Approximate_Ratio
3,Approximate_Ratio
45forall a. Fractional a => a -> a -> a
/Approximate_Ratio
32
    ,Approximate_Ratio
5 forall a. Floating a => a -> a -> a
** Approximate_Ratio
0.25,Approximate_Ratio
128forall a. Fractional a => a -> a -> a
/Approximate_Ratio
81
    ,(Approximate_Ratio
5 forall a. Floating a => a -> a -> a
** Approximate_Ratio
0.75)forall a. Fractional a => a -> a -> a
/Approximate_Ratio
2,Approximate_Ratio
16forall a. Fractional a => a -> a -> a
/Approximate_Ratio
9
    ,Approximate_Ratio
15forall a. Fractional a => a -> a -> a
/Approximate_Ratio
8]

-- | <http://www.microtonal-synthesis.com/scale_kirnberger.html>.
--
-- > cents_i kirnberger_iii == [0,90,193,294,386,498,590,697,792,890,996,1088]
--
-- > scl <- scl_load "kirnberger"
-- > cents_i (scale_tuning 0.1 scl) == cents_i kirnberger_iii
kirnberger_iii :: Tuning
kirnberger_iii :: Tuning
kirnberger_iii = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. b -> Either a b
Right (forall a b. (a -> b) -> [a] -> [b]
map Approximate_Ratio -> Approximate_Ratio
approximate_ratio_to_cents [Approximate_Ratio]
kirnberger_iii_ar)) forall a. Maybe a
Nothing

-- > let c = [0,94,196,298,392,502,592,698,796,894,1000,1090]
-- > in map round vallotti_c == c
vallotti_c :: [Cents]
vallotti_c :: [Approximate_Ratio]
vallotti_c =
    [Approximate_Ratio
0.0,Approximate_Ratio
94.135
    ,Approximate_Ratio
196.09,Approximate_Ratio
298.045
    ,Approximate_Ratio
392.18
    ,Approximate_Ratio
501.955,Approximate_Ratio
592.18
    ,Approximate_Ratio
698.045,Approximate_Ratio
796.09
    ,Approximate_Ratio
894.135,Approximate_Ratio
1000.0
    ,Approximate_Ratio
1090.225]

-- | Vallotti & Young scale (Vallotti version), see
-- <http://www.microtonal-synthesis.com/scale_vallotti_young.html>.
--
-- > cents_i vallotti == [0,94,196,298,392,502,592,698,796,894,1000,1090]
--
-- > scl <- scl_load "vallotti"
-- > cents_i (scale_tuning 0.1 scl) == cents_i vallotti
vallotti :: Tuning
vallotti :: Tuning
vallotti = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. b -> Either a b
Right [Approximate_Ratio]
vallotti_c) forall a. Maybe a
Nothing

-- > let c = [0,128,139,359,454,563,637,746,841,911,1072,1183]
-- > in map (round . ratio_to_cents) mayumi_tsuda == c
mayumi_tsuda_r :: [Rational]
mayumi_tsuda_r :: [Rational]
mayumi_tsuda_r =
    [Rational
1,Rational
14forall a. Fractional a => a -> a -> a
/Rational
13
    ,Rational
13forall a. Fractional a => a -> a -> a
/Rational
12,Rational
16forall a. Fractional a => a -> a -> a
/Rational
13
    ,Rational
13forall a. Fractional a => a -> a -> a
/Rational
10
    ,Rational
18forall a. Fractional a => a -> a -> a
/Rational
13,Rational
13forall a. Fractional a => a -> a -> a
/Rational
9
    ,Rational
20forall a. Fractional a => a -> a -> a
/Rational
13,Rational
13forall a. Fractional a => a -> a -> a
/Rational
8
    ,Rational
22forall a. Fractional a => a -> a -> a
/Rational
13,Rational
13forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
208forall a. Fractional a => a -> a -> a
/Rational
105]

-- | Mayumi Tsuda 13-limit Just Intonation scale,
-- <http://www.microtonal-synthesis.com/scale_reinhard.html>.
--
-- > cents_i mayumi_tsuda == [0,128,139,359,454,563,637,746,841,911,1072,1183]
--
-- > scl <- scl_load "tsuda13"
-- > cents_i (scale_tuning 0.1 scl) == cents_i mayumi_tsuda
mayumi_tsuda :: Tuning
mayumi_tsuda :: Tuning
mayumi_tsuda = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
mayumi_tsuda_r) forall a. Maybe a
Nothing

-- | Ratios for 'lou_harrison_16'.
--
-- > length lou_harrison_16_r == 16
--
-- > let c = [0,112,182,231,267,316,386,498,603,702,814,884,933,969,1018,1088]
-- > in map (round . ratio_to_cents) lou_harrison_16_r == c
lou_harrison_16_r :: [Rational]
lou_harrison_16_r :: [Rational]
lou_harrison_16_r =
    [Rational
1,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15
    ,Rational
10forall a. Fractional a => a -> a -> a
/Rational
9,Rational
8forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
7forall a. Fractional a => a -> a -> a
/Rational
6,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4
    ,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3
    ,Rational
17forall a. Fractional a => a -> a -> a
/Rational
12
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2
    ,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
12forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
7forall a. Fractional a => a -> a -> a
/Rational
4,Rational
9forall a. Fractional a => a -> a -> a
/Rational
5,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8]

-- | Lou Harrison 16 tone Just Intonation scale, see
-- <http://www.microtonal-synthesis.com/scale_harrison_16.html>
--
-- > let r = [0,112,182,231,267,316,386,498,603,702,814,884,933,969,1018,1088]
-- > in cents_i lou_harrison_16 == r
--
-- > import Music.Theory.Tuning.Scala
-- > scl <- scl_load "harrison_16"
-- > cents_i (scale_tuning 0.1 scl) == cents_i lou_harrison_16
lou_harrison_16 :: Tuning
lou_harrison_16 :: Tuning
lou_harrison_16 = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
lou_harrison_16_r) forall a. Maybe a
Nothing

-- | Ratios for 'partch_43'.
partch_43_r :: [Rational]
partch_43_r :: [Rational]
partch_43_r =
    [Rational
1,Rational
81forall a. Fractional a => a -> a -> a
/Rational
80,Rational
33forall a. Fractional a => a -> a -> a
/Rational
32,Rational
21forall a. Fractional a => a -> a -> a
/Rational
20,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15,Rational
12forall a. Fractional a => a -> a -> a
/Rational
11,Rational
110,Rational
10forall a. Fractional a => a -> a -> a
/Rational
9,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
8forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
7forall a. Fractional a => a -> a -> a
/Rational
6,Rational
32forall a. Fractional a => a -> a -> a
/Rational
27,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5,Rational
11forall a. Fractional a => a -> a -> a
/Rational
9,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4,Rational
14forall a. Fractional a => a -> a -> a
/Rational
11,Rational
9forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
216,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
27forall a. Fractional a => a -> a -> a
/Rational
20
    ,Rational
11forall a. Fractional a => a -> a -> a
/Rational
8,Rational
7forall a. Fractional a => a -> a -> a
/Rational
5,Rational
10forall a. Fractional a => a -> a -> a
/Rational
7,Rational
16forall a. Fractional a => a -> a -> a
/Rational
11
    ,Rational
40forall a. Fractional a => a -> a -> a
/Rational
27,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
32forall a. Fractional a => a -> a -> a
/Rational
21,Rational
14forall a. Fractional a => a -> a -> a
/Rational
9,Rational
11forall a. Fractional a => a -> a -> a
/Rational
7,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5,Rational
18forall a. Fractional a => a -> a -> a
/Rational
11,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
27forall a. Fractional a => a -> a -> a
/Rational
16,Rational
12forall a. Fractional a => a -> a -> a
/Rational
7
    ,Rational
7forall a. Fractional a => a -> a -> a
/Rational
4,Rational
16forall a. Fractional a => a -> a -> a
/Rational
9,Rational
9forall a. Fractional a => a -> a -> a
/Rational
5,Rational
20forall a. Fractional a => a -> a -> a
/Rational
11,Rational
11forall a. Fractional a => a -> a -> a
/Rational
6,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8,Rational
40forall a. Fractional a => a -> a -> a
/Rational
21,Rational
64forall a. Fractional a => a -> a -> a
/Rational
33,Rational
160forall a. Fractional a => a -> a -> a
/Rational
81]

-- | Harry Partch 43 tone scale, see
-- <http://www.microtonal-synthesis.com/scale_partch.html>
--
-- > cents_i partch_43 == [0,22,53,84,112,151,165
-- >                      ,182,204,231,267,294,316
-- >                      ,347,386,418,435
-- >                      ,471,498,520,551,583,617,649
-- >                      ,680,702,729,765,782,814,853,884,906,933
-- >                      ,969,996,1018,1035,1049,1088,1116,1147,1178]
--
-- > scl <- scl_load "partch_43"
-- > cents_i (scale_tuning 0.1 scl) == cents_i partch_43
partch_43 :: Tuning
partch_43 :: Tuning
partch_43 = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
partch_43_r) forall a. Maybe a
Nothing

-- | Ratios for 'ben_johnston_25'.
ben_johnston_25_r :: [Rational]
ben_johnston_25_r :: [Rational]
ben_johnston_25_r =
    [Rational
1,Rational
25forall a. Fractional a => a -> a -> a
/Rational
24,Rational
135forall a. Fractional a => a -> a -> a
/Rational
128,Rational
16forall a. Fractional a => a -> a -> a
/Rational
15,Rational
10forall a. Fractional a => a -> a -> a
/Rational
9
    ,Rational
9forall a. Fractional a => a -> a -> a
/Rational
8,Rational
75forall a. Fractional a => a -> a -> a
/Rational
64,Rational
6forall a. Fractional a => a -> a -> a
/Rational
5,Rational
5forall a. Fractional a => a -> a -> a
/Rational
4,Rational
81forall a. Fractional a => a -> a -> a
/Rational
64
    ,Rational
32forall a. Fractional a => a -> a -> a
/Rational
25,Rational
4forall a. Fractional a => a -> a -> a
/Rational
3,Rational
27forall a. Fractional a => a -> a -> a
/Rational
20,Rational
45forall a. Fractional a => a -> a -> a
/Rational
32,Rational
36forall a. Fractional a => a -> a -> a
/Rational
25
    ,Rational
3forall a. Fractional a => a -> a -> a
/Rational
2,Rational
25forall a. Fractional a => a -> a -> a
/Rational
16,Rational
8forall a. Fractional a => a -> a -> a
/Rational
5,Rational
5forall a. Fractional a => a -> a -> a
/Rational
3,Rational
27forall a. Fractional a => a -> a -> a
/Rational
16
    ,Rational
225forall a. Fractional a => a -> a -> a
/Rational
128,Rational
16forall a. Fractional a => a -> a -> a
/Rational
9,Rational
9forall a. Fractional a => a -> a -> a
/Rational
5,Rational
15forall a. Fractional a => a -> a -> a
/Rational
8,Rational
48forall a. Fractional a => a -> a -> a
/Rational
25]

-- | Ben Johnston 25 note just enharmonic scale, see
-- <http://www.microtonal-synthesis.com/scale_johnston_25.html>
--
-- > scl <- scl_load "johnston_25"
-- > cents_i (scale_tuning 0.1 scl) == cents_i ben_johnston_25
ben_johnston_25 :: Tuning
ben_johnston_25 :: Tuning
ben_johnston_25 = Either [Rational] [Approximate_Ratio]
-> Maybe (Either Rational Approximate_Ratio) -> Tuning
Tuning (forall a b. a -> Either a b
Left [Rational]
ben_johnston_25_r) forall a. Maybe a
Nothing