Safe Haskell | None |
---|
- data Interval
- interval :: Quality -> Number -> Interval
- perfect :: Number -> Interval
- major :: Number -> Interval
- minor :: Number -> Interval
- augmented :: Number -> Interval
- diminished :: Number -> Interval
- doublyAugmented :: Number -> Interval
- doublyDiminished :: Number -> Interval
- number :: Interval -> Number
- isPositive :: Interval -> Bool
- isNegative :: Interval -> Bool
- isSimple :: Interval -> Bool
- isCompound :: Interval -> Bool
- separate :: Interval -> (Octaves, Interval)
- simple :: Interval -> Interval
- invert :: Interval -> Interval
- type Spelling = Semitones -> Number
- spell :: HasSemitones a => Spelling -> a -> Interval
- sharps :: Semitones -> Number
- flats :: Semitones -> Number
- d1 :: Interval
- _P1 :: Interval
- _A1 :: Interval
- d2 :: Interval
- m2 :: Interval
- _M2 :: Interval
- _A2 :: Interval
- d3 :: Interval
- m3 :: Interval
- _M3 :: Interval
- _A3 :: Interval
- d4 :: Interval
- _P4 :: Interval
- _A4 :: Interval
- d5 :: Interval
- _P5 :: Interval
- _A5 :: Interval
- d6 :: Interval
- m6 :: Interval
- _M6 :: Interval
- _A6 :: Interval
- d7 :: Interval
- m7 :: Interval
- _M7 :: Interval
- _A7 :: Interval
- d8 :: Interval
- _P8 :: Interval
- _A8 :: Interval
- intervalDiff :: Interval -> Int
- interval' :: Int -> Int -> Interval
- octave :: Number
Intervals
An interval is the difference between two pitches, incuding negative intervals.
Intervals and pitches can be added using .+^
. To get the interval between
two pitches, use .-.
.
c .+^ minor third == eb f .-. c == perfect fourth
Adding intervals preserves spelling. For example:
m3 ^+^ _M3 = _P5 d5 ^+^ _M6 = m10
The scalar type of intervals are Integer
, using ^*
to stack intervals
of a certain type on top of each other. For example _P5 ^* 2
is a stack
of 2 perfect fifths. The Num
instance works as expected for +
, negate
and abs
, and arbitrarily uses octaves for multiplication. If you find
yourself *
, or signum
on intervals, consider switching to ^*
or
normalized
.
Intervals are generally described in terms of Quality
and Number
. To
construct an interval, use the interval
constructor, the utility
constructors major
, minor
, augmented
and diminished
, or the
interval literals:
m5 == minor fifth == interval Minor 5 _P4 == perfect fourth == interval Perfect 5 d5 == diminished fifth == diminish (perfect fifth)
Creating intervals
perfect :: Number -> IntervalSource
Creates a perfect interval. If given an inperfect number, constructs a major interval.
major :: Number -> IntervalSource
Creates a major interval. If given a perfect number, constructs a perfect interval.
minor :: Number -> IntervalSource
Creates a minor interval. If given a perfect number, constructs a diminished interval.
diminished :: Number -> IntervalSource
Creates a diminished interval.
doublyAugmented :: Number -> IntervalSource
Creates a doubly augmented interval.
doublyDiminished :: Number -> IntervalSource
Creates a doubly diminished interval.
Inspecting intervals
isPositive :: Interval -> BoolSource
Returns whether the given interval is positive.
isNegative :: Interval -> BoolSource
Returns whether the given interval is negative.
Simple and compound intervals
isSimple :: Interval -> BoolSource
Returns whether the given interval is simple.
A simple interval is an positive interval spanning less than one octave.
isCompound :: Interval -> BoolSource
Returns whether the given interval is compound.
A compound interval is either a negative interval, or a positive interval spanning more than octave.
separate :: Interval -> (Octaves, Interval)Source
Separate a compound interval into octaves and a simple interval.
(perfect octave)^*x + y = z iff (x, y) = separate z
simple :: Interval -> IntervalSource
Returns the simple part of an interval.
(perfect octave)^*x + y = z iff y = simple z
Inversion
invert :: Interval -> IntervalSource
Intervallic inversion.
The inversion of a simple interval is determined by the following rules:
- The interval number and the number of its inversion always add up to nine (i.e. 4 + 5 = 9).
- The inversion of a major interval is a minor interval, and vice versa; the inversion of a perfect interval is also perfect; the inversion of an augmented interval is a diminished interval, and vice versa; the inversion of a doubly augmented interval is a doubly diminished interval, and vice versa.
The inversion of any compound interval is always the same as the inversion of the simple interval from which it is compounded, i.e.:
invert = simple . negate
Utility
Spelling
spell :: HasSemitones a => Spelling -> a -> IntervalSource
Literals (TODO move)
intervalDiff :: Interval -> IntSource