Portability | non-portable (TF,GNTD) |
---|---|
Stability | experimental |
Maintainer | hans@hanshoglund.se |
Safe Haskell | None |
Provides semitone, octave and step representaiton of intervals.
- data Octaves
- class HasOctaves a where
- data Steps
- class HasSteps a where
- data Semitones
- class HasSemitones a where
- semitone :: Semitones
- tone :: Semitones
- ditone :: Semitones
- tritone :: Semitones
- isSemitone :: HasSemitones a => a -> Bool
- isTone :: HasSemitones a => a -> Bool
- isTritone :: HasSemitones a => a -> Bool
- (=:=) :: HasSemitones a => a -> a -> Bool
- (/:=) :: HasSemitones a => a -> a -> Bool
Types
Octaves
An interval represented as a number of octaves, including negative intervals.
octaves a = semitones a `div` 12 steps a = semitones a `mod` 12
class HasOctaves a whereSource
Class of intervals that has a number of Octaves
.
Returns the number of octaves spanned by an interval.
The number of octaves is negative if and only if the interval is negative.
Examples:
octaves (perfect unison) = 0 octaves (d5 ^* 4) = 2 octaves (-_P8) = -1
Steps
An interval represented as a number of steps in the range 0 ≤ x < 12.
octaves a = semitones a `div` 12 steps a = semitones a `mod` 12
Class of intervals that has a number of Steps
.
The number of steps is always in the range 0 ≤ x < 12.
Examples:
octaves (perfect unison) = 0 octaves (d5 ^* 4) = 2 octaves (-m7) = -1
Semitones
An interval represented as a number of semitones, including negative intervals, as well as intervals larger than one octave. This representation does not take spelling into account, so for example a major third and a diminished fourth can not be distinguished.
Intervals that name a number of semitones (i.e. semitone
, tritone
) does
not have an unequivocal spelling. To convert these to an interval, a
Spelling
must be provided as in:
spell sharps tritone == augmented fourth spell flats tritone == diminished fifth
class HasSemitones a whereSource
Class of intervals that can be converted to a number of Semitones
.
isSemitone :: HasSemitones a => a -> BoolSource
Returns true iff the given interval spans one semitone.
isTone :: HasSemitones a => a -> BoolSource
Returns true iff the given interval spans one whole tone (two semitones).
isTritone :: HasSemitones a => a -> BoolSource
Returns true iff the given interval spans three whole tones (six semitones).
Enharmonic equivalence
(=:=) :: HasSemitones a => a -> a -> BoolSource
Enharmonic equivalence.
(/:=) :: HasSemitones a => a -> a -> BoolSource
Enharmonic non-equivalence.