Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic equal temperament pitch.
Use the type-level numbers to construct an temperement dividing the octave in any number of equal-sized steps.
Common cases such as 6, 12 and 24 are provided for convenience.
- data Equal a
- toEqual :: IsNat a => Int -> Equal a
- fromEqual :: IsNat a => Equal a -> Int
- equalToRatio :: IsNat a => Equal a -> Double
- size :: IsNat a => Equal a -> Int
- cast :: (IsNat a, IsNat b) => Equal a -> Equal b
- type Equal6 = Equal N6
- type Equal12 = Equal N12
- type Equal17 = Equal N17
- type Equal24 = Equal N24
- type Equal36 = Equal N36
- type N20 = N10 :*: N2
- type N30 = N10 :*: N3
- type N17 = N10 :+: N7
- type N24 = N20 :+: N4
- type N36 = N30 :+: N6
Equal temperament
equalToRatio :: IsNat a => Equal a -> Double Source
Convert an equal-temeperament value to a frequency ratio.
>>>
equalToRatio (7 :: Equal12)
1.4983070768766815
>>>
equalToRatio (4 :: Equal12)
1.2599210498948732
size :: IsNat a => Equal a -> Int Source
Size of this type (value not evaluated).
>>>
size (undefined :: Equal N2)
2
>>>
size (undefined :: Equal N12)
12
cast :: (IsNat a, IsNat b) => Equal a -> Equal b Source
Safely cast a tempered value to another size.
>>>
cast (1 :: Equal12) :: Equal24
2 :: Equal24
>>>
cast (8 :: Equal12) :: Equal6
4 :: Equal6
>>>
(2 :: Equal12) + cast (2 :: Equal24)
3 :: Equal12