music-pitch-1.7.2: Musical pitch representation.

Copyright(c) Hans Hoglund, Edward Lilley 2012–2014
LicenseBSD-style
Maintainerhans@hanshoglund.se
Stabilityexperimental
Portabilitynon-portable (TF,GNTD)
Safe HaskellNone
LanguageHaskell2010

Music.Pitch.Common.Semitones

Contents

Description

Provides semitone, octave and step representation of intervals.

Synopsis

Types

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

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

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:

>>> spell usingSharps tritone
_A4
>>> spell usingFlats  tritone
d5

class HasSemitones a where Source

Class of intervals that can be converted to a number of Semitones.

Methods

semitones :: a -> Semitones Source

Returns the number of semitones spanned by an interval.

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

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

semitone :: Semitones Source

Precisely one semitone.

tone :: Semitones Source

Precisely one whole tone, or two semitones.

ditone :: Semitones Source

Precisely two whole tones, or four semitones.

tritone :: Semitones Source

Precisely three whole tones, or six semitones.

isSemitone :: HasSemitones a => a -> Bool Source

Returns true iff the given interval spans one semitone.

isTone :: HasSemitones a => a -> Bool Source

Returns true iff the given interval spans one whole tone (two semitones).

isTritone :: HasSemitones a => a -> Bool Source

Returns true iff the given interval spans three whole tones (six semitones).

Enharmonic equivalence

(=:=) :: HasSemitones a => a -> a -> Bool infix 4 Source

Enharmonic equivalence.

>>> asInterval _A2 == m3
False
>>> asInterval _A2 =:= m3
True

(/:=) :: HasSemitones a => a -> a -> Bool infix 4 Source

Enharmonic non-equivalence.

>>> asInterval _A2 /= m3
True
>>> asInterval _A2 /:= m3
False