Safe Haskell | None |
---|
This module defines notion of pitch.
- type Hz = Double
- type Interval = Double
- c1 :: Hz
- a1 :: Hz
- transpose :: Interval -> Hz -> Hz
- data Pitch = Pitch {
- pitchScale :: Scale
- pitchBend :: Bend
- pitchOctave :: Octave
- pitchStep :: Step
- fromStep :: Int -> Pitch
- type Bend = Double
- type Octave = Int
- type Step = Int
- data Scale = Scale {}
- fromIntervals :: Interval -> [Interval] -> Hz -> Scale
- scaleStep :: Scale -> Int -> Interval
- scaleLength :: Scale -> Int
- class PitchLike a where
- mapPitch :: PitchLike a => (Pitch -> Pitch) -> a -> a
- absPitch :: PitchLike a => a -> Hz
- pitchAsDouble :: Pitch -> Double
- scaleAt :: Scale -> Double -> Hz
Documentation
Pitch
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.
Pitch | |
|
Scale
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])
Scale | |
|
scaleLength :: Scale -> IntSource
Gives number of steps in one octave.
PitchLike
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.
Render
pitchAsDouble :: Pitch -> DoubleSource
Calculates position on tone plane for value of type Pitch
.