music-pitch-1.3: Abstract representation of musical pitch.

Safe HaskellNone

Music.Pitch.Relative.Semitones

Contents

Synopsis

Octaves

data Octaves Source

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.

Methods

octaves :: a -> OctavesSource

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

data Steps Source

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 HasSteps a whereSource

Class of intervals that has a number of Steps.

Methods

steps :: a -> StepsSource

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

data Semitones Source

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.

Methods

semitones :: a -> SemitonesSource

Returns the number of semitones spanned by an interval.

The number of semitones is negative if and only if the interval is negative.

Examples:

 semitones (perfect unison)  =  0
 semitones tritone           =  6
 semitones d5                =  6
 semitones (-_P8)            =  -12

semitone :: SemitonesSource

Precisely one semitone.

tone :: SemitonesSource

Precisely one whole tone, or two semitones.

ditone :: SemitonesSource

Precisely two whole tones, or four semitones.

tritone :: SemitonesSource

Precisely three whole tones, or six 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.