csound-sampler 0.0.6.5 → 0.0.7.0
raw patch · 2 files changed
+32/−3 lines, 2 filesdep ~csound-expressionPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: csound-expression
API changes (from Hackage documentation)
+ Csound.Sam: rndPat :: Sig -> [D] -> Sam -> Sam
+ Csound.Sam: rndPat' :: Sig -> [D] -> [D] -> Sam -> Sam
Files
- csound-sampler.cabal +2/−2
- src/Csound/Sam.hs +30/−1
csound-sampler.cabal view
@@ -1,5 +1,5 @@ name: csound-sampler-version: 0.0.6.5+version: 0.0.7.0 license: BSD3 license-file: LICENSE author: Anton Kholomiov@@ -25,7 +25,7 @@ library Ghc-Options: -Wall Hs-Source-Dirs: src/- build-depends: base >= 4, base < 5, transformers >= 0.3, csound-expression >= 5.0.0+ build-depends: base >= 4, base < 5, transformers >= 0.3, csound-expression >= 5.1.0 exposed-modules: Csound.Sam Csound.Sam.Core
src/Csound/Sam.hs view
@@ -21,7 +21,7 @@ wide, flow, pick, pickBy, atPan, atPch, atCps, atPanRnd, atVolRnd, atVolGauss, -- * Loops- rep1, rep, pat1, pat, pat', + rep1, rep, pat1, pat, pat', rndPat, rndPat', -- * Arpeggio Chord, arpUp, arpDown, arpOneOf, arpFreqOf,@@ -416,6 +416,13 @@ pat dts = genLoop $ \bpm d asig -> sched (const $ return asig) $ fmap (const $ notes bpm d) $ metroS bpm (sig $ sum dts) where notes bpm d = har $ fmap (\t -> fromEvent $ Event (toSec bpm t) d unit) $ patDurs dts +-- | Plays the sample at the given pattern of periods (in BPMs) and sometimes skips the samples from playback. The overlapped samples are mixed together.+-- The first argument is the probability of inclusion.+rndPat :: Sig -> [D] -> Sam -> Sam +rndPat prob dts = genLoop $ \bpm d asig -> sched (const $ rndSkipInstr prob asig) $ fmap (const $ notes bpm d) $ metroS bpm (sig $ sum dts)+ where + notes bpm d = har $ fmap (\t -> fromEvent $ Event (toSec bpm t) d unit) $ patDurs dts + -- | Plays the sample at the given pattern of volumes and periods (in BPMs). The overlapped samples are mixed together. -- -- > pat' volumes periods@@ -425,6 +432,28 @@ notes bpm d = har $ zipWith (\v t -> singleEvent (toSec bpm t) d v) vols' $ patDurs dts' instr asig v = return $ mul (sig v) asig (vols', dts') = unzip $ lcmList vols dts++rndSkipInstr probSig asig = do+ let prob = ir probSig+ ref <- newRef 0 + p <- random 0 (1 :: D)+ whenD1 (p `lessThan` prob) $ + writeRef ref asig+ whenD1 (p `greaterThanEquals` prob) $+ writeRef ref 0+ readRef ref ++-- | Plays the sample at the given pattern of volumes and periods (in BPMs) and sometimes skips the samples from playback. The overlapped samples are mixed together.+-- The first argument is the probability of inclusion.+--+-- > rndPat' probability volumes periods+rndPat' :: Sig -> [D] -> [D] -> Sam -> Sam +rndPat' prob vols dts = genLoop $ \bpm d asig -> sched (instr asig) $ fmap (const $ notes bpm d) $ metroS bpm (sig $ sum dts')+ where + notes bpm d = har $ zipWith (\v t -> singleEvent (toSec bpm t) d v) vols' $ patDurs dts' + instr asig v = mul (sig v) $ rndSkipInstr prob asig + (vols', dts') = unzip $ lcmList vols dts+ lcmList :: [a] -> [b] -> [(a, b)] lcmList as bs = take n $ zip (cycle as) (cycle bs)