-- | Larry Polansky. \"Notes on the Tunings of Three Central Javanese
-- Slendro\/Pelog Pairs\". /Experimental Musical Instruments/,
-- 6(2):12-13,16-17, 1990.
module Music.Theory.Tuning.Polansky_1990 where

import Data.Ratio
import qualified Music.Theory.List as L
import qualified Music.Theory.Tuning as T

-- | Kanjutmesem Slendro (S1,S2,S3,S5,S6,S1')
--
-- > L.d_dx kanjutmesem_s == [252,238,241,236,253]
kanjutmesem_s :: Num n => [n]
kanjutmesem_s :: forall n. Num n => [n]
kanjutmesem_s = [n
0,n
252,n
490,n
731,n
967,n
1220]

-- | Kanjutmesem Pelog (P1,P2,P3,P4,P5,P6,P7,P1')
--
-- > L.d_dx kanjutmesem_p == [141,141,272,140,115,172,246]
kanjutmesem_p :: Num n => [n]
kanjutmesem_p :: forall n. Num n => [n]
kanjutmesem_p = [n
37,n
178,n
319,n
591,n
731,n
846,n
1018,n
1264]

-- | Darius Slendro (S1,S2,S3,S5,S6,S1')
--
-- > L.d_dx darius_s == [204,231,267,231,267]
-- > ax_r darius_s == [9/8,8/7,7/6,8/7,7/6]
darius_s :: Num n => [n]
darius_s :: forall n. Num n => [n]
darius_s = [n
0,n
204,n
435,n
702,n
933,n
1200]

-- | Madeleine Pelog (P1,P2,P3,P4,P5,P6,P7,P1')
--
-- > L.d_dx madeleine_p == [139,128,336,99,94,173,231]
-- > ax_r madeleine_p == [13/12,14/13,17/14,18/17,19/18,21/19,8/7]
madeleine_p :: Num n => [n]
madeleine_p :: forall n. Num n => [n]
madeleine_p = [n
137,n
276,n
404,n
740,n
839,n
933,n
1106,n
1337]

-- | Lipur Sih Slendro (S1,S2,S3,S5,S6,S1')
--
-- > L.d_dx lipur_sih_s == [273,236,224,258,256]
lipur_sih_s :: Num n => [n]
lipur_sih_s :: forall n. Num n => [n]
lipur_sih_s = [n
0,n
273,n
509,n
733,n
991,n
1247]

-- | Lipur Sih Pelog (P1,P2,P3,P4,P5,P6,P7,P1')
--
-- > L.d_dx lipur_sih_p == [110,153,253,146,113,179]
lipur_sih_p :: Num n => [n]
lipur_sih_p :: forall n. Num n => [n]
lipur_sih_p = [n
216,n
326,n
479,n
732,n
878,n
991,n
1170]

-- | Idealized ET Slendro, 5-tone equal temperament (p.17)
--
-- > L.d_dx idealized_et_s == [240,240,240,240,240]
idealized_et_s :: Num n => [n]
idealized_et_s :: forall n. Num n => [n]
idealized_et_s = [n
0,n
240,n
480,n
720,n
960,n
1200]

-- | Idealized ET Pelog, subset of 9-tone equal temperament (p.17)
--
-- > L.d_dx idealized_et_p == [400/3,800/3,400/3,400/3,400/3,400/3,800/3]
idealized_et_p :: Integral n => [Ratio n]
idealized_et_p :: forall n. Integral n => [Ratio n]
idealized_et_p = [Ratio n
160,Ratio n
293forall a. Num a => a -> a -> a
+Ratio n
1forall a. Fractional a => a -> a -> a
/Ratio n
3,Ratio n
560,Ratio n
693forall a. Num a => a -> a -> a
+Ratio n
1forall a. Fractional a => a -> a -> a
/Ratio n
3,Ratio n
826forall a. Num a => a -> a -> a
+Ratio n
2forall a. Fractional a => a -> a -> a
/Ratio n
3,Ratio n
960,Ratio n
1093forall a. Num a => a -> a -> a
+Ratio n
1forall a. Fractional a => a -> a -> a
/Ratio n
3,Ratio n
1360]

-- | Reconstruct approximate ratios to within @1e-3@ from intervals.
ax_r :: Real n => [n] -> [Rational]
ax_r :: forall n. Real n => [n] -> [Rational]
ax_r = forall a b. (a -> b) -> [a] -> [b]
map (Cents -> Cents -> Rational
T.reconstructed_ratio Cents
1e-3 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (Real a, Fractional b) => a -> b
realToFrac) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => [a] -> [a]
L.d_dx