A semitone is an Integer measuring musical distance from concert A. Zero represents 440 Hz; positive and negative values move above or below it. section 10.4.1
The Semitone type becomes Pitchable by converting its integer distance into frequency using 12-tone equal temperament, with concert A fixed at 440 Hz. section 10.4.1
Useful consequences of the representation include:
- Adding 12 semitones doubles frequency, while subtracting 12 halves it. section 10.4.1
- Semitones provide an intermediate representation for converting named chromatic notes into frequencies. section 10.4.1
GHCi calculations
toFrequency (0 :: Semitone) gives 440.0, toFrequency (12 :: Semitone) gives 880.0, and toFrequency (-12 :: Semitone) gives 220.0. section 10.4.1
Listing 10.13 A type for semitones
{-# LANGUAGE TypeSynonymInstances #-} #1
module Composition.Pitch where
...
type Semitone = Integer #2
instance Pitchable Semitone where
toFrequency semitone =
440 * (2.0 ** (fromInteger semitone / 12)) #3
Shows the Semitone alias and its Pitchable instance, including the frequency calculation. section 10.4.1
