| Copyright | (c) Hans Hoglund 2012-2014 |
|---|---|
| License | BSD-style |
| Maintainer | hans@hanshoglund.se |
| Stability | experimental |
| Portability | non-portable (TF,GNTD) |
| Safe Haskell | None |
| Language | Haskell2010 |
Music.Score.Pitch
Description
Provides functions for manipulating pitch.
- type family Pitch s :: *
- type family SetPitch b s :: *
- type Interval a = Diff (Pitch a)
- class HasPitches s t => HasPitch s t where
- class (Transformable (Pitch s), Transformable (Pitch t), SetPitch (Pitch t) s ~ t) => HasPitches s t where
- fromPitch' :: (HasPitches' a, IsPitch a) => Pitch a -> a
- type HasPitch' a = HasPitch a a
- type HasPitches' a = HasPitches a a
- pitch' :: (HasPitch s t, s ~ t) => Lens' s (Pitch s)
- pitches' :: (HasPitches s t, s ~ t) => Traversal' s (Pitch s)
- up :: Transposable a => Interval a -> a -> a
- down :: Transposable a => Interval a -> a -> a
- above :: (Semigroup a, Transposable a) => Interval a -> a -> a
- below :: (Semigroup a, Transposable a) => Interval a -> a -> a
- octavesUp :: Transposable a => Scalar (Interval a) -> a -> a
- octavesDown :: Transposable a => Scalar (Interval a) -> a -> a
- octavesAbove :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a
- octavesBelow :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a
- fifthsUp :: Transposable a => Scalar (Interval a) -> a -> a
- fifthsDown :: Transposable a => Scalar (Interval a) -> a -> a
- fifthsAbove :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a
- fifthsBelow :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a
- _15va :: Transposable a => a -> a
- _8va :: Transposable a => a -> a
- _8vb :: Transposable a => a -> a
- _15vb :: Transposable a => a -> a
- inv :: Transposable a => Pitch a -> a -> a
- invertPitches :: Transposable a => Pitch a -> a -> a
- highest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a)
- lowest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a)
- meanPitch :: (HasPitches' a, Fractional (Pitch a)) => a -> Pitch a
- type PitchPair v w = (Num (Scalar v), IsInterval v, IsPitch w)
- type AffinePair v w = (VectorSpace v, AffineSpace w)
- type Transposable a = (HasPitches' a, AffinePair (Interval a) (Pitch a), PitchPair (Interval a) (Pitch a))
Pitch type
type family Pitch s :: * Source
This type fuction is used to access the pitch type for a given type.
Instances
| type Pitch Bool = Bool | |
| type Pitch Char = Char | |
| type Pitch Double = Double | |
| type Pitch Float = Float | |
| type Pitch Int = Int | |
| type Pitch Integer = Integer | |
| type Pitch Ordering = Ordering | |
| type Pitch () = () | |
| type Pitch [a] = Pitch a | |
| type Pitch (Maybe a) = Pitch a | |
| type Pitch (Sum a) = Pitch a | |
| type Pitch (Stretched a) = Pitch a | |
| type Pitch (Voice a) = Pitch a | |
| type Pitch (Delayed a) = Pitch a | |
| type Pitch (Chord a) = Pitch a | |
| type Pitch (Track a) = Pitch a | |
| type Pitch (Note a) = Pitch a | |
| type Pitch (Score a) = Pitch a | |
| type Pitch (Behavior a) = Behavior a | |
| type Pitch (TieT a) = Pitch a | |
| type Pitch (SlideT a) = Pitch a | |
| type Pitch (TextT a) = Pitch a | |
| type Pitch (HarmonicT a) = Pitch a | |
| type Pitch (TremoloT a) = Pitch a | |
| type Pitch (ColorT a) = Pitch a | |
| type Pitch (Either c a) = Pitch a | |
| type Pitch (c, a) = Pitch a | |
| type Pitch (Couple c a) = Pitch a | |
| type Pitch (PartT p a) = Pitch a | |
| type Pitch (DynamicT p a) = Pitch a | |
| type Pitch (ArticulationT p a) = Pitch a |
type family SetPitch b s :: * Source
This type fuction is used to update the pitch type for a given type. The first argument is the new type.
Instances
HasPitch classes
class HasPitches s t => HasPitch s t where Source
Class of types that provide a single pitch.
Methods
pitch :: Lens s t (Pitch s) (Pitch t) Source
Access the pitch.
As this is a Traversal, you can use all combinators from the lens package,
for example:
pitch.~ c :: (HasPitch'a,IsPitcha) => a -> apitch+~ 2 :: (HasPitch'a,Num(Pitcha)) => a -> apitch%~succ:: (HasPitch'a,Enum(Pitcha)) => a -> aviewpitch::HasPitches'a => a ->Pitchasetpitch::HasPitchesa b =>Pitchb -> a -> boverpitch::HasPitchesa b => (Pitcha ->Pitchb) -> a -> b
Instances
class (Transformable (Pitch s), Transformable (Pitch t), SetPitch (Pitch t) s ~ t) => HasPitches s t where Source
Class of types that provide zero or more pitches.
Methods
pitches :: Traversal s t (Pitch s) (Pitch t) Source
Access all pitches.
As this is a Traversal, you can use all combinators from the lens package,
for example:
toListOfpitches::HasPitches'a => a -> [Pitcha]allOfpitches:: (HasPitches'a) => (Pitcha ->Bool) -> a ->BoolmaximumOfpitches:: (HasPitches'a,Ord(Pitcha)) => a ->Maybe(Pitcha)setpitches::HasPitchesa b =>Pitchb -> a -> boverpitches::HasPitchesa b => (Pitcha ->Pitchb) -> a -> b
Instances
fromPitch' :: (HasPitches' a, IsPitch a) => Pitch a -> a Source
Inject a pitch into some larger type.
Simple versions
type HasPitches' a = HasPitches a a Source
pitch' :: (HasPitch s t, s ~ t) => Lens' s (Pitch s) Source
Access the pitch.
Same as pitch, but without polymorphic update.
pitches' :: (HasPitches s t, s ~ t) => Traversal' s (Pitch s) Source
Access all pitches.
Same as pitches, but without polymorphic update.
Transposition
up :: Transposable a => Interval a -> a -> a Source
Transpose pitch upwards.
Not to be confused with matrix transposition.
>>>up m3 ceb
>>>up _P5 [c,d,e :: Pitch][g,a,b]
>>>up _P5 [440 :: Hertz, 442, 810][g,a,b]
down :: Transposable a => Interval a -> a -> a Source
Transpose pitch downwards.
Not to be confused with matrix transposition.
>>>down m3 ca
>>>down _P5 [c,d,e][f_,g_,a_]
above :: (Semigroup a, Transposable a) => Interval a -> a -> a Source
Add the given interval above.
>>>above _P8 [c][c,c']
below :: (Semigroup a, Transposable a) => Interval a -> a -> a Source
Add the given interval below.
>>>below _P8 [c][c,c_]
octavesUp :: Transposable a => Scalar (Interval a) -> a -> a Source
Transpose up by the given number of octaves.
>>>octavesUp 2 cc''
>>>octavesUp 1 [c,d,e][c',d',e']
>>>octavesUp (-1) [c,d,e][c_,d_,e_]
octavesDown :: Transposable a => Scalar (Interval a) -> a -> a Source
Transpose down by the given number of octaves.
>>>octavesDown 2 cc__
>>>octavesDown 1 [c,d,e][c_,d_,e_]
>>>octavesDown (-1) [c,d,e][c',d',e']
octavesAbove :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a Source
Add the given octave above.
octavesBelow :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a Source
Add the given octave below.
fifthsUp :: Transposable a => Scalar (Interval a) -> a -> a Source
Transpose up by the given number of fifths.
fifthsDown :: Transposable a => Scalar (Interval a) -> a -> a Source
Transpose down by the given number of fifths.
fifthsAbove :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a Source
Add the given octave above.
fifthsBelow :: (Semigroup a, Transposable a) => Scalar (Interval a) -> a -> a Source
Add the given octave below.
_15va :: Transposable a => a -> a Source
Shorthand for .octavesUp 2
_8va :: Transposable a => a -> a Source
Shorthand for .octavesUp 1
_8vb :: Transposable a => a -> a Source
Shorthand for .octavesDown 1
_15vb :: Transposable a => a -> a Source
Shorthand for .octavesDown 2
Inversion
inv :: Transposable a => Pitch a -> a -> a Source
Deprecated: Use invertPitches
invertPitches :: Transposable a => Pitch a -> a -> a Source
Invert pitches.
Folds
highest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a) Source
Return the highest pitch in the given music.
lowest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a) Source
Return the lowest pitch in the given music.
meanPitch :: (HasPitches' a, Fractional (Pitch a)) => a -> Pitch a Source
Return the mean pitch in the given music.
type AffinePair v w = (VectorSpace v, AffineSpace w) Source
type Transposable a = (HasPitches' a, AffinePair (Interval a) (Pitch a), PitchPair (Interval a) (Pitch a)) Source
Class of types that can be transposed, inverted and so on.