packages feed

csound-expression 3.3.1 → 3.3.2

raw patch · 3 files changed

+219/−71 lines, 3 filesdep ~csound-expression-typedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: csound-expression-typed

API changes (from Hackage documentation)

- Csound.Air: bbpb :: Sig -> Sig -> Sig -> Sig
- Csound.Air: bbrb :: Sig -> Sig -> Sig -> Sig
- Csound.Air: bhpb :: Sig -> Sig -> Sig
- Csound.Air: blpb :: Sig -> Sig -> Sig
- Csound.Air: bpb :: Sig -> Sig -> Sig -> Sig
- Csound.Air: brb :: Sig -> Sig -> Sig -> Sig
- Csound.Air: hpb :: Sig -> Sig -> Sig
- Csound.Air: lpb :: Sig -> Sig -> Sig
+ Csound.Air: alp :: Sig -> Sig -> Sig -> Sig
+ Csound.Air: chorusPitch :: Int -> Sig -> (Sig -> Sig) -> Sig -> Sig
+ Csound.Air: distortion :: Sig -> Sig -> Sig
+ Csound.Air: echo :: D -> Sig -> Sig -> SE Sig
+ Csound.Air: fdelay :: D -> Sig -> Sig -> Sig -> SE Sig
+ Csound.Air: flange :: Lfo -> Sig -> Sig -> Sig -> Sig
+ Csound.Air: funDelays :: D -> [(Sig, Sig -> Sig)] -> Sig -> Sig -> SE Sig
+ Csound.Air: fvdelay :: D -> Sig -> Sig -> Sig -> Sig -> SE Sig
+ Csound.Air: fvdelays :: D -> [(Sig, Sig)] -> Sig -> Sig -> SE Sig
+ Csound.Air: harmPhase :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig -> Sig -> Sig
+ Csound.Air: leg :: D -> D -> D -> D -> Sig
+ Csound.Air: lfo :: (Sig -> Sig) -> Sig -> Sig -> Sig
+ Csound.Air: phase1 :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig
+ Csound.Air: pink :: SE Sig
+ Csound.Air: powerPhase :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig -> Sig -> Sig
+ Csound.Air: rndh :: Sig -> SE Sig
+ Csound.Air: rndi :: Sig -> SE Sig
+ Csound.Air: scalePitch :: Sig -> Sig -> Sig
+ Csound.Air: type Lfo = Sig
+ Csound.Air: urndh :: Sig -> SE Sig
+ Csound.Air: urndi :: Sig -> SE Sig
+ Csound.Air: white :: SE Sig
+ Csound.Air: xeg :: D -> D -> D -> D -> Sig
- Csound.Air: chorus :: Fractional a => [Sig] -> (Sig -> a) -> Sig -> a
+ Csound.Air: chorus :: Sig -> Sig -> Sig -> Sig -> SE Sig
- Csound.Air: hp :: Sig -> Sig -> Sig
+ Csound.Air: hp :: Sig -> Sig -> Sig -> Sig
- Csound.Air: lp :: Sig -> Sig -> Sig
+ Csound.Air: lp :: Sig -> Sig -> Sig -> Sig

Files

csound-expression.cabal view
@@ -1,5 +1,5 @@ Name:          csound-expression-Version:       3.3.1+Version:       3.3.2 Cabal-Version: >= 1.6 License:       BSD3 License-file:  LICENSE@@ -26,6 +26,8 @@     .     * Introduction to Csound and library for Haskell users <http://github.com/anton-k/csound-expression/blob/master/tutorial/CsoundInstro.markdown>     .+    * Basics of sound synthesis with csound-expression <https://github.com/anton-k/csound-expression/blob/master/tutorial/SynthTutorial.md>+    .     * There are examples in the source code archive <http://github.com/anton-k/csound-expression/tree/master/examples>.      .     Key principles@@ -107,7 +109,7 @@   Ghc-Options:    -Wall   Build-Depends:         base >= 4, base < 5, process, data-default, Boolean >= 0.1.0,-        csound-expression-typed >= 0.0.5.1, csound-expression-opcodes+        csound-expression-typed >= 0.0.5.2, csound-expression-opcodes   Hs-Source-Dirs:      src/   Exposed-Modules:         Csound.Base
src/Csound/Air.hs view
@@ -8,8 +8,13 @@     -- ** Unipolar     unipolar, bipolar, on, uon, uosc, uoscBy, usaw, uisaw, upulse, usqr, utri, ublosc, +    -- * Noise+    rndh, urndh, rndi, urndi, white, pink,+     -- * Envelopes +    leg, xeg,+     -- ** Relative duration     onIdur, lindur, expdur, linendur,     onDur, lindurBy, expdurBy, linendurBy,@@ -19,19 +24,18 @@     -- ** Faders     fadeIn, fadeOut, fades, expFadeIn, expFadeOut, expFades, +    -- * Low frequency oscillators+    Lfo, lfo,+     -- * Filters     -- | Arguemnts are inversed to get most out of curruing. First come parameters and the last one is the signal.          -- ** Simple filters-    lp, hp, bp, br,+    lp, hp, bp, br, alp,          -- ** Butterworth filters     blp, bhp, bbp, bbr, -    -- ** Balanced filters-    -- | Applies filter and balances the output by the input signal.-    lpb, hpb, bpb, brb, blpb, bhpb, bbpb, bbrb,-     -- ** Specific filters     mlp, @@ -52,10 +56,10 @@     takeSnd, delaySnd, segmentSnd, repeatSnd, toMono,      -- * Spectral functions-    toSpec, fromSpec, mapSpec, scaleSpec, addSpec,+    toSpec, fromSpec, mapSpec, scaleSpec, addSpec, scalePitch,      -- * Patterns-    mean, vibrate, randomPitch, chorus, resons, resonsBy, modes, dryWet,    +    mean, vibrate, randomPitch, chorusPitch, resons, resonsBy, modes, dryWet,          -- ** List functions     odds, evens,@@ -66,24 +70,41 @@     classicWaves,     masterVolume, masterVolumeKnob, -    -- * Reverbs+    -- Effects+    +    -- ** Reverbs     reverbsc1, rever1, rever2, reverTime,     smallRoom, smallHall, largeHall, magicCave,-    smallRoom2, smallHall2, largeHall2, magicCave2+    smallRoom2, smallHall2, largeHall2, magicCave2, +    -- ** Delays+    echo, fdelay, fvdelay, fvdelays, funDelays,++    -- ** Distortion+    distortion,++    -- ** Chorus+    chorus,++    -- ** Flanger+    flange,++    -- ** Phase+    phase1, harmPhase, powerPhase+ ) where  import Data.List(intersperse, isSuffixOf) import Data.Boolean  import Csound.Typed-import Csound.Typed.Opcode hiding (display)+import Csound.Typed.Opcode hiding (display, lfo) import Csound.Typed.Gui import Csound.Control.Gui(funnyRadio) import Csound.Control.Evt(metroE, eventList) import Csound.Control.Instr(withDur, sched) -import Csound.Tab(sine)+import Csound.Tab(sine, sines4)  ------------------------------------------------------------------- -- waveforms@@ -153,8 +174,51 @@ uon a b x = a + (b - a) * x  --------------------------------------------------------------------------+-- noise++-- | Constant random signal. It updates random numbers with given frequency.+--+-- > constRnd freq +rndh :: Sig -> SE Sig+rndh = randh 1++-- | Linear random signal. It updates random numbers with given frequency.+--+-- > rndi freq +rndi :: Sig -> SE Sig+rndi = randi 1++-- | Unipolar @rndh@+urndh :: Sig -> SE Sig+urndh = fmap unipolar . rndh++-- | Unipolar @rndi@+urndi :: Sig -> SE Sig+urndi = fmap unipolar . rndi++-- | White noise.+white :: SE Sig +white = noise 1 0++-- | Pink noise.+pink :: SE Sig+pink = pinkish 1++-------------------------------------------------------------------------- -- envelopes +-- | Linear adsr envelope generator with release+--+-- > leg attack decay sustain release+leg :: D -> D -> D -> D -> Sig+leg = madsr++-- | Exponential adsr envelope generator with release+--+-- > xeg attack decay sustain release+xeg :: D -> D -> D -> D -> Sig+xeg a d s r = mxadsr a d (s + 0.00001) r+ -- | Makes time intervals relative to the note's duration. So that: -- -- > onIdur [a, t1, b, t2, c]@@ -240,32 +304,50 @@ expFades att dec = expFadeIn att * expFadeOut dec  ----------------------------------------------------------------------------- filters+-- lfo --- | High-pass filter.+-- | Low frequency oscillator+type Lfo = Sig++-- | Low frequency oscillator ----- > hp cutoff sig-hp :: Sig -> Sig -> Sig-hp = flip atone+-- > lfo shape depth rate+lfo :: (Sig -> Sig) -> Sig -> Sig -> Sig+lfo shape depth rate = depth * shape rate +--------------------------------------------------------------------------+-- filters+ -- | Low-pass filter. ----- > lp cutoff sig-lp :: Sig -> Sig -> Sig-lp = flip tone+-- > lp cutoff resonance sig+lp :: Sig -> Sig -> Sig -> Sig+lp cf q a = bqrez a cf q +-- | High-pass filter.+--+-- > hp cutoff resonance sig+hp :: Sig -> Sig -> Sig -> Sig+hp cf q a = bqrez a cf q `withD` 1+ -- | Band-pass filter. ----- > bp cutoff bandwidth sig+-- > bp cutoff resonance sig bp :: Sig -> Sig -> Sig -> Sig-bp freq band a = reson a freq band+bp cf q a = bqrez a cf q `withD` 2 --- | Band-regect filter.+-- | Band-reject filter. ----- > br cutoff bandwidth sig-br :: Sig -> Sig -> Sig -> Sig -br freq band a = areson a freq band+-- > br cutoff resonance sig+br :: Sig -> Sig -> Sig -> Sig+br cf q a = bqrez a cf q `withD` 3 +-- | All-pass filter.+--+-- > alp cutoff resonance sig+alp :: Sig -> Sig -> Sig -> Sig+alp cf q a = bqrez a cf q `withD` 4+ -- Butterworth filters  -- | High-pass filter.@@ -292,46 +374,7 @@ bbr :: Sig -> Sig -> Sig -> Sig  bbr freq band a = butbr a freq band --- Balanced filters -balance1 :: (Sig -> Sig -> Sig) -> (Sig -> Sig -> Sig)-balance1 f = \cfq asig -> balance (f cfq asig) asig--balance2 :: (Sig -> Sig -> Sig -> Sig) -> (Sig -> Sig -> Sig -> Sig)-balance2 f = \cfq bw asig -> balance (f cfq bw asig) asig---- | Balanced low-pass filter.-lpb :: Sig -> Sig -> Sig-lpb = balance1 lp---- | Balanced high-pass filter.-hpb :: Sig -> Sig -> Sig-hpb = balance1 hp---- | Balanced band-pass filter.-bpb :: Sig -> Sig -> Sig -> Sig-bpb = balance2 bp---- | Balanced band-reject filter.-brb :: Sig -> Sig -> Sig -> Sig-brb = balance2 br---- | Balanced butterworth low-pass filter.-blpb :: Sig -> Sig -> Sig-blpb = balance1 blp---- | Balanced butterworth high-pass filter.-bhpb :: Sig -> Sig -> Sig-bhpb = balance1 bhp---- | Balanced butterworth band-pass filter.-bbpb :: Sig -> Sig -> Sig -> Sig-bbpb = balance2 bbp---- | Balanced butterworth band-reject filter.-bbrb :: Sig -> Sig -> Sig -> Sig-bbrb = balance2 bbr- -- | Moog's low-pass filter. -- -- > mlp centerFrequency qResonance signal@@ -458,6 +501,10 @@ addSpec :: Sig -> Sig -> Sig addSpec hz = mapSpec $ \x -> pvshift x hz 0 +-- | Scales frequency in semitones.+scalePitch :: Sig -> Sig -> Sig+scalePitch n = scaleSpec (semitone n)+ -------------------------------------------------------------------------- -- patterns @@ -548,11 +595,17 @@     where go krand = f (cps + krand)  --- | Chorus takes a list of displacments from the base frequencies and a sound unit.--- Output is mean of signals with displacments that is applied to the base frequency. -chorus :: Fractional a => [Sig] -> (Sig -> a) -> Sig -> a-chorus ks f = \cps -> mean $ fmap (f . (+ cps)) ks+-- | Chorus takes a number of copies, chorus width and wave shape.+chorusPitch :: Int -> Sig -> (Sig -> Sig) -> Sig -> Sig+chorusPitch n wid = phi dts+    where+        phi :: [Sig] -> (Sig -> Sig) -> Sig -> Sig+        phi ks f = \cps -> mean $ fmap (f . (+ cps)) ks +        dts = fmap (\x -> - wid + fromIntegral x * dt) [0 .. n-1] ++        dt = 2 * wid / fromIntegral n+ -- | Applies a resonator to the signals. A resonator is -- a list of band pass filters. A list contains the parameters for the filters: --@@ -720,3 +773,96 @@ -- | The magic cave reverb (stereo). magicCave2 :: Sig -> Sig -> (Sig, Sig) magicCave2 = rever2 0.99++-- Delays++-- | The simplest delay with feedback. Arguments are: delay length and decay ratio.+--+-- > echo delayLength ratio+echo :: D -> Sig -> Sig -> SE Sig+echo len fb = fdelay len fb 1++-- | Delay with feedback. +--+-- > fdelay maxDelayLength delayLength decayRatio+fdelay :: D -> Sig -> Sig -> Sig -> SE Sig+fdelay len = fvdelay len (sig len)+++-- | Delay with feedback. +--+-- > fdelay maxDelayLength delayLength feedbackLevel decayRatio+fvdelay :: D -> Sig -> Sig -> Sig -> Sig -> SE Sig+fvdelay len dt fb mx a = do+	_ <- delayr len+	aDel <- deltap3 dt+	delayw $ a + fb * aDel+	return $ a + (aDel * mx)++-- | Multitap delay. Arguments are: max delay length, list of pairs @(delayLength, decayRatio)@,+-- balance of mixed signal with processed signal.+--+-- > fdelay maxDelayLength  delays balance asig+fvdelays :: D -> [(Sig, Sig)] -> Sig -> Sig -> SE Sig+fvdelays len dtArgs mx a = funDelays len (zip dts fs) mx a+	where +		(dts, fbks) = unzip dtArgs+		fs = map (*) fbks+++-- | Generic multitap delay. It's just like @fvdelays@ but instead of constant feedbackLevel +-- it expects a function for processing a delayed signal on the tap.+--+-- > fdelay maxDelayLength  delays balance asig+funDelays :: D -> [(Sig, Sig -> Sig)] -> Sig -> Sig -> SE Sig+funDelays len dtArgs mx a = do+	_ <- delayr len+	aDels <- mapM deltap3 dts+	delayw $ a + sum (zipWith ($) fs aDels)+	return $ a + mx * sum aDels +	where (dts, fs) = unzip dtArgs++-- Distortion++-- | Distortion. +--+-- > distort distLevel asig+distortion :: Sig -> Sig -> Sig+distortion pre asig = distort1 asig pre 0.5 0 0 `withD` 1++-- Chorus++-- | Chorus.+--+-- > chorus depth rate balance asig+chorus :: Sig -> Sig -> Sig -> Sig -> SE Sig+chorus depth rate mx asig = do+	_ <- delayr 1.2+	adelSig <- deltap3 (0.03 * depth * oscBy fn (3 * rate) + 0.01)+	delayw asig+	return $ ntrpol asig adelSig mx+	where fn = sines4 [(0.5, 1, 180, 1)] -- U-shape parabola++-- Flanger++-- | Flanger. Lfo depth ranges in 0 to 1.+--+-- flanger lfo feedback balance asig+flange :: Lfo -> Sig -> Sig -> Sig -> Sig+flange alfo fbk mx asig = ntrpol asig (flanger asig ulfo fbk) mx+	where ulfo = 0.0001 + 0.02 * unipolar alfo++-- Phaser++-- | First order phaser.+phase1 :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig+phase1 ord alfo fbk mx asig = ntrpol asig (phaser1 asig (20 + unipolar alfo) ord fbk) mx  ++-- | Second order phaser. Sweeping gaps in the timbre are placed harmonicaly+harmPhase :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig -> Sig -> Sig+harmPhase ord alfo q sep fbk mx asig = ntrpol asig (phaser2 asig (20 + unipolar alfo) q ord 1 sep fbk) mx++-- | Second order phaser. Sweeping gaps in the timbre are placed by powers of the base frequency.+powerPhase :: Sig -> Lfo -> Sig -> Sig -> Sig -> Sig -> Sig -> Sig+powerPhase ord alfo q sep fbk mx asig = ntrpol asig (phaser2 asig (20 + unipolar alfo) q ord 2 sep fbk) mx+
src/Csound/Base.hs view
@@ -35,5 +35,5 @@ import Data.Default import Data.Monoid     -import Csound.Typed.Opcode hiding (button, display, space)+import Csound.Typed.Opcode hiding (button, display, space, lfo)