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 |
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
- type HasPitch' a = HasPitch a a
- type HasPitches' a = HasPitches a a
- pitch' :: HasPitch' s => Lens' s (Pitch s)
- pitches' :: HasPitches' s => Traversal' s (Pitch s)
- 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))
- 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
- _15va :: Transposable a => a -> a
- _8va :: Transposable a => a -> a
- _8vb :: Transposable a => a -> a
- _15vb :: Transposable 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 -> Maybe (Pitch a)
Pitch type
type family Pitch s :: * Source
This type fuction is used to access the pitch type for a given type.
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 (Sum a) = Pitch a | |
type Pitch (Maybe a) = Pitch a | |
type Pitch (Seq a) = Pitch a | |
type Pitch (Note a) = Pitch a | |
type Pitch (Voice a) = Pitch a | |
type Pitch (Placed a) = Pitch a | |
type Pitch (Track a) = Pitch a | |
type Pitch (Event a) = Pitch a | |
type Pitch (Score a) = Pitch a | |
type Pitch (Aligned 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 (Map k 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.
HasPitch classes
class HasPitches s t => HasPitch s t where Source
Class of types that provide a single pitch.
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.
Simple versions
type HasPitches' a = HasPitches a a Source
pitch' :: HasPitch' s => Lens' s (Pitch s) Source
Access the pitch.
Same as pitch
, but without polymorphic update.
pitches' :: HasPitches' s => Traversal' s (Pitch s) Source
Access all pitches.
Same as pitches
, but without polymorphic update.
Transposition
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.
up :: Transposable a => Interval a -> a -> a Source
Transpose (translate) up.
>>>
up m3 (c :: Pitch)
eb
>>>
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 (translate) down.
>>>
down m3 (c :: Pitch)
a
>>>
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 :: Pitch]
[c,c']
below :: (Semigroup a, Transposable a) => Interval a -> a -> a Source
Add the given interval below.
>>>
below _P8 [c :: Pitch]
[c,c_]
octavesUp :: Transposable a => Scalar (Interval a) -> a -> a Source
Transpose up by the given number of octaves.
>>>
octavesUp 2 (c :: Pitch)
c''
>>>
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 (c :: Pitch)
c__
>>>
octavesDown 1 [c,d,e]
[c_,d_,e_]
>>>
octavesDown (-1) [c,d,e]
[c',d',e']
_15va :: Transposable a => a -> a Source
Same as
.octavesUp
2
_8va :: Transposable a => a -> a Source
Same as
.octavesUp
1
_8vb :: Transposable a => a -> a Source
Same as
.octavesDown
1
_15vb :: Transposable a => a -> a Source
Same as
.octavesDown
2
Inversion
invertPitches :: Transposable a => Pitch a -> a -> a Source
Invert pitches.
Folds
highest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a) Source
Extract the highest pitch. Returns Nothing
if there are none.
lowest :: (HasPitches' a, Ord (Pitch a)) => a -> Maybe (Pitch a) Source
Extract the lowest pitch. Returns Nothing
if there are none.
meanPitch :: (HasPitches' a, Fractional (Pitch a)) => a -> Maybe (Pitch a) Source
Extract the average pitch. Returns Nothing
if there are none.