csound-expression 4.8.1 → 4.8.2
raw patch · 6 files changed
+221/−14 lines, 6 filesdep ~csound-expression-opcodesdep ~csound-expression-typedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: csound-expression-opcodes, csound-expression-typed
API changes (from Hackage documentation)
+ Csound.Air.Wave: birspline :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: blosc' :: Tab -> D -> Sig -> Sig
+ Csound.Air.Wave: detune :: Sig -> (Sig -> a) -> (Sig -> a)
+ Csound.Air.Wave: isaw' :: D -> Sig -> Sig
+ Csound.Air.Wave: multiCent :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> a)
+ Csound.Air.Wave: multiGauss :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> SE a)
+ Csound.Air.Wave: multiGaussSE :: Fractional a => Int -> Sig -> (Sig -> SE a) -> (Sig -> SE a)
+ Csound.Air.Wave: multiHz :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> a)
+ Csound.Air.Wave: multiRnd :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> SE a)
+ Csound.Air.Wave: multiRndSE :: Fractional a => Int -> Sig -> (Sig -> SE a) -> (Sig -> SE a)
+ Csound.Air.Wave: osc' :: D -> Sig -> Sig
+ Csound.Air.Wave: oscBy' :: Tab -> D -> Sig -> Sig
+ Csound.Air.Wave: pulse' :: D -> Sig -> Sig
+ Csound.Air.Wave: pw' :: Sig -> D -> Sig -> Sig
+ Csound.Air.Wave: ramp' :: Sig -> D -> Sig -> Sig
+ Csound.Air.Wave: rndBlosc :: Tab -> Sig -> SE Sig
+ Csound.Air.Wave: rndIsaw :: Sig -> SE Sig
+ Csound.Air.Wave: rndOsc :: Sig -> SE Sig
+ Csound.Air.Wave: rndOscBy :: Tab -> Sig -> SE Sig
+ Csound.Air.Wave: rndPulse :: Sig -> SE Sig
+ Csound.Air.Wave: rndPw :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: rndRamp :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: rndSaw :: Sig -> SE Sig
+ Csound.Air.Wave: rndSqr :: Sig -> SE Sig
+ Csound.Air.Wave: rndTri :: Sig -> SE Sig
+ Csound.Air.Wave: saw' :: D -> Sig -> Sig
+ Csound.Air.Wave: sqr' :: D -> Sig -> Sig
+ Csound.Air.Wave: tri' :: D -> Sig -> Sig
+ Csound.Air.Wave: ublosc' :: Tab -> D -> Sig -> Sig
+ Csound.Air.Wave: uisaw' :: D -> Sig -> Sig
+ Csound.Air.Wave: uosc' :: D -> Sig -> Sig
+ Csound.Air.Wave: uoscBy' :: Tab -> D -> Sig -> Sig
+ Csound.Air.Wave: upulse' :: D -> Sig -> Sig
+ Csound.Air.Wave: upw' :: Sig -> D -> Sig -> Sig
+ Csound.Air.Wave: uramp' :: Sig -> D -> Sig -> Sig
+ Csound.Air.Wave: urndBlosc :: Tab -> Sig -> SE Sig
+ Csound.Air.Wave: urndIsaw :: Sig -> SE Sig
+ Csound.Air.Wave: urndOsc :: Sig -> SE Sig
+ Csound.Air.Wave: urndOscBy :: Tab -> Sig -> SE Sig
+ Csound.Air.Wave: urndPulse :: Sig -> SE Sig
+ Csound.Air.Wave: urndPw :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: urndRamp :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: urndSaw :: Sig -> SE Sig
+ Csound.Air.Wave: urndSqr :: Sig -> SE Sig
+ Csound.Air.Wave: urndTri :: Sig -> SE Sig
+ Csound.Air.Wave: urspline :: Sig -> Sig -> SE Sig
+ Csound.Air.Wave: usaw' :: D -> Sig -> Sig
+ Csound.Air.Wave: usqr' :: D -> Sig -> Sig
+ Csound.Air.Wave: utri' :: D -> Sig -> Sig
+ Csound.Control.Evt: dust :: Sig -> Tick
+ Csound.Control.Evt: dustSig :: Sig -> SE Sig
+ Csound.Control.Evt: dustSig2 :: Sig -> SE Sig
+ Csound.Control.Evt: gaussTrig :: Sig -> Sig -> Tick
+ Csound.Control.Evt: metro :: Sig -> Evt Unit
+ Csound.Control.Evt: metroSig :: Sig -> Sig
Files
- csound-expression.cabal +3/−3
- src/Csound/Air/Granular.hs +5/−2
- src/Csound/Air/Misc.hs +2/−3
- src/Csound/Air/Wave.hs +172/−2
- src/Csound/Base.hs +2/−1
- src/Csound/Control/Evt.hs +37/−3
csound-expression.cabal view
@@ -1,5 +1,5 @@ Name: csound-expression-Version: 4.8.1+Version: 4.8.2 Cabal-Version: >= 1.6 License: BSD3 License-file: LICENSE@@ -68,8 +68,8 @@ Ghc-Options: -Wall Build-Depends: base >= 4, base < 5, process, data-default, Boolean >= 0.1.0, colour >= 2.0, transformers >= 0.3,- csound-expression-typed >= 0.0.7.6, csound-expression-dynamic >= 0.1.4.3, temporal-media >= 0.6.0,- csound-expression-opcodes >= 0.0.2+ csound-expression-typed >= 0.0.7.7, csound-expression-dynamic >= 0.1.4.3, temporal-media >= 0.6.0,+ csound-expression-opcodes >= 0.0.3 Hs-Source-Dirs: src/ Exposed-Modules: Csound.Base
src/Csound/Air/Granular.hs view
@@ -641,14 +641,17 @@ -- | The syncgrain with randomized parameters. rndSyncgrain :: RndSyncgrainSpec -> SyncgrainSpec -> GrainSize -> TempoSig -> PitchSig -> Tab -> SE Sig rndSyncgrain rndSpec spec kgrdur ktimescale kpitch ftab = do + rndSyncGrainDur <- rnd (rndSyncgrainGrainDur rndSpec)+ rndSyncGrainPitch <- birnd (rndSyncgrainPitch rndSpec)+ rndSyncGrainTimescale <- birnd (rndSyncTimescale rndSpec) let kgroverlap = sig $ (syncgrainOverlap spec) / 2 ko1 = int' (kgroverlap + 0.15)- kgr = kgrdur + rnd (rndSyncgrainGrainDur rndSpec)+ kgr = kgrdur + rndSyncGrainDur kfr = ko1 / kgr kps = 1 / ko1 awp = phasor (sig $ getSampleRate / ftlen ftab)- res = csdSyncgrain 1 kfr (kpitch + birnd (rndSyncgrainPitch rndSpec)) kgr (kps * ktimescale + birnd (rndSyncTimescale rndSpec)) ftab (syncgrainWin spec) (syncgrainOverlap spec)+ res = csdSyncgrain 1 kfr (kpitch + rndSyncGrainPitch) kgr (kps * ktimescale + rndSyncGrainTimescale) ftab (syncgrainWin spec) (syncgrainOverlap spec) return res -- | syncgrain that is defined on stereo audio files. We provide the filename instead of table.
src/Csound/Air/Misc.hs view
@@ -153,7 +153,7 @@ -- | Random panning rndPan :: Sig -> SE Sig2 rndPan a = do - return $ pan2 a (sig $ rnd (1 :: D))+ fmap (pan2 a . sig) (rnd (1 :: D)) -- | Random volume (with gauss distribution) -- @@ -168,9 +168,8 @@ -- > gaussVol (minVolume, maxVolume) rndVol :: SigSpace a => (D, D) -> a -> SE a rndVol (kMin, kMax) a = do- let level = rnd (1 :: D)+ level <- rnd (1 :: D) return $ mul (sig $ kMin + (kMax - kMin) * level) a- -- | Hi-fi output for stereo signals. Saves the stereo signal to file. -- The length of the file is defined in seconds.
src/Csound/Air/Wave.hs view
@@ -4,9 +4,21 @@ -- * Bipolar osc, oscBy, saw, isaw, pulse, sqr, pw, tri, ramp, blosc, + -- ** With phase control+ osc', oscBy', saw', isaw', pulse', sqr', pw', tri', ramp', blosc',++ -- ** With random phase+ rndOsc, rndOscBy, rndSaw, rndIsaw, rndPulse, rndSqr, rndPw, rndTri, rndRamp, rndBlosc, + -- * Unipolar unipolar, bipolar, uosc, uoscBy, usaw, uisaw, upulse, usqr, upw, utri, uramp, ublosc, + -- ** With phase control+ uosc', uoscBy', usaw', uisaw', upulse', usqr', upw', utri', uramp', ublosc',++ -- ** With random phase+ urndOsc, urndOscBy, urndSaw, urndIsaw, urndPulse, urndSqr, urndPw, urndTri, urndRamp, urndBlosc, + -- * Noise rndh, urndh, rndi, urndi, white, pink, @@ -14,7 +26,16 @@ fosc, -- * Low frequency oscillators- Lfo, lfo+ Lfo, lfo,++ -- * Detune+ detune,++ -- * Unision+ multiHz, multiCent, multiRnd, multiGauss, multiRndSE, multiGaussSE,++ -- * Random splines+ urspline, birspline ) where import Csound.Typed@@ -24,12 +45,20 @@ -- | A pure tone (sine wave). osc :: Sig -> Sig-osc cps = oscil3 1 cps sine+osc cps = oscil3 1 cps sine +-- | A pure tone (sine wave) with initial phase (the first argiment).+osc' :: D -> Sig -> Sig+osc' phase cps = oscil3 1 cps sine `withD` phase+ -- | An oscillator with user provided waveform. oscBy :: Tab -> Sig -> Sig oscBy tb cps = oscil3 1 cps tb +-- | An oscillator with user provided waveform with initial phase (the second argiment).+oscBy' :: Tab -> D -> Sig -> Sig+oscBy' tb phase cps = oscil3 1 cps tb `withD` phase+ -- unipolar waveforms -- | Turns a bipolar sound (ranges from -1 to 1) to unipolar (ranges from 0 to 1)@@ -72,6 +101,24 @@ ublosc :: Tab -> Sig -> Sig ublosc tb = unipolar . blosc tb +-- | Unipolar random splines.+-- It generates the splines with unipolar output (ranges from 0 to 1).+-- Arguments affect the frequency for generation of new values. +--+-- > urspline cpsMin cpsMax+urspline :: Sig -> Sig -> SE Sig+urspline cpsMin cpsMax = rspline 0 1 cpsMin cpsMax++-- | Bipolar random splines.+-- It generates the splines with bipolar output (ranges from -1 to 1).+-- Arguments affect the frequency for generation of new values. +--+-- > birspline cpsMin cpsMax+birspline :: Sig -> Sig -> SE Sig+birspline cpsMin cpsMax = rspline (-1) 1 cpsMin cpsMax++-----------------------+ -- | Frequency modulation -- -- > fosc carrierFreq modulatorFreq modIndex cps@@ -84,12 +131,24 @@ pw :: Sig -> Sig -> Sig pw duty cps = vco2 1 cps `withD` 2 `withSig` duty +-- | Pulse width modulation (width range is 0 to 1)+--+-- > pw' dutyCycle phase cps+pw' :: Sig -> D -> Sig -> Sig+pw' duty phase cps = vco2 1 cps `withD` 2 `withSig` duty `withD` phase+ -- | Triangle wave with ramp factor (factor's range is 0 to 1) -- -- > ramp factor cps ramp :: Sig -> Sig -> Sig ramp duty cps = vco2 1 cps `withD` 4 `withSig` (uon 0.01 0.99 $ duty) +-- | Triangle wave with ramp factor (factor's range is 0 to 1)+--+-- > ramp' factor phase cps+ramp' :: Sig -> D -> Sig -> Sig+ramp' duty phase cps = vco2 1 cps `withD` 4 `withSig` (uon 0.01 0.99 $ duty) `withD` phase+ -- | Unipolar pulse width modulation wave. upw :: Sig -> Sig -> Sig upw duty cps = unipolar $ pw duty cps@@ -99,6 +158,54 @@ uramp duty cps = unipolar $ ramp duty cps --------------------------------------------------------------------------+-- unipolar oscils with phase control++unipolar' :: (D -> Sig -> Sig) -> (D -> Sig -> Sig)+unipolar' f phs cps = unipolar $ f phs cps ++uosc' = unipolar' osc'+uoscBy' a = unipolar' (oscBy' a) +usaw' = unipolar' saw'+uisaw' = unipolar' isaw' +upulse' = unipolar' pulse' +usqr' = unipolar' sqr'+upw' a = unipolar' (pw' a)+utri' = unipolar' tri'+uramp' a = unipolar' (ramp' a)+ublosc' a = unipolar' (blosc' a)++--------------------------------------------------------------------------+-- random phase++rndPhs :: (D -> Sig -> Sig) -> (Sig -> SE Sig)+rndPhs f cps = fmap (\x -> f x cps) $ rnd 1++rndOsc = rndPhs osc'+rndOscBy a = rndPhs (oscBy' a)+rndSaw = rndPhs saw' +rndIsaw = rndPhs isaw'+rndPulse = rndPhs pulse'+rndSqr = rndPhs sqr'+rndPw a = rndPhs (pw' a)+rndTri = rndPhs tri'+rndRamp a = rndPhs (ramp' a)+rndBlosc a = rndPhs (blosc' a)++urndOsc = rndPhs uosc'+urndOscBy a = rndPhs (uoscBy' a)+urndSaw = rndPhs usaw' +urndIsaw = rndPhs uisaw'+urndPulse = rndPhs upulse'+urndSqr = rndPhs usqr'+urndPw a = rndPhs (upw' a)+urndTri = rndPhs utri'+urndRamp a = rndPhs (uramp' a)+urndBlosc a = rndPhs (ublosc' a)++--------------------------------------------------------------------------+-- unipolar random phase++-------------------------------------------------------------------------- -- noise -- | Constant random signal. It updates random numbers with given frequency.@@ -141,4 +248,67 @@ lfo :: (Sig -> Sig) -> Sig -> Sig -> Sig lfo shape depth rate = depth * shape rate +-------------------------------------------------------------------------- +-- | Scales the oscillator by frequency.+-- That's how we can rise the pitch by 2 semitones and 15 cents:+--+-- > detune (semitone 2 * cent 15) osc+detune :: Sig -> (Sig -> a) -> (Sig -> a)+detune k f cps = f (k * cps) ++--------------------------------------------------------------------------++linRange n amount = fmap (\x -> amount * sig (2 * double x - 1)) [0, (1 / fromIntegral n) .. 1] ++-- | Unision by Hertz. It creates n oscillators that are playing +-- the same pitch slightly detuned. The oscillatos's pitch is evenly distributed in Hz.+--+-- > multiHz numberOfUnits amountHz wave+multiHz :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> a) +multiHz n amount f cps = mean $ fmap (f . (cps + )) $ linRange n amount++-- | Unision by Cents. It creates n oscillators that are playing +-- the same pitch slightly detuned. The oscillatos's pitch is evenly distributed in cents.+--+-- > multiCent numberOfUnits amountCent wave+multiCent :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> a) +multiCent n amount f cps = mean $ fmap (f . (cps * ) . cent) $ linRange n amount+ +-- | Oscillators are detuned randomly in the given interval.+--+-- > multiRnd numberOfUnits amountCent wave+multiRnd :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> SE a)+multiRnd = genMultiRnd (rnd 1)++-- | Oscillators are detuned randomly with Gauss distribution in the given interval.+--+-- > multiGauss numberOfUnits amountCent wave+multiGauss :: Fractional a => Int -> Sig -> (Sig -> a) -> (Sig -> SE a)+multiGauss = genMultiRnd (fmap ((+ 0.5) . ir) $ gauss 0.5)++genMultiRnd :: Fractional a => (SE D) -> Int -> Sig -> (Sig -> a) -> (Sig -> SE a)+genMultiRnd gen n amount f cps = fmap mean $ mapM (const go) $ replicate n ()+ where go = fmap (\dx -> f $ cps + amount * (sig $ 2 * dx - 1)) gen++-- | Oscillators are detuned randomly in the given interval.+-- Useful for waves that return a signals with Side Effects.+--+-- > multiRnd numberOfUnits amountCent wave+multiRndSE :: Fractional a => Int -> Sig -> (Sig -> SE a) -> (Sig -> SE a)+multiRndSE = genMultiRndSE (rnd 1)++-- | Oscillators are detuned randomly with Gauss distribution in the given interval.+-- Useful for waves that return a signals with Side Effects.+--+-- > multiGauss numberOfUnits amountCent wave+multiGaussSE :: Fractional a => Int -> Sig -> (Sig -> SE a) -> (Sig -> SE a)+multiGaussSE = genMultiRndSE (fmap ((+ 0.5) . ir) $ gauss 0.5)++genMultiRndSE :: Fractional a => (SE D) -> Int -> Sig -> (Sig -> SE a) -> (Sig -> SE a)+genMultiRndSE gen n amount f cps = fmap mean $ mapM (const go) $ replicate n ()+ where go = (\dx -> f $ cps * cent (amount * (sig $ 2 * dx - 1))) =<< gen++-- | Mean value.+mean :: Fractional a => [a] -> a+mean xs = sum xs / (fromIntegral $ length xs)
src/Csound/Base.hs view
@@ -48,4 +48,5 @@ oscInit, oscListen, oscSend, lpshold, loopseg, loopxseg, partikkel, syncgrain, granule, sndwarp, sndwarpst, fof2,- line, delay)+ line, delay,+ metro, dust)
src/Csound/Control/Evt.hs view
@@ -9,7 +9,7 @@ Snap, snapshot, snaps, snaps2, sync, syncBpm, -- * Opcodes- metroE, impulseE, changedE, triggerE, loadbang, impulse,+ metro, gaussTrig, dust, metroSig, dustSig, dustSig2, impulseE, changedE, triggerE, loadbang, impulse, metroE, -- * Higher-level event functions devt, eventList,@@ -31,7 +31,8 @@ import Temporal.Media import Csound.Typed hiding (evtToBool)-import Csound.Typed.Opcode+import Csound.Typed.Opcode hiding (metro, dust, dust2)+import qualified Csound.Typed.Opcode as O(metro, dust, dust2) import Csound.Types(atArg) type Tick = Evt Unit@@ -47,9 +48,42 @@ devt :: D -> Evt a -> Evt D devt d = fmap (const d) +{-# DEPRECATED metroE "Use metro instead" #-} -- | Behaves like 'Csound.Opcode.Basic.metro', but returns an event stream. metroE :: Sig -> Evt Unit -metroE = sigToEvt . metro+metroE = sigToEvt . O.metro++-- | Creates a stream of events that happen with the given frequency.+metro :: Sig -> Evt Unit +metro = sigToEvt . O.metro++-- | Csound's original metro function.+metroSig :: Sig -> Sig+metroSig = O.metro++-- | Creates a stream of ticks that happen around the given frequency with given deviation.+-- +-- > gaussTrig freq deviation+gaussTrig :: Sig -> Sig -> Tick+gaussTrig afreq adev = Evt $ \bam -> do+ on <- gausstrig 1 (afreq * sig getBlockSize) adev+ when1 (on >* 0.5) $ bam unit++-- | Creates a stream of random events. The argument is a number of events per second.+--+-- > dust eventsPerSecond+dust :: Sig -> Tick+dust freq = Evt $ \bam -> do+ on <- O.dust 1 (freq * sig getBlockSize)+ when1 (on >* 0.5) $ bam unit++-- | Creates a signal that contains a random ones that happen with given frequency.+dustSig :: Sig -> SE Sig+dustSig freq = O.dust 1 (freq * sig getBlockSize)++-- | Creates a signal that contains a random ones or negative ones that happen with given frequency.+dustSig2 :: Sig -> SE Sig+dustSig2 freq = O.dust2 1 (freq * sig getBlockSize) -- | Fires a single event right now. --