Representing pitch
 type Frequency = Double
 c1 :: Frequency
 a1 :: Frequency
 class Seg a => Pch a where
 data Seg n => Pitch n = Pitch {
 pitchScale :: Scale
 pitchTone :: Tone n
 type Interval = Frequency
 data Scale = Scale {
 scaleBase :: (Int, Frequency)
 scaleOctave :: Interval
 scaleSteps :: Vector Interval
 scaleSize :: Scale > Int
 fromIntervals :: Interval > [Interval] > Int > Frequency > Scale
 type Bend = Double
 type Octave = Int
 type Step = Int
 data Seg n => Tone n = Tone {
 toneBend :: Bend
 toneOctave :: Octave
 toneStep :: n
 tone :: Seg n => n > Tone n
 toneNum :: Seg n => Tone n > Int
 class PitchFunctor a where
 setScale :: PitchFunctor a => Scale > a > a
 mapBase :: PitchFunctor a => (Frequency > Frequency) > a > a
 setBase :: PitchFunctor a => Frequency > a > a
 transposeScale :: PitchFunctor a => Step > a > a
 class ToneFunctor a where
 setBend :: ToneFunctor a => Bend > a > a
 bend :: ToneFunctor a => Bend > a > a
 step :: ToneFunctor a => Step > a > a
 transp :: ToneFunctor a => Step > a > a
 low :: ToneFunctor a => a > a
 l' :: ToneFunctor a => a > a
 ll' :: ToneFunctor a => a > a
 high :: ToneFunctor a => a > a
 h' :: ToneFunctor a => a > a
 hh' :: ToneFunctor a => a > a
 lower :: ToneFunctor a => Int > a > a
 higher :: ToneFunctor a => Int > a > a
 invert :: ToneFunctor a => Step > a > a
 frequency :: Seg n => Scale > Tone n > Frequency
 absPitch :: Seg n => Pitch n > Frequency
 toneAsDouble :: Seg s => Tone s > Double
 scaleAt :: Scale > Double > Double
 scaleAtInt :: Scale > Int > Frequency
 scaleStep :: Scale > Int > Interval
Types
There are four main datatypes Frequency
, Pitch
, Scale
and Tone
.
Pitch
consists of Scale
and Tone
.
Every Pitch
can be converted to Frequency
(see a absPitch
).
Scale
defines logarithmic mapping from 2d integer coordinates of
Tone
to 1d double values. Scale
is 2d logarithmic grid in
frequency domain and Tone
is point on that grid.
Pitch  

Scale
defines 2d grid in frequency domain. First value of 2d vector
is octave and second is step. Scale
consists of base tone,
octave interval and individual tone intervals inside octave.
Base tone links scale coordinates to frequency coordinates.
Base tone is pair (n, f) of integer value and frequency value,
Base tone defines that
corresponds to frequency tone
nf
.
For example scales s1
and s2
are equal
import Temporal.Music.Notation.Local.Scales(eqt) s1 = eqt 0 c1 s2 = eqt 9 a1
This doesn't make much sense for equal temperament. But can be useful for just scales. For example this gives just pythagorean scale in G major
import Temporal.Music.Notation.Local.Scales(pyth) pythG = pyth 7 (3/2 * c1)
if you write just pyth 0 (3/2 * c1)
note (0 :: Tone N12) corresponds
to G.
fromIntervals :: Interval > [Interval] > Int > Frequency > ScaleSource
fromIntervals
makes scale constructor from octave
interval and
scale step intervals.
Transformers
Pitch
class PitchFunctor a whereSource
PitchFunctor a => PitchFunctor (Score a)  
Seg n => PitchFunctor (Pitch n)  
(Seg nVol, Seg nPch) => PitchFunctor (Note nVol nPch a) 
Scale
setScale :: PitchFunctor a => Scale > a > aSource
setting specific scale
mapBase :: PitchFunctor a => (Frequency > Frequency) > a > aSource
mapping of scale base tone
setBase :: PitchFunctor a => Frequency > a > aSource
setting scale base tone
transposeScale :: PitchFunctor a => Step > a > aSource
transposeScale
shifts scaleSteps by given number.
For example if your just scale is defined with middle C as base
and you want to transpose it to middle D you can write
res = someScale 2 (wholeTone * c1) where wholeTone = 9/8
or
transposeScale 2 $ someScale 0 c1
And now 0 corresponds to middle C and step multipliers are rearranged so that someScale starts from middle D.
Tone
class ToneFunctor a whereSource
transformer for types that contain tone
ToneFunctor a => ToneFunctor (Score a)  
Seg n => ToneFunctor (Tone n)  
Seg n => ToneFunctor (Pitch n)  
(Seg nVol, Seg nPch) => ToneFunctor (Note nVol nPch a) 
setBend :: ToneFunctor a => Bend > a > aSource
set bend value
bend :: ToneFunctor a => Bend > a > aSource
shift in bends
step :: ToneFunctor a => Step > a > aSource
transposition, shift in steps
transp :: ToneFunctor a => Step > a > aSource
transposition, shift in steps
low :: ToneFunctor a => a > aSource
one octave lower
l' :: ToneFunctor a => a > aSource
shorcut for low
ll' :: ToneFunctor a => a > aSource
shorcut for lower
2
high :: ToneFunctor a => a > aSource
one octave higher
h' :: ToneFunctor a => a > aSource
shorcut for high
hh' :: ToneFunctor a => a > aSource
shorcut for higher
2
lower :: ToneFunctor a => Int > a > aSource
shifts downwards in octaves
higher :: ToneFunctor a => Int > a > aSource
shifts upwards in octaves
invert :: ToneFunctor a => Step > a > aSource
inverts note around some tone center. Tone center defines two tones octave apart around current note in wich inversion takes place.
For example with center at 5 note c
in twelve tone scale
[5, 6, 7, 8, 9, bb, 11, c, 1, 2, 3, 4, 5]
goes into note bb.
Inversion counts number of steps from lower center tone to given tone
and then result is higher center tone shifted lower by this number.
Rendering
frequency :: Seg n => Scale > Tone n > FrequencySource
calculates frequency value for given tone on scale grid
toneAsDouble :: Seg s => Tone s > DoubleSource
flattens tone to double.
scaleAtInt :: Scale > Int > FrequencySource
scale value on integers