music-pitch-1.9.0: Musical pitch representation.

Safe HaskellNone
LanguageHaskell2010

Music.Pitch.Equal

Contents

Description

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.

Synopsis

Equal temperament

data Equal a Source

Instances

Eq (Equal a) 
IsNat a => Num (Equal a) 
Ord (Equal a) 
Show (Equal a) 
IsNat a => Monoid (Equal a) 
IsNat a => AdditiveGroup (Equal a) 
IsNat a => Semigroup (Equal a) 
IsNat a => VectorSpace (Equal a) 
type Scalar (Equal a) = Equal a 

toEqual :: IsNat a => Int -> Equal a Source

 Create an equal-temperament value.

fromEqual :: IsNat a => Equal a -> Int Source

Extract an equal-temperament value.

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

Synonyms

type Equal6 = Equal N6 Source

type Equal12 = Equal N12 Source

Extra type-level naturals

type N20 = N10 :*: N2 Source

type N30 = N10 :*: N3 Source

type N17 = N10 :+: N7 Source

type N24 = N20 :+: N4 Source

type N36 = N30 :+: N6 Source