csound-expression-typed 0.0.6.0 → 0.0.6.1
raw patch · 3 files changed
+28/−23 lines, 3 filesdep ~colourPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: colour
API changes (from Hackage documentation)
+ Csound.Typed.Control: mixSERef :: (Num a, Tuple a) => SERef a -> a -> SE ()
+ Csound.Typed.Control: modifySERef :: Tuple a => SERef a -> (a -> a) -> SE ()
- Csound.Typed.Control: midi :: Sigs a => (Msg -> SE a) -> a
+ Csound.Typed.Control: midi :: (Num a, Sigs a) => (Msg -> SE a) -> SE a
- Csound.Typed.Control: midin :: Sigs a => Channel -> (Msg -> SE a) -> a
+ Csound.Typed.Control: midin :: (Num a, Sigs a) => Channel -> (Msg -> SE a) -> SE a
- Csound.Typed.Control: pgmidi :: Sigs a => Maybe Int -> Channel -> (Msg -> SE a) -> a
+ Csound.Typed.Control: pgmidi :: (Num a, Sigs a) => Maybe Int -> Channel -> (Msg -> SE a) -> SE a
Files
- csound-expression-typed.cabal +2/−2
- src/Csound/Typed/Control/Midi.hs +15/−12
- src/Csound/Typed/Control/SERef.hs +11/−9
csound-expression-typed.cabal view
@@ -1,5 +1,5 @@ Name: csound-expression-typed-Version: 0.0.6.0+Version: 0.0.6.1 Cabal-Version: >= 1.6 License: BSD3 License-file: LICENSE@@ -24,7 +24,7 @@ Library Ghc-Options: -Wall Build-Depends:- base >= 4, base < 5, ghc-prim, containers, transformers >= 0.3, Boolean >= 0.1.0, colour >= 2.3, data-default, deepseq,+ base >= 4, base < 5, ghc-prim, containers, transformers >= 0.3, Boolean >= 0.1.0, colour >= 2.0, data-default, deepseq, wl-pprint, stable-maps >= 0.0.3.3, csound-expression-dynamic >= 0.1.0 Hs-Source-Dirs: src/ Exposed-Modules:
src/Csound/Typed/Control/Midi.hs view
@@ -9,32 +9,35 @@ import System.Mem.StableName import Control.Applicative+import Control.Monad import Control.Monad.IO.Class import Csound.Typed.Types import Csound.Typed.GlobalState import Csound.Typed.Control.Instr+import Csound.Typed.Control.SERef -- | Triggers a midi-instrument (aka Csound's massign) for all channels. -- It's useful to test a single instrument.-midi :: (Sigs a) => (Msg -> SE a) -> a-midi = midin 0+midi :: (Num a, Sigs a) => (Msg -> SE a) -> SE a+midi = fromProcMidi midi_ -- | Triggers a midi-instrument (aka Csound's massign) on the specified channel. -midin :: (Sigs a) => Channel -> (Msg -> SE a) -> a-midin n f = genMidi Massign n f+midin :: (Num a, Sigs a) => Channel -> (Msg -> SE a) -> SE a+midin n = fromProcMidi (midin_ n) -- | Triggers a midi-instrument (aka Csound's pgmassign) on the specified programm bank. -pgmidi :: (Sigs a) => Maybe Int -> Channel -> (Msg -> SE a) -> a-pgmidi mchn n f = genMidi (Pgmassign mchn) n f +pgmidi :: (Num a, Sigs a) => Maybe Int -> Channel -> (Msg -> SE a) -> SE a+pgmidi mchn n = fromProcMidi (pgmidi_ mchn n) -genMidi :: (Sigs a) => MidiType -> Channel -> (Msg -> SE a) -> a-genMidi midiType chn instr = toTuple $ do - key <- midiKey midiType chn instr- withCache InfiniteDur getMidiKey saveMidiKey key $- saveMidiInstr midiType chn (constArity $ instr Msg) (midiExp instr)+fromProcMidi :: (Num a, Sigs a) => ((Msg -> SE ()) -> SE ()) -> (Msg -> SE a) -> SE a+fromProcMidi procMidi f = do+ ref <- newGlobalSERef 0+ procMidi (mixSERef ref <=< f)+ res <- readSERef ref+ writeSERef ref 0+ return res -------------------------------------------------------------------- -- | Triggers a midi-procedure (aka Csound's massign) for all channels. midi_ :: (Msg -> SE ()) -> SE ()
src/Csound/Typed/Control/SERef.hs view
@@ -32,10 +32,18 @@ -- A reference can contain a tuple of variables. newSERef :: Tuple a => a -> SE (SERef a) newSERef t = fmap SERef $ newLocalVars (tupleRates t) (fromTuple t) - {-let wr a = fromDep_ $ (zipWithM_ writeVar vars) =<< lift (fromTuple a))- re = fmap toTuple $ fromDep $ mapM readVar vars- return (SERef wr re)-}+ +-- | Adds the given signal to the value that is contained in the+-- reference.+mixSERef :: (Num a, Tuple a) => SERef a -> a -> SE ()+mixSERef ref asig = modifySERef ref (+ asig) +-- | Modifies the SERef value with given function.+modifySERef :: Tuple a => SERef a -> (a -> a) -> SE ()+modifySERef ref f = do+ v <- readSERef ref + writeSERef ref (f v)+ -- | An alias for the function @newSERef@. It returns not the reference -- to mutable value but a pair of reader and writer functions. sensorsSE :: Tuple a => a -> SE (SE a, a -> SE ())@@ -47,12 +55,6 @@ -- A reference can contain a tuple of variables. newGlobalSERef :: Tuple a => a -> SE (SERef a) newGlobalSERef t = fmap SERef $ newGlobalVars (tupleRates t) (fromTuple t) -{-- vars <- newGlobalVars (tupleRates t) (fromTuple t)- let wr a = fromDep_ $ (zipWithM_ writeVar vars) =<< lift (fromTuple a)- re = fmap toTuple $ fromDep $ mapM readVar vars- return (SERef wr re)- -} -- | An alias for the function @newSERef@. It returns not the reference -- to mutable value but a pair of reader and writer functions.