temporal-music-notation-western 0.1 → 0.1.2
raw patch · 5 files changed
+527/−370 lines, 5 filesdep ~temporal-music-notation
Dependency ranges changed: temporal-music-notation
Files
- src/Temporal/Music/Notation/Local/Western.hs +0/−367
- src/Temporal/Music/Western.hs +251/−0
- src/Temporal/Music/Western/BohlenPierce.hs +64/−0
- src/Temporal/Music/Western/TwelveTone.hs +207/−0
- temporal-music-notation-western.cabal +5/−3
− src/Temporal/Music/Notation/Local/Western.hs
@@ -1,367 +0,0 @@--- | Names specific to western music tradition-module Temporal.Music.Notation.Local.Western(- - -- * Pitch- - -- ** Scales- eqt, pyth, - hind, hindFs, hindGb,- major, minor,- - -- ** Tone constants- -- | 'c' corresponds to 0, 'db' and 'cs' to 1 etc.- c, d, e, f, g, a, b,- cs, ds, es, fs, gs, as, bs,- cb, db, eb, fb, gb, ab, bb,- - -- ** Intervals- - -- *** pure intervals as factors- pureOctave, pureFifth, pureForth, pureMajorThird,- pureMinorThird, pureWholeTone, pureHalfTone, pureMajorSixth,- pureMinorSixth, pureMajorSeventh, pureMinorSeventh, -- -- *** in steps for 12 tone scale- - majorSeventh, minorSeventh, majorSixth, minorSixth,- fifth, tritone, forth, majorThird, - minorThird, wholeTone, halfTone, - - -- * Volume- -- ** Levels- -- | Dynamics values form 8-level equally spaced grid. - -- They are from quietest- -- to loudest: piano pianissimo (ppp), pianissimo (pp), piano (p),- -- mezzo piano (mp), mezzo forte (mf), forte (f), fortissimo (ff),- -- forte fortissimo (fff).- Dynamics,- pianoPianissimo, pianissimo, piano, mezzoPiano,- mezzoForte, forte, fortissimo, forteFortissimo,-- -- ** short-cuts- pppl, ppl, pl, mpl, mfl, fl, ffl, fffl,-- -- ** Envelops- dim, cresc, -- -- ** Volume level constants- - -- * Score - -- ** Forms - rondo, reprise, - - -- ** Tempo- -- | Tempo terms specify not a rigid value but tempo range. So all- -- terms are functions from relative power of term (it's value- -- of type Double from 0 to 1) to some tempo value. Zero means- -- lowest value from tempo range and one means highest value.- Tempo, - lento, largo, larghetto, grave, adagio, adagietto,- andante, andantino, moderato, allegretto,- allegro, vivace, presto, prestissimo,-- -- * Note- NoteW, DrumW,- Note(..), Drum, - absNote, absDrum,- - -- ** Rests - bnr, wnr, qnr, hnr, enr, snr, tnr, - dbnr, dwnr, dqnr, dhnr, denr, dsnr, dtnr,- - -- ** Notes- - bn, wn, hn, qn, en, sn, tn, - dbn, dwn, dhn, dqn, den, dsn, dtn,- - -- ** Drums- bd, wd, hd, qd, ed, sd, td, - dbd, dwd, dhd, dqd, ded, dsd, dtd-) where--import Temporal.Music.Notation--import Temporal.Music.Notation.Local.Scales(- eqt, pyth, hind, hindFs, hindGb,- major, minor)--import Temporal.Music.Notation.Note(Note(..), Drum,- absNote, absDrum,- bnr, wnr, qnr, hnr, enr, snr, tnr, - dbnr, dwnr, dqnr, dhnr, denr, dsnr, dtnr) --import qualified Temporal.Music.Notation.Note as N------------------------------------------------ tones--c, d, e, f, g, a, b, - cs, ds, es, fs, gs, as, bs,- cb, db, eb, fb, gb, ab, bb :: Tone N12--c = 0-cs = 1-d = 2-ds = 3-e = 4-f = 5-fs = 6-g = 7-gs = 8-a = 9-as = 10-b = 11--bs = c-es = f--cb = b-db = cs-eb = ds-fb = e-gb = fs-ab = gs-bb = as-------------------------------------------------------------- intervals--pureOctave, pureFifth, pureForth, pureMajorThird,- pureMinorThird, pureWholeTone, pureHalfTone, pureMajorSixth,- pureMinorSixth, pureMajorSeventh, pureMinorSeventh :: Fractional a => a--pureOctave = 2-pureFifth = 3/2-pureForth = 4/3-pureMajorThird = 5/4-pureMinorThird = 6/5-pureWholeTone = 9/8-pureHalfTone = 25/24-pureMajorSixth = 5/3-pureMinorSixth = 8/5-pureMajorSeventh = 48/25-pureMinorSeventh = 16/9---majorSeventh, minorSeventh, majorSixth, minorSixth,- fifth, tritone, forth, majorThird, - minorThird, wholeTone, halfTone :: Step---majorSeventh = 11-minorSeventh = 10-majorSixth = 9-minorSixth = 8-fifth = 7-tritone = 6-forth = 5-majorThird = 4-minorThird = 3-wholeTone = 2-halfTone = 1--------------------------------------------- volume levels---type Dynamics = Int--pianoPianissimo :: Dynamics-pianoPianissimo = 0--pianissimo :: Dynamics-pianissimo = 1--piano :: Dynamics-piano = 2--mezzoPiano :: Dynamics-mezzoPiano = 3--mezzoForte :: Dynamics-mezzoForte = 4--forte :: Dynamics-forte = 5--fortissimo :: Dynamics-fortissimo = 6--forteFortissimo :: Dynamics-forteFortissimo = 7----- short-cuts--pppl, ppl, pl, mpl, mfl, fl, ffl, fffl :: LevelFunctor a => a -> a--pppl = setLevel pianoPianissimo-ppl = setLevel pianissimo-pl = setLevel piano-mpl = setLevel mezzoPiano-mfl = setLevel mezzoForte-fl = setLevel forte-ffl = setLevel fortissimo-fffl = setLevel forteFortissimo---- | diminuendo-dim :: LevelFunctor a => Accent -> Score a -> Score a-dim v = dynamic ((-v) *)---- | crescendo-cresc :: LevelFunctor a => Accent -> Score a -> Score a-cresc v = dynamic (v * )-------------------------------------------- forms---- | rondo form------ >rondo a b c = line [a, b, a, c, a]-rondo :: Score a -> Score a -> Score a -> Score a-rondo a b c = line [a, b, a, c, a]---- | reprise form------ >reprise a b1 b2 = line [a, b1, a, b2]-reprise :: Score a -> Score a -> Score a -> Score a-reprise a b c = line [a, b, a, c]-------------------------------------------- tempo--type Tempo = Double--largoRange, larghettoRange, - adagioRange, adagiettoRange, - andanteRange, andantinoRange,- moderatoRange, allegroRange,- allegrettoRange, vivaceRange,- prestoRange, prestissimoRange :: (Double, Double)--largoRange = ( 40, 60) -larghettoRange = ( 60, 66) -adagioRange = ( 66, 76)-adagiettoRange = ( 70, 80)-andanteRange = ( 76, 80)-andantinoRange = ( 80,100)-moderatoRange = (101,110)-allegrettoRange = (115,125)-allegroRange = (120,139)-vivaceRange = (135,160)-prestoRange = (168,200)-prestissimoRange = (200,230)--getTempo :: (Tempo, Tempo) -> Double -> Tempo-getTempo (a, b) x = a + (b - a) * x---- | very slow (40-60 bpm), like largo-lento :: Double -> Tempo-lento = largo---- | very slow (40-60 bpm)-largo :: Double -> Tempo-largo = getTempo largoRange---- | rather broadly (60-66 bpm)-larghetto :: Double -> Tempo-larghetto = getTempo larghettoRange---- | slow and sloemn (60 - 66 bpm)-grave :: Double -> Tempo-grave = larghetto---- | slow and stately (literally "at ease") (66-76 bpm)-adagio :: Double -> Tempo-adagio = getTempo adagioRange---- | rather slow (70-80 bpm)-adagietto :: Double -> Tempo -adagietto = getTempo adagiettoRange---- | at awalking pace (76-80 bpm)-andante :: Double -> Tempo -andante = getTempo andanteRange---- | slightly faster then andante (80-100 bpm)-andantino :: Double -> Tempo -andantino = getTempo andantinoRange---- | moderately (101-110 bpm)-moderato :: Double -> Tempo-moderato = getTempo moderatoRange---- | moderately fast (115-125 bpm)-allegretto :: Double -> Tempo-allegretto = getTempo allegrettoRange---- | fast, at 'march tempo' (120-139 bpm)-allegro :: Double -> Tempo-allegro = getTempo allegroRange---- | lively and fast (135-160 bpm)-vivace :: Double -> Tempo-vivace = getTempo vivaceRange---- | very fast (168-200 bpm)-presto :: Double -> Tempo-presto = getTempo prestoRange---- | extremely fast (200 - 230 bpm)-prestissimo :: Double -> Tempo-prestissimo = getTempo prestissimoRange---- Note---- | Western 'Note' (eight volume levels and twelve tones)-type NoteW = Note N8 N12---- | Western 'Drum' note (eight volume levels)-type DrumW = Drum N8---- shortcuts---- notes-bn, wn, hn, qn, en, sn, tn, - dbn, dwn, dhn, dqn, den, dsn, dtn :: - Tone N12 -> Score NoteW--bn = N.bn-wn = N.wn-hn = N.hn-qn = N.qn-en = N.en-sn = N.sn-tn = N.tn-dbn = N.dbn-dwn = N.dwn-dhn = N.dhn-dqn = N.dqn-den = N.den-dsn = N.dsn-dtn = N.dtn---- drums--bd, wd, hd, qd, ed, sd, td, - dbd, dwd, dhd, dqd, ded, dsd, dtd :: - Accent -> Score DrumW--bd = N.bd-wd = N.wd-hd = N.hd-qd = N.qd-ed = N.ed-sd = N.sd-td = N.td-dbd = N.dbd-dwd = N.dwd-dhd = N.dhd-dqd = N.dqd-ded = N.ded-dsd = N.dsd-dtd = N.dtd---
+ src/Temporal/Music/Western.hs view
@@ -0,0 +1,251 @@+-- | Names specific to western music tradition+module Temporal.Music.Western(+ -- * Volume+ -- ** Levels+ -- | Dynamics values form 8-level equally spaced grid. + -- They are from quietest+ -- to loudest: piano pianissimo (ppp), pianissimo (pp), piano (p),+ -- mezzo piano (mp), mezzo forte (mf), forte (f), fortissimo (ff),+ -- forte fortissimo (fff).+ Dynamics(..),++ -- ** short-cuts+ ppp', pp', p', mp', mf', f', ff', fff',++ -- ** Envelops+ dim, cresc, ++ -- ** Volume level constants+ + -- * Score + -- ** Forms + rondo, reprise, + + -- ** Tempo+ -- | Tempo terms specify not a rigid value but tempo range. So all+ -- terms are functions from relative power of term (it's value+ -- of type Double from 0 to 1) to some tempo value. Zero means+ -- lowest value from tempo range and one means highest value.+ Tempo, + lento, largo, larghetto, grave, adagio, adagietto,+ andante, andantino, moderato, allegretto,+ allegro, vivace, presto, prestissimo,++ -- * Note+ NoteW, DrumW,+ Note(..), Drum, + absNote, absDrum,+ + -- ** Rests + bnr, wnr, qnr, hnr, enr, snr, tnr, + dbnr, dwnr, dqnr, dhnr, denr, dsnr, dtnr,+ + -- ** Notes+ + bn, wn, hn, qn, en, sn, tn, + dbn, dwn, dhn, dqn, den, dsn, dtn,+ + -- ** Drums+ bd, wd, hd, qd, ed, sd, td, + dbd, dwd, dhd, dqd, ded, dsd, dtd+) where++import Temporal.Music.Notation++++import Temporal.Music.Notation.Note(Note(..), Drum,+ absNote, absDrum,+ bnr, wnr, qnr, hnr, enr, snr, tnr, + dbnr, dwnr, dqnr, dhnr, denr, dsnr, dtnr) ++import qualified Temporal.Music.Notation.Note as N++++---------------------------------------+-- volume levels++-- | Dynamics levels. Default defined volume +-- defined in 'Vol' class is (1e-5, 1).+data Dynamics = PPP | PP | P | MP | MF | F | FF | FFF+ deriving (Show, Eq, Enum, Bounded)++instance Seg Dynamics++instance Vol Dynamics where+ volume = Volume (1e-5, 1)++-- short-cuts++ppp', pp', p', mp', mf', f', ff', fff' :: LevelFunctor a => a -> a++ppp' = setLevel PPP+pp' = setLevel PP +p' = setLevel P+mp' = setLevel MP+mf' = setLevel MF+f' = setLevel F+ff' = setLevel FF+fff' = setLevel FFF++-- | diminuendo+dim :: LevelFunctor a => Accent -> Score a -> Score a+dim v = dynamics ((-v) *)++-- | crescendo+cresc :: LevelFunctor a => Accent -> Score a -> Score a+cresc v = dynamics (v * )++---------------------------------------+-- forms++-- | rondo form+--+-- >rondo a b c = line [a, b, a, c, a]+rondo :: Score a -> Score a -> Score a -> Score a+rondo a b c = line [a, b, a, c, a]++-- | reprise form+--+-- >reprise a b1 b2 = line [a, b1, a, b2]+reprise :: Score a -> Score a -> Score a -> Score a+reprise a b c = line [a, b, a, c]++---------------------------------------+-- tempo++type Tempo = Double++largoRange, larghettoRange, + adagioRange, adagiettoRange, + andanteRange, andantinoRange,+ moderatoRange, allegroRange,+ allegrettoRange, vivaceRange,+ prestoRange, prestissimoRange :: (Double, Double)++largoRange = ( 40, 60) +larghettoRange = ( 60, 66) +adagioRange = ( 66, 76)+adagiettoRange = ( 70, 80)+andanteRange = ( 76, 80)+andantinoRange = ( 80,100)+moderatoRange = (101,110)+allegrettoRange = (115,125)+allegroRange = (120,139)+vivaceRange = (135,160)+prestoRange = (168,200)+prestissimoRange = (200,230)++getTempo :: (Tempo, Tempo) -> Double -> Tempo+getTempo (a, b) x = a + (b - a) * x++-- | very slow (40-60 bpm), like largo+lento :: Double -> Tempo+lento = largo++-- | very slow (40-60 bpm)+largo :: Double -> Tempo+largo = getTempo largoRange++-- | rather broadly (60-66 bpm)+larghetto :: Double -> Tempo+larghetto = getTempo larghettoRange++-- | slow and sloemn (60 - 66 bpm)+grave :: Double -> Tempo+grave = larghetto++-- | slow and stately (literally "at ease") (66-76 bpm)+adagio :: Double -> Tempo+adagio = getTempo adagioRange++-- | rather slow (70-80 bpm)+adagietto :: Double -> Tempo +adagietto = getTempo adagiettoRange++-- | at awalking pace (76-80 bpm)+andante :: Double -> Tempo +andante = getTempo andanteRange++-- | slightly faster then andante (80-100 bpm)+andantino :: Double -> Tempo +andantino = getTempo andantinoRange++-- | moderately (101-110 bpm)+moderato :: Double -> Tempo+moderato = getTempo moderatoRange++-- | moderately fast (115-125 bpm)+allegretto :: Double -> Tempo+allegretto = getTempo allegrettoRange++-- | fast, at 'march tempo' (120-139 bpm)+allegro :: Double -> Tempo+allegro = getTempo allegroRange++-- | lively and fast (135-160 bpm)+vivace :: Double -> Tempo+vivace = getTempo vivaceRange++-- | very fast (168-200 bpm)+presto :: Double -> Tempo+presto = getTempo prestoRange++-- | extremely fast (200 - 230 bpm)+prestissimo :: Double -> Tempo+prestissimo = getTempo prestissimoRange++-- Note++-- | Western 'Note' (eight volume levels and twelve tones)+type NoteW p a = Note Dynamics p a++-- | Western 'Drum' note (eight volume levels)+type DrumW a = Drum Dynamics a++-- shortcuts++-- notes+bn, wn, hn, qn, en, sn, tn, + dbn, dwn, dhn, dqn, den, dsn, dtn :: + Pch p => Tone p -> Score (NoteW p a)++bn = N.bn+wn = N.wn+hn = N.hn+qn = N.qn+en = N.en+sn = N.sn+tn = N.tn+dbn = N.dbn+dwn = N.dwn+dhn = N.dhn+dqn = N.dqn+den = N.den+dsn = N.dsn+dtn = N.dtn++-- drums++bd, wd, hd, qd, ed, sd, td, + dbd, dwd, dhd, dqd, ded, dsd, dtd :: + Accent -> Score (DrumW a)++bd = N.bd+wd = N.wd+hd = N.hd+qd = N.qd+ed = N.ed+sd = N.sd+td = N.td+dbd = N.dbd+dwd = N.dwd+dhd = N.dhd+dqd = N.dqd+ded = N.ded+dsd = N.dsd+dtd = N.dtd+++
+ src/Temporal/Music/Western/BohlenPierce.hs view
@@ -0,0 +1,64 @@+-- | Bohlen-Pierce tones+module Temporal.Music.Western.BohlenPierce(+ -- * Tones+ StepBP(..),++ c, cs, cb, d, ds, db, e, es, eb,+ f, fs, fb, g, gs, gb, h, hs, hb, + j, js, jb, a, as, ab, b, bs, bb,++ -- * Scales+ eqBP, justBP+) +where++import Temporal.Music.Notation.Seg(Seg)+import Temporal.Music.Notation.Pitch+import Temporal.Music.Notation.Scales(eqBP, justBP)++-- | Tones for Bohlen-Pierce 13-tone scale. +-- Default scale defined in 'Pch' class is equal +-- temperament Bohlen-Pierce scale+data StepBP = + C | Cs | D | E | F | Fs | G + | H | Hs | J | A | As | B+ deriving (Enum, Bounded, Eq, Show)++instance Seg StepBP++instance Pch StepBP where+ pitch = Pitch (eqBP 0 c1)++c, cs, cb, d, ds, db, e, es, eb,+ f, fs, fb, g, gs, gb, h, hs, hb, + j, js, jb, a, as, ab, b, bs, bb :: Tone StepBP++c = tone C +cs = tone Cs +d = tone D +e = tone E+f = tone F+fs = tone Fs+g = tone G+h = tone H+hs = tone Hs+j = tone J+a = tone A+as = tone As+b = tone B++cb = b+ds = e+db = cs+es = f+eb = d+fb = e+gs = h+gb = fs+hb = g+js = a+jb = hs+ab = j++bb = as+bs = c
+ src/Temporal/Music/Western/TwelveTone.hs view
@@ -0,0 +1,207 @@+module Temporal.Music.Western.TwelveTone(+ -- * 12-tones+ -- | Chromatic scales+ + -- ** Tones+ Chromatic(..),+ c, d, e, f, g, a, b, + cs, ds, es, fs, gs, as, bs,+ cf, df, ef, ff, gf, af, bf,++ -- ** Scales+ eqt, pyth, + hind, hindFs, hindGb,+ {-+ -- * 7-tones+ + -- | Diatonic scales++ -- ** Tones+ Diatonic(..),+ d0, d1, d2, d3, d4, d5, d6,++ -- ** Scales++ -- | Here scales are scale functions. The take chromatic scales+ -- and produce 7-tone subscales.+ major, minor,+ ionian, dorian, phrygian, lydian, + mixolydian, aeolian, locrian,++ -- * 5-tones + + -- | Pentatonic scales+ + -- ** Tones+ Pentatonic(..),+ p0, p1, p2, p3, p4, + -}+ + -- ** Scales++ -- | Here scales are scale functions. The take chromatic scales+ -- and produce 5-tone subscales.+ minor5, major5, bluesMinor5, bluesMajor5, egyptian5,++ -- * Intervals+ + -- ** pure intervals as factors+ pureOctave, pureFifth, pureForth, pureMajorThird,+ pureMinorThird, pureWholeTone, pureHalfTone, pureMajorSixth,+ pureMinorSixth, pureMajorSeventh, pureMinorSeventh, ++ -- ** in steps for 12 tone scale+ + majorSeventh, minorSeventh, majorSixth, minorSixth,+ fifth, tritone, forth, majorThird, + minorThird, wholeTone, halfTone ++ )+where++import Temporal.Music.Notation.Seg(Seg)+--import Temporal.Music.Notation.Seg(Seg, IntSeg(..), N5, N7)+import Temporal.Music.Notation.Pitch++import Temporal.Music.Notation.Scales(+ eqt, pyth, hind, hindFs, hindGb,+ minor5, major5, bluesMinor5, bluesMajor5, egyptian5,+ major, minor, ionian, dorian, phrygian, lydian, + mixolydian, aeolian, locrian)++-- | 12-tone scale. Default scale defined in 'Pch' class +-- is equal temperament.+data Chromatic = + C | Cs | D | Ds | E | F + | Fs | G | Gs | A | As | B+ deriving (Enum, Bounded, Eq, Show)++instance Seg Chromatic++instance Pch Chromatic where+ pitch = Pitch (eqt 0 c1)++-- tones++c, d, e, f, g, a, b, + cs, ds, es, fs, gs, as, bs,+ cf, df, ef, ff, gf, af, bf :: Tone Chromatic++c = tone C+cs = tone Cs+d = tone D+ds = tone Ds+e = tone E+f = tone F+fs = tone Fs+g = tone G+gs = tone Gs+a = tone A+as = tone As+b = tone B++bs = c+es = f++cf = b+df = cs+ef = ds+ff = e+gf = fs+af = gs+bf = as++{-+-- | 5-tone scale. Default scale defined in 'Pch' class +-- is minor pentatonic on equal temerament.+newtype Pentatonic = Pentatonic { + runPentatonic :: IntSeg N5 + } deriving (Show, Eq, Bounded)++instance Enum Pentatonic where+ toEnum = Pentatonic . toEnum+ fromEnum = fromEnum . runPentatonic++instance Seg Pentatonic++instance Pch Pentatonic where+ pitch = Pitch (minor5 $ eqt 0 c1)+ ++p0, p1, p2, p3, p4 :: Tone Pentatonic++p0 = pn 0+p1 = pn 1+p2 = pn 2+p3 = pn 3+p4 = pn 4++pn :: Int -> Tone Pentatonic+pn = tone . Pentatonic . IntSeg++ +-- | 7-tone scale. Default scale defined in 'Pch' class+-- is C major on equal temperament.+newtype Diatonic = Diatonic { + runDiatonic :: IntSeg N7 + } deriving (Show, Eq, Bounded)++instance Enum Diatonic where+ toEnum = Diatonic . toEnum+ fromEnum = fromEnum . runDiatonic++instance Seg Diatonic++instance Pch Diatonic where+ pitch = Pitch (major $ eqt 0 c1)++d0, d1, d2, d3, d4, d5, d6 :: Tone Diatonic++d0 = dn 0+d1 = dn 1+d2 = dn 2+d3 = dn 3+d4 = dn 4+d5 = dn 5+d6 = dn 6++dn :: Int -> Tone Diatonic+dn = tone . Diatonic . IntSeg+-}+---------------------------------------------------------+-- intervals++pureOctave, pureFifth, pureForth, pureMajorThird,+ pureMinorThird, pureWholeTone, pureHalfTone, pureMajorSixth,+ pureMinorSixth, pureMajorSeventh, pureMinorSeventh :: Fractional a => a++pureOctave = 2+pureFifth = 3/2+pureForth = 4/3+pureMajorThird = 5/4+pureMinorThird = 6/5+pureWholeTone = 9/8+pureHalfTone = 25/24+pureMajorSixth = 5/3+pureMinorSixth = 8/5+pureMajorSeventh = 48/25+pureMinorSeventh = 16/9+++majorSeventh, minorSeventh, majorSixth, minorSixth,+ fifth, tritone, forth, majorThird, + minorThird, wholeTone, halfTone :: Step+++majorSeventh = 11+minorSeventh = 10+majorSixth = 9+minorSixth = 8+fifth = 7+tritone = 6+forth = 5+majorThird = 4+minorThird = 3+wholeTone = 2+halfTone = 1+
temporal-music-notation-western.cabal view
@@ -1,5 +1,5 @@ Name: temporal-music-notation-western-Version: 0.1+Version: 0.1.2 Cabal-Version: >= 1.2 License: BSD3 License-file: LICENSE@@ -17,7 +17,9 @@ Library Build-Depends: base >= 4, base < 5,- temporal-music-notation+ temporal-music-notation >= 0.1.2 Hs-Source-Dirs: src/ Exposed-Modules:- Temporal.Music.Notation.Local.Western+ Temporal.Music.Western+ Temporal.Music.Western.TwelveTone+ Temporal.Music.Western.BohlenPierce