Copyright | Christoph Finkensiep 2021 |
---|---|
License | BSD |
Maintainer | chfin@chfin.de |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
Musicology.Pitch.Class
Description
This module defines a generic interface for pitch and interval types.
It provides three basic blocks of functionality:
- a set of type classes for generically working with intervals
- a generic type and associated operations for working with pitches
- functionality for reading and printing pitches and intervals in a common notation
Synopsis
- module Data.VectorSpace
- class VectorSpace i => Interval i where
- class (Interval i, Interval (IOf i), VectorSpace i, ICOf (IOf i) ~ i) => IntervalClass i where
- oct :: (IntervalClass i, s ~ Scalar (IOf i)) => s -> i -> IOf i
- unison :: Interval i => i
- class Interval i => Diatonic i where
- class Interval i => Chromatic i where
- chromaticSemitone :: i
- aug :: Chromatic i => i -> i
- dim :: Chromatic i => i -> i
- down :: Interval i => i -> i
- newtype ImperfectInterval i = Impf (i -> i)
- minor :: Chromatic i => ImperfectInterval i -> i
- major :: Interval i => ImperfectInterval i -> i
- newtype Pitch a = Pitch a
- toPitch :: a -> Pitch a
- toInterval :: Pitch a -> a
- pto :: AdditiveGroup v => Pitch v -> Pitch v -> v
- pfrom :: AdditiveGroup v => Pitch v -> Pitch v -> v
- (+^) :: AdditiveGroup a => Pitch a -> a -> Pitch a
- (^+) :: AdditiveGroup a => a -> Pitch a -> Pitch a
- (-^) :: AdditiveGroup a => Pitch a -> a -> Pitch a
- pc :: Interval p => Pitch p -> Pitch (ICOf p)
- class Notation i where
- showNotation :: i -> String
- showNotationT :: i -> Text
- parseNotation :: ReadP i
- readNotation :: String -> Maybe i
- readNotationT :: Text -> Maybe i
- transpose :: (Functor f, Interval i) => i -> f i -> f i
- embedI :: IntervalClass b => b -> IOf b -> b -> IOf b
- embedP :: IntervalClass a => a -> IOf a -> Pitch a -> Pitch (IOf a)
- embed :: (Functor f, IntervalClass a) => a -> IOf a -> f a -> f (IOf a)
- embed' :: (IOf (ICOf v) ~ v, Functor f, IntervalClass (ICOf v), Interval v) => v -> Pitch v -> f (ICOf v) -> f (IOf (ICOf v))
- class ToMidi i where
- class ToFreq i where
Intervals
Every interval implements the Interval
class.
Since intervals form vector spaces (or rather [modules]()),
Interval
inherits from VectorSpace
and the associated arithmetic operations ^+^
, ^-^
, *^
, and ^*
.
Each Interval
type is associated with an IntervalClass
type that implements octave equivalence.
In addition, the classes Diatonic
and Chromatic
provide extra functionality
for intervals that have diatonic and chromatic interpretations.
module Data.VectorSpace
class VectorSpace i => Interval i where Source #
class (Interval i, Interval (IOf i), VectorSpace i, ICOf (IOf i) ~ i) => IntervalClass i where Source #
class Interval i => Chromatic i where Source #
Methods
chromaticSemitone :: i Source #
Instances
Chromatic MidiIC Source # | |
Defined in Musicology.Pitch.Midi Methods | |
Chromatic SIC Source # | |
Defined in Musicology.Pitch.Spelled Methods | |
Chromatic SInterval Source # | |
Defined in Musicology.Pitch.Spelled Methods | |
Chromatic Int Source # | |
Defined in Musicology.Pitch.Midi Methods |
newtype ImperfectInterval i Source #
Constructors
Impf (i -> i) |
minor :: Chromatic i => ImperfectInterval i -> i Source #
major :: Interval i => ImperfectInterval i -> i Source #
Pitches
Pitches are derived from intervals by interpreting an interval relative to a conventional reference point,
which is specific to the interval type at hand.
A pitch is represented as a Pitch
value, which is a newtype wrapper around an interval type.
Calculating with pitches and intervals is done with
Constructors
Pitch a |
Instances
toInterval :: Pitch a -> a Source #
Notation
The Notation
class implements showing and reading a standard notation
that is compatible with other implementations of this library (for standard interval and pitch types).
class Notation i where Source #
Minimal complete definition
Methods
showNotation :: i -> String Source #
showNotationT :: i -> Text Source #
parseNotation :: ReadP i Source #
readNotation :: String -> Maybe i Source #
readNotationT :: Text -> Maybe i Source #
Instances
Notation MidiIC Source # | |
Defined in Musicology.Pitch.Midi | |
Notation MidiInterval Source # | |
Defined in Musicology.Pitch.Midi Methods showNotation :: MidiInterval -> String Source # showNotationT :: MidiInterval -> Text Source # parseNotation :: ReadP MidiInterval Source # readNotation :: String -> Maybe MidiInterval Source # readNotationT :: Text -> Maybe MidiInterval Source # | |
Notation MidiPC Source # | |
Defined in Musicology.Pitch.Midi | |
Notation MidiPitch Source # | |
Defined in Musicology.Pitch.Midi | |
Notation SIC Source # | |
Defined in Musicology.Pitch.Spelled | |
Notation SInterval Source # | |
Defined in Musicology.Pitch.Spelled | |
Notation SPC Source # | |
Defined in Musicology.Pitch.Spelled | |
Notation SPitch Source # | |
Defined in Musicology.Pitch.Spelled |
Other Functions
embed' :: (IOf (ICOf v) ~ v, Functor f, IntervalClass (ICOf v), Interval v) => v -> Pitch v -> f (ICOf v) -> f (IOf (ICOf v)) Source #