csound-sampler 0.0.6.2 → 0.0.6.3
raw patch · 3 files changed
+46/−36 lines, 3 filesdep ~csound-expressionPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: csound-expression
API changes (from Hackage documentation)
- Csound.Sam: instance Compose Sam
- Csound.Sam: instance Delay Sam
- Csound.Sam: instance Harmony Sam
- Csound.Sam: instance Limit Sam
- Csound.Sam: instance Loop Sam
- Csound.Sam: instance Melody Sam
- Csound.Sam: instance Rest Sam
- Csound.Sam: instance Stretch Sam
- Csound.Sam: instance ToSam (SE Sig)
- Csound.Sam: instance ToSam (SE Sig2)
- Csound.Sam: instance ToSam Sig
- Csound.Sam: instance ToSam Sig2
- Csound.Sam.Core: instance Applicative S
- Csound.Sam.Core: instance Applicative Sample
- Csound.Sam.Core: instance Fractional a => Fractional (Sample a)
- Csound.Sam.Core: instance Functor S
- Csound.Sam.Core: instance Functor Sample
- Csound.Sam.Core: instance Num a => Num (Sample a)
- Csound.Sam.Core: instance RenderCsd Sam
- Csound.Sam.Core: instance SigSpace a => SigSpace (Sample a)
- Csound.Sam.Core: samDur :: S a -> Dur
- Csound.Sam.Core: samSig :: S a -> a
- Csound.Sam.Core: unSam :: Sample a -> ReaderT Bpm SE (S a)
+ Csound.Sam: instance Csound.Sam.ToSam (Csound.Typed.GlobalState.SE.SE Csound.Typed.Types.Prim.Sig)
+ Csound.Sam: instance Csound.Sam.ToSam (Csound.Typed.GlobalState.SE.SE Csound.Typed.Types.Tuple.Sig2)
+ Csound.Sam: instance Csound.Sam.ToSam Csound.Typed.Types.Prim.Sig
+ Csound.Sam: instance Csound.Sam.ToSam Csound.Typed.Types.Tuple.Sig2
+ Csound.Sam: instance Temporal.Class.Compose Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Delay Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Harmony Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Limit Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Loop Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Melody Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Rest Csound.Sam.Core.Sam
+ Csound.Sam: instance Temporal.Class.Stretch Csound.Sam.Core.Sam
+ Csound.Sam.Core: [samDur] :: S a -> Dur
+ Csound.Sam.Core: [samSig] :: S a -> a
+ Csound.Sam.Core: [unSam] :: Sample a -> ReaderT Bpm SE (S a)
+ Csound.Sam.Core: instance Csound.IO.RenderCsd Csound.Sam.Core.Sam
+ Csound.Sam.Core: instance Csound.SigSpace.SigSpace a => Csound.SigSpace.SigSpace (Csound.Sam.Core.Sample a)
+ Csound.Sam.Core: instance GHC.Base.Applicative Csound.Sam.Core.S
+ Csound.Sam.Core: instance GHC.Base.Applicative Csound.Sam.Core.Sample
+ Csound.Sam.Core: instance GHC.Base.Functor Csound.Sam.Core.S
+ Csound.Sam.Core: instance GHC.Base.Functor Csound.Sam.Core.Sample
+ Csound.Sam.Core: instance GHC.Num.Num a => GHC.Num.Num (Csound.Sam.Core.Sample a)
+ Csound.Sam.Core: instance GHC.Real.Fractional a => GHC.Real.Fractional (Csound.Sam.Core.Sample a)
- Csound.Sam.Trig: samCharCycle :: Char -> String -> [Sam] -> Sam
+ Csound.Sam.Trig: samCharCycle :: Maybe Sam -> Char -> String -> [Sam] -> Sam
- Csound.Sam.Trig: samCharGroup :: [(Char, Sam)] -> String -> Sam
+ Csound.Sam.Trig: samCharGroup :: Maybe Sam -> [(Char, Sam)] -> String -> Sam
- Csound.Sam.Trig: samCharPush :: Char -> Sam -> Sam
+ Csound.Sam.Trig: samCharPush :: Maybe Sam -> Char -> Sam -> Sam
- Csound.Sam.Trig: samCharToggle :: Char -> Sam -> Sam
+ Csound.Sam.Trig: samCharToggle :: Maybe Sam -> Char -> Sam -> Sam
- Csound.Sam.Trig: samCharTrig :: String -> String -> Sam -> Sam
+ Csound.Sam.Trig: samCharTrig :: Maybe Sam -> String -> String -> Sam -> Sam
Files
- csound-sampler.cabal +3/−3
- src/Csound/Sam/Trig.hs +20/−10
- src/Csound/Sam/Ui.hs +23/−23
csound-sampler.cabal view
@@ -1,10 +1,10 @@ name: csound-sampler-version: 0.0.6.2+version: 0.0.6.3 license: BSD3 license-file: LICENSE author: Anton Kholomiov maintainer: <anton.kholomiov@gmail.com>-Tested-With: GHC==7.6+Tested-With: GHC==7.10 stability: Experimental category: Music build-type: Simple@@ -25,7 +25,7 @@ library Ghc-Options: -Wall Hs-Source-Dirs: src/- build-depends: base >= 4, base < 5, transformers >= 0.3, csound-expression >= 4.8+ build-depends: base >= 4, base < 5, transformers >= 0.3, csound-expression >= 4.8.3 exposed-modules: Csound.Sam Csound.Sam.Core
src/Csound/Sam/Trig.hs view
@@ -21,16 +21,22 @@ -- | Triggers the sample with any char from the first string -- and stops the sample with any char from the second string.-samCharTrig :: String -> String -> Sam -> Sam-samCharTrig starts stops = fmap (charTrig starts stops) +samCharTrig :: Maybe Sam -> String -> String -> Sam -> Sam+samCharTrig initVal starts stops x = case initVal of+ Nothing -> fmap (charTrig Nothing starts stops) x+ Just v0 -> liftA2 (\v sigs -> charTrig (Just v) starts stops sigs) v0 x -- | Plays a sample while the key is pressed.-samCharPush :: Char -> Sam -> Sam-samCharPush ch = fmap (charPush ch)+samCharPush :: Maybe Sam -> Char -> Sam -> Sam+samCharPush initVal ch x = case initVal of+ Nothing -> fmap (charPush Nothing ch) x+ Just v0 -> liftA2 (\v sigs -> charPush (Just v) ch sigs) v0 x -- | Toggles the sample when the key is pressed.-samCharToggle :: Char -> Sam -> Sam-samCharToggle ch = fmap (charToggle ch)+samCharToggle :: Maybe Sam -> Char -> Sam -> Sam+samCharToggle initVal ch x = case initVal of+ Nothing -> fmap (charToggle Nothing ch) x+ Just v0 -> liftA2 (\v sigs -> charToggle (Just v) ch sigs) v0 x -- | Char trigger with fixed note limiting by length in second. -- It's useful optimization. It's good to use for drum notes and short sounds.@@ -39,14 +45,18 @@ -- | Plays one of the sample from the list when corresponding char is pressed. -- The last string is for stopping the samples.-samCharGroup :: [(Char, Sam)] -> String -> Sam-samCharGroup as stop = fmap (\xs -> charGroup (zip starts xs) stop) $ sequenceA sams+samCharGroup :: Maybe Sam -> [(Char, Sam)] -> String -> Sam+samCharGroup initVal as stop = case initVal of+ Nothing -> fmap (\xs -> charGroup Nothing (zip starts xs) stop) (sequenceA sams)+ Just v0 -> liftA2 (\v xs -> charGroup (Just v) (zip starts xs) stop) v0 (sequenceA sams) where (starts, sams) = unzip as -- | Plays samples in sequence when key is pressed. The last string is -- for stopping the sequence.-samCharCycle :: Char -> String -> [Sam] -> Sam-samCharCycle start stop as = fmap (charCycle start stop) (sequenceA as)+samCharCycle :: Maybe Sam -> Char -> String -> [Sam] -> Sam+samCharCycle initVal start stop as = case initVal of+ Nothing -> fmap (charCycle Nothing start stop) (sequenceA as)+ Just v0 -> liftA2 (\v xs -> charCycle (Just v) start stop xs) v0 (sequenceA as) ------------------------------------------------------
src/Csound/Sam/Ui.hs view
@@ -63,14 +63,14 @@ genFreeTog :: ([Gui] -> Gui) -> [(String, Sam)] -> Source Sam genFreeTog gcat as = source $ do (guis, writes, reads) <- fmap unzip3 $ mapM (flip setToggleSig False) names- curRef <- newGlobalSERef (0 :: Sig)- current <- readSERef curRef+ curRef <- newGlobalRef (0 :: Sig)+ current <- readRef curRef zipWithM_ (\w i -> w $ ifB (current ==* i) 1 0) writes ids zipWithM_ (\r i -> runEvt (snaps r) $ \x -> do when1 (sig x ==* 0 &&* current ==* i) $ do- writeSERef curRef 0+ writeRef curRef 0 when1 (sig x ==* 1) $ do- writeSERef curRef i + writeRef curRef i ) reads ids let res = groupToggles sum sams $ fmap (snaps . (\i -> ifB (current ==* i) 1 0)) ids@@ -86,11 +86,11 @@ genSimInits :: ([Gui] -> Gui) -> Int -> [(String, Sam, Bool)] -> Source Sam genSimInits gcat numBeats as = source $ do (guis, writes, reads) <- fmap unzip3 $ zipWithM setToggleSig names initVals- curRefs <- mapM (const $ newGlobalSERef (0 :: Sig)) ids- currents <- mapM readSERef curRefs+ curRefs <- mapM (const $ newGlobalRef (0 :: Sig)) ids+ currents <- mapM readRef curRefs zipWithM_ (\w val -> w val) writes currents- let mkReaders bpm = zipWithM_ (\r ref -> runEvt (syncBpm (bpm / int numBeats) $ snaps r) $ \x -> do- writeSERef ref (sig x)+ let mkReaders bpm = zipWithM_ (\r ref -> runEvt (syncBpm (sig $ bpm / int numBeats) $ snaps r) $ \x -> do+ writeRef ref (sig x) ) reads curRefs let res = bindBpm (\bpm x -> mkReaders bpm >> return x) $ groupToggles mean sams $ fmap snaps currents return (gcat guis, res)@@ -129,17 +129,17 @@ genTog :: ([Gui] -> Gui) -> Int -> [(String, Sam)] -> Source Sam genTog gcat numBeats as = fmap (\(g, x) -> (g, fst x)) $ genTogWithRef gcat numBeats as -genTogWithRef :: ([Gui] -> Gui) -> Int -> [(String, Sam)] -> Source (Sam, SERef Sig)+genTogWithRef :: ([Gui] -> Gui) -> Int -> [(String, Sam)] -> Source (Sam, Ref Sig) genTogWithRef gcat numBeats as = source $ do (guis, writes, reads) <- fmap unzip3 $ mapM (flip setToggleSig False) names- curRef <- newGlobalSERef (0 :: Sig)- current <- readSERef curRef+ curRef <- newGlobalRef (0 :: Sig)+ current <- readRef curRef zipWithM_ (\w i -> w $ ifB (current ==* i) 1 0) writes ids- let mkReaders bpm = zipWithM_ (\r i -> runEvt (syncBpm (bpm / int numBeats) $ snaps r) $ \x -> do+ let mkReaders bpm = zipWithM_ (\r i -> runEvt (syncBpm (sig $ bpm / int numBeats) $ snaps r) $ \x -> do when1 (sig x ==* 0 &&* current ==* i) $ do- writeSERef curRef 0 + writeRef curRef 0 when1 (sig x ==* 1) $ do- writeSERef curRef i + writeRef curRef i ) reads ids let res = bindBpm (\bpm x -> mkReaders bpm >> return x) $ groupToggles sum sams $ fmap (snaps . (\i -> ifB (current ==* i) 1 0)) ids@@ -184,22 +184,22 @@ ids = fmap (sig . int) [1 .. length (head rows)] n = length names -mkLiveRow :: Int -> (String, Gui) -> [Sam] -> Source (Sam, SERef Sig)+mkLiveRow :: Int -> (String, Gui) -> [Sam] -> Source (Sam, Ref Sig) mkLiveRow numBeats (name, gVol) xs = genTogWithRef (\xs -> ver $ xs ++ [gVol]) numBeats (zip (name : repeat "") xs) -mkLiveSceneRow :: Int -> Gui -> [Sig] -> [SERef Sig] -> SE (Gui, D -> SE ())+mkLiveSceneRow :: Int -> Gui -> [Sig] -> [Ref Sig] -> SE (Gui, D -> SE ()) mkLiveSceneRow numBeats gMaster ids refs = do (guis, writes, reads) <- fmap unzip3 $ mapM (flip setToggleSig False) names- curRef <- newGlobalSERef (0 :: Sig)- current <- readSERef curRef+ curRef <- newGlobalRef (0 :: Sig)+ current <- readRef curRef zipWithM_ (\w i -> w $ ifB (current ==* i) 1 0) writes ids- let mkReaders bpm = zipWithM_ (\r i -> runEvt (syncBpm (bpm / int numBeats) $ snaps r) $ \x -> do+ let mkReaders bpm = zipWithM_ (\r i -> runEvt (syncBpm (sig $ bpm / int numBeats) $ snaps r) $ \x -> do when1 (sig x ==* 0 &&* current ==* i) $ do- writeSERef curRef 0 - mapM_ (flip writeSERef 0) refs+ writeRef curRef 0 + mapM_ (flip writeRef 0) refs when1 (sig x ==* 1) $ do- writeSERef curRef i - mapM_ (flip writeSERef i) refs+ writeRef curRef i + mapM_ (flip writeRef i) refs ) reads ids return (ver $ guis ++ [gMaster], mkReaders)