hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Tuning.Type

Description

Tuning type

Synopsis

Tuning

data Tuning Source #

A tuning specified Either as a sequence of exact ratios, or as a sequence of possibly inexact Cents, and an octave if not 2:1 or 1200.

In both cases, the values are given in relation to the first degree of the scale, which for ratios is 1 and for cents 0.

Instances

Instances details
Show Tuning Source # 
Instance details

Defined in Music.Theory.Tuning.Type

Eq Tuning Source # 
Instance details

Defined in Music.Theory.Tuning.Type

Methods

(==) :: Tuning -> Tuning -> Bool #

(/=) :: Tuning -> Tuning -> Bool #

tn_epsilon :: Double Source #

Default epsilon for recovering ratios from cents.

tn_as_ratio :: Double -> Either Rational Cents -> Rational Source #

Tuning value as rational, reconstructed if required.

tn_as_cents :: Either Rational Cents -> Cents Source #

Tuning value as cents.

tn_octave_def :: Tuning -> Either Rational Cents Source #

Tuning octave, defaulting to 2:1.

tn_octave_cents :: Tuning -> Cents Source #

Tuning octave in cents.

tn_octave_ratio :: Double -> Tuning -> Rational Source #

Tuning octave as ratio cents.

tn_divisions :: Tuning -> Int Source #

Divisions of octave.

tn_divisions (tn_equal_temperament 12) == 12

tn_ratios :: Tuning -> Maybe [Rational] Source #

Maybe exact ratios of Tuning, NOT including the octave.

tn_limit :: Tuning -> Maybe Integer Source #

Limit of JI tuning.

tn_cents :: Tuning -> [Cents] Source #

Possibly inexact Cents of tuning, NOT including the octave.

tn_cents_i :: Integral i => Tuning -> [i] Source #

map round . cents.

tn_cents_octave :: Tuning -> [Cents] Source #

Variant of tn_cents that includes octave at right.

tn_approximate_ratios :: Tuning -> [Approximate_Ratio] Source #

Possibly inexact Approximate_Ratios of tuning.

tn_approximate_ratios_cyclic :: Tuning -> [Approximate_Ratio] Source #

Cyclic form, taking into consideration octave_ratio.

tn_ratios_lookup :: Tuning -> Int -> Maybe Rational Source #

Lookup function that allows both negative & multiple octave indices.

:l Music.Theory.Tuning.DB.Werckmeister
let map_zip f l = zip l (map f l)
map_zip (tn_ratios_lookup werckmeister_vi) [-24 .. 24]

tn_approximate_ratios_lookup :: Tuning -> Int -> Approximate_Ratio Source #

Lookup function that allows both negative & multiple octave indices.

map_zip (tn_approximate_ratios_lookup werckmeister_v) [-24 .. 24]

tn_reconstructed_ratios :: Double -> Tuning -> Maybe [Rational] Source #

Maybe exact ratios reconstructed from possibly inexact Cents of Tuning.

:l Music.Theory.Tuning.DB.Werckmeister
let r = [1,17/16,9/8,13/11,5/4,4/3,7/5,3/2,11/7,5/3,16/9,15/8]
tn_reconstructed_ratios 1e-2 werckmeister_iii == Just r

Equal temperaments

tn_equal_temperament :: Integral n => n -> Tuning Source #

Make n division equal temperament.

tn_equal_temperament_12 :: Tuning Source #

12-tone equal temperament.

tn_cents tn_equal_temperament_12 == [0,100..1100]

tn_equal_temperament_19 :: Tuning Source #

19-tone equal temperament.

let c = [0,63,126,189,253,316,379,442,505,568,632,695,758,821,884,947,1011,1074,1137]
tn_cents_i tn_equal_temperament_19 == c

tn_equal_temperament_31 :: Tuning Source #

31-tone equal temperament.

tn_equal_temperament_53 :: Tuning Source #

53-tone equal temperament.

tn_equal_temperament_72 :: Tuning Source #

72-tone equal temperament.

let r = [0,17,33,50,67,83,100]
take 7 (map round (tn_cents tn_equal_temperament_72)) == r

tn_equal_temperament_96 :: Tuning Source #

96-tone equal temperament.