temporal-music-notation-0.2.3: music notation

Safe HaskellNone




This module defines notion of pitch.



type Hz = DoubleSource

Cycles per second

type Interval = DoubleSource

Multiplier of Hz

c1 :: HzSource

Middle C (261.626 Hz)

a1 :: HzSource

Middle A (440 Hz)

transpose :: Interval -> Hz -> HzSource

Transpose cycles per second by some interval.


data Pitch Source

Pitch denotes Hz value. But it's not a double for ease of performing some musical transformations, transposition, bend, inversion, changing scales. Pitch can be converted to Hz with function hz. Pitch contains Scale, and point on the tone plane. The point is a triple (bend, octave, step). Bend denotes divergens from vertices of scale grid. Octave and Step are integers.



fromStep :: Int -> PitchSource

Constructs Pitch from some step value. Bend and Octave are set to zeroes. Scale is set to default scale which is defined in HasScale class.

type Bend = DoubleSource

Bend represents tone's diversion from scale grid.


data Scale Source

Scale defines 2D grid (octave, step) in space of Hz units. Bend is a level of diversion from grid vertices. 1-level bend is equal to 1 step. For tones with fractional bends frequency is calculated with linear interpolation by nearest values in scale. Example:

 s = Scale f0 d intervals

Here scale s defines 2D grid that mapps center point (0, 0) to frequency f0 Hz. Value d is octave interval. Octave interval is divided on steps. Steps are Interval s from base frequency f0 to desired frequency. Let's define equal temperament scale:

 eqt = Scale c1 2 $ Vector.fromList $ (map ((2 **) . (/12)) [0..11])

fromIntervals :: Interval -> [Interval] -> Hz -> ScaleSource

Scale constructor.

scaleStep :: Scale -> Int -> IntervalSource

Gives scale multiplier

scaleLength :: Scale -> IntSource

Gives number of steps in one octave.


class PitchLike a whereSource

Pitch can be used alongside with many other parameters (they can define timbre or loudness). Class PitchLike provides getters and setters for data types that contain value of type Pitch. In Temporal.Music.Score module you can find many functions that are defined in terms of this class. Once you have chosen some note representation you can make an instance for it and use all pitch-modifiers.


setPitch :: Pitch -> a -> aSource

getPitch :: a -> PitchSource


mapPitch :: PitchLike a => (Pitch -> Pitch) -> a -> aSource

Pitch modifier.


absPitch :: PitchLike a => a -> HzSource

Calculates cycles per second for a pitch.

pitchAsDouble :: Pitch -> DoubleSource

Calculates position on tone plane for value of type Pitch.

scaleAt :: Scale -> Double -> HzSource

Scale value on doubles