temporal-music-notation 0.2.1 → 0.2.2
raw patch · 3 files changed
+36/−45 lines, 3 filesdep ~temporal-media
Dependency ranges changed: temporal-media
Files
- src/Temporal/Music/Note.hs +13/−29
- src/Temporal/Music/Score.hs +13/−13
- temporal-music-notation.cabal +10/−3
src/Temporal/Music/Note.hs view
@@ -4,8 +4,8 @@ -- It defines the notion of note. module Temporal.Music.Note( -- * Types- Note(..), note, mapNoteParam,- Drum(..), bam, mapDrumParam,+ Note(..), note,+ Drum(..), bam, -- * Shortcuts -- ** Note shortcuts -- | Function n[i] is equivalent to call @note i@.@@ -30,7 +30,7 @@ data Note a = Note { noteVolume :: Volume, notePitch :: Pitch,- noteParam :: Maybe a+ noteParam :: a } deriving (Show, Eq) @@ -38,7 +38,7 @@ fmap f n = Note { notePitch = notePitch n , noteVolume = noteVolume n- , noteParam = fmap f $ noteParam n+ , noteParam = f $ noteParam n } instance PitchLike (Note a) where@@ -49,62 +49,46 @@ setVolume v a = a{ noteVolume = v } getVolume = noteVolume -instance Default (Note a) where+instance Default a => Default (Note a) where def = Note def def def -- | Constructs default 'Note' with given step value.-note :: Step -> Score (Note a)+note :: Default a => Step -> Score (Note a) note a = temp $ Note def def{ pitchStep = a } def --- | Updates note's timbral paramters.-mapNoteParam :: (Maybe a -> Maybe b) -> Note a -> Note b-mapNoteParam f n = Note- { notePitch = notePitch n- , noteVolume = noteVolume n- , noteParam = f $ noteParam n- }- -- drum -- | 'Drum' has only pitch and some timbral paramters. data Drum a = Drum { drumVolume :: Volume,- drumParam :: Maybe a+ drumParam :: a } deriving (Show, Eq) instance Functor Drum where fmap f n = Drum { drumVolume = drumVolume n- , drumParam = fmap f $ drumParam n+ , drumParam = f $ drumParam n } instance VolumeLike (Drum a) where setVolume v a = a{ drumVolume = v } getVolume = drumVolume -instance Default (Drum a) where+instance Default a => Default (Drum a) where def = Drum def def -- | Constructs drum note with given accent. Level is set to the default -- value.-bam :: Accent -> Score (Drum a)+bam :: Default a => Accent -> Score (Drum a) bam a = accent a $ temp def --- | Updates drum-note's timbral paramters.-mapDrumParam :: (Maybe a -> Maybe b) -> Drum a -> Drum b-mapDrumParam f n = Drum- { drumVolume = drumVolume n- , drumParam = f $ drumParam n- }-- -------------------------------------------------------------- -- notes -- n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22, n23- :: Score (Note a)+ :: Default a => Score (Note a) n0 = note 0; n1 = note 1; n2 = note 2; n3 = note 3; n4 = note 4; n5 = note 5; n6 = note 6; n7 = note 7;@@ -118,7 +102,7 @@ -- drums -- -bd, wd, hd, qd, ed, sd, td :: Accent -> Score (Drum a)+bd, wd, hd, qd, ed, sd, td :: Default a => Accent -> Score (Drum a) bd = bn . bam wd = bam@@ -128,7 +112,7 @@ sd = sn . bam td = tn . bam -dbd, dwd, dhd, dqd, ded, dsd, dtd :: Accent -> Score (Drum a) +dbd, dwd, dhd, dqd, ded, dsd, dtd :: Default a => Accent -> Score (Drum a) dbd = dot . bd dwd = dot . wd
src/Temporal/Music/Score.hs view
@@ -6,13 +6,13 @@ temp, rest, stretch, delay, reflect, (+|), (*|), (=:=), (+:+), (=:/), line, chord, chordT, loop, sustain, sustainT, -- * Filtering- clip, takeS, dropS, filterEvents, + slice, takeS, dropS, filterEvents, -- * Mappings mapEvents, tmap, tmapRel, -- * Rendering dur, render, alignByZero, sortEvents, -- * Miscellaneous- linseg, linsegRel,+ linfun, linfunRel, -- ** Monoid synonyms -- -- | This package heavily relies on 'Monoid's, so there are shorcuts@@ -63,7 +63,7 @@ where import Temporal.Media(Event(..), within, eventEnd, nil, - linseg, linsegRel, alignByZero, sortEvents)+ linfun, linfunRel, alignByZero, sortEvents) import qualified Temporal.Media as M import Temporal.Music.Pitch import Temporal.Music.Volume@@ -162,19 +162,19 @@ -------------------------------------------------- -- filtering --- | 'clip' cuts piece of value within given time interval.--- for @('clip' t0 t1 m)@, if @t1 < t0@ result is reversed.+-- | 'slice' cuts piece of value within given time interval.+-- for @('slice' t0 t1 m)@, if @t1 < t0@ result is reversed. -- If @t0@ is negative or @t1@ goes beyond @'dur' m@ blocks of -- nothing inserted so that duration of result equals to -- @'abs' (t0 - t1)@.-clip :: Dur -> Dur -> Score a -> Score a-clip = M.clip+slice :: Dur -> Dur -> Score a -> Score a+slice = M.slice --- | @('takeS' t)@ is equivalent to @('clip' 0 t)@.+-- | @('takeS' t)@ is equivalent to @('slice' 0 t)@. takeS :: Dur -> Score a -> Score a takeS = M.takeT --- | @('dropS' t m)@ is equivalent to @('clip' t (dur a) a)@.+-- | @('dropS' t m)@ is equivalent to @('slice' t (dur a) a)@. dropS :: Dur -> Score a -> Score a dropS = M.dropT @@ -269,13 +269,13 @@ envelope f = tmapRel $ \(Event s d c) -> accent' c (f s) where accent' v a = mapVolume (\v -> v{ volumeAccent = a }) v --- | 'envelopeSeg' lifts function 'linseg' to dynamics level+-- | 'envelopeSeg' lifts function 'lines' to dynamics level envelopeSeg :: (VolumeLike a) => [Double] -> Score a -> Score a-envelopeSeg xs = envelope $ (linseg xs)+envelopeSeg xs = envelope $ (linfun xs) --- | 'envelopeRel' lifts function 'linsegRel' to dynamics level+-- | 'envelopeRel' lifts function 'linesRel' to dynamics level envelopeRel :: (VolumeLike a) => [Accent] -> Score a -> Score a-envelopeRel xs a = envelope (linsegRel 1 xs) a+envelopeRel xs a = envelope (linfunRel 1 xs) a ---------------------------------------------------------
temporal-music-notation.cabal view
@@ -1,6 +1,6 @@ Name: temporal-music-notation-Version: 0.2.1-Cabal-Version: >= 1.2+Version: 0.2.2+Cabal-Version: >= 1.6 License-file: LICENSE License: BSD3 Author: Anton Kholomiov@@ -12,11 +12,18 @@ Tested-With: GHC==6.12.3 Build-Type: Simple +Homepage: https://github.com/anton-k/temporal-music-notation+Bug-Reports: https://github.com/anton-k/temporal-music-notation/issues++Source-repository head+ Type: git+ Location: https://github.com/anton-k/temporal-music-notation+ Library Build-Depends: base >= 4, base < 5, vector >= 0.7, data-default >= 0.3,- temporal-media >= 0.3.0+ temporal-media >= 0.3.1 Hs-Source-Dirs: src/ Exposed-Modules: Temporal.Music