module Csound.Typed.Plugins.Iain(
    pitchShifterDelay,
    fxAnalogDelay, fxDistortion, fxEnvelopeFollower, fxFlanger, fxFreqShifter, fxLoFi,
    fxPanTrem, fxMonoTrem, fxPhaser, fxPitchShifter, fxReverse, fxRingModulator, fxChorus2, fxPingPong
) where

import Csound.Dynamic

import Csound.Typed.Types
import Csound.Typed.GlobalState
import qualified Csound.Typed.GlobalState.Elements as E(pitchShifterDelayPlugin,
    analogDelayPlugin, distortionPlugin, envelopeFolollowerPlugin, flangerPlugin, freqShifterPlugin,
    loFiPlugin, panTremPlugin, monoTremPlugin, phaserPlugin, pitchShifterPlugin, reversePlugin, ringModulatorPlugin, stChorusPlugin, stereoPingPongDelayPlugin)

pitchShifterDelay :: D -> (Sig, Sig) -> Sig -> Sig -> Sig -> Sig
pitchShifterDelay :: D -> (Sig, Sig) -> Sig -> Sig -> Sig -> Sig
pitchShifterDelay D
imaxdlt (Sig
fb1, Sig
fb2) Sig
kdel Sig
ktrans Sig
ain = Sig -> Sig -> Sig -> Sig -> Sig -> D -> Sig
csdPitchShifterDelay Sig
ain Sig
ktrans Sig
kdel Sig
fb1 Sig
fb2 D
imaxdlt

-- | PitchShifterDelay
-- ; ----------------
-- ; A pitch shifter effect that employs delay lines
-- ;
-- ; aout  PitchShifterDelay  ain,ktrans,kdlt,kFB1,kFB2,imaxdlt
--;
--; Initialisation
--; --------------
--; imaxdlt --  maximum delay time (kdlt should not exceed this value)
--;
--; Performance
--; -----------
--; ain     --  input audio to be pitch shifted
--; ktrans  --  pitch transposition (in semitones)
--; kdlt    --  delay time employed by the pitch shifter effect (should be within the range ksmps/sr and imaxdlt)
--; kFB1    --  feedback using method 1 (output from delay taps are fed back directly into their own buffers before enveloping and mixing)
--; kFB2    --  feedback using method 2 (enveloped and mixed output from both taps is fed back into both buffers)
--
-- opcode  PitchShifterDelay,a,akkkki
csdPitchShifterDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> D -> Sig
csdPitchShifterDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> D -> Sig
csdPitchShifterDelay Sig
ain Sig
ktrans Sig
kdlt Sig
kFB1 Sig
kFB2 D
imaxdlt = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.pitchShifterDelayPlugin
    E -> E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E -> E)
-> GE E -> GE (E -> E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E -> E -> E)
-> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktrans GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdlt GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kFB1 GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kFB2 GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
imaxdlt
    where f :: E -> E -> E -> E -> E -> E -> E
f E
ain' E
ktrans' E
kdlt' E
kFB1' E
kFB2' E
imaxdlt' = Name -> Spec1 -> [E] -> E
opcs Name
"PitchShifterDelay" [(Rate
Ar, [Rate
Ar, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Kr, Rate
Ir])] [E
ain', E
ktrans', E
kdlt', E
kFB1', E
kFB2', E
imaxdlt']

--------------------------------------------------------
-- multi fx

fxAnalogDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxAnalogDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxAnalogDelay Sig
kmix Sig
ktime Sig
kfback Sig
ktone Sig
ain = Sig -> Sig -> Sig -> Sig -> Sig -> Sig
csdAnalogDelay Sig
ain Sig
kmix Sig
ktime Sig
kfback Sig
ktone

-- ; AnalogDelay
-- ; ----------------
-- ; A analog style delay with signal degradation and saturation options
-- ;
-- ; aout  AnalogDelay  ain,kmix,ktime,kfback,ktone
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to which the flanging effect will be applied
-- ; kmix   --  dry / wet mix of the output signal (range 0 to 1)
-- ; ktime  --  delay time of the effect in seconds
-- ; kfback --  control of the amount of output signal fed back into the input of the effect (exceeding 1 (100%) is possible and will result in saturation clipping effects)
-- ; ktone  --  control of the amount of output signal fed back into the input of the effect (range 0 to 1)
csdAnalogDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
csdAnalogDelay :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
csdAnalogDelay Sig
ain Sig
kmix Sig
ktime Sig
kfback Sig
ktone = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.analogDelayPlugin
    E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmix GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktime GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfback GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktone
    where f :: E -> E -> E -> E -> E -> E
f E
ain' E
kmix' E
ktime' E
kfback' E
ktone' = Name -> Spec1 -> [E] -> E
opcs Name
"AnalogDelay" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
kmix', E
ktime', E
kfback', E
ktone']

fxDistortion :: Sig -> Sig -> Sig -> Sig -> Sig
fxDistortion :: Sig -> Sig -> Sig -> Sig -> Sig
fxDistortion Sig
klevel Sig
kdrive Sig
ktone Sig
ain = Sig -> Sig -> Sig -> Sig -> Sig
csdDistortion Sig
ain Sig
klevel Sig
kdrive Sig
ktone

-- ; Distortion
-- ; ----------------
-- ; A distortion effect offering stomp-box-like controls
-- ;
-- ; aout  Distortion  ain,klevel,kdrive,ktone
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be distorted
-- ; klevel --  output level of the effect (range: 0 to 1)
-- ; kdrive --  intensity of the distortion effect (range: 0 to 1)
-- ; ktone  --  tone of a lowpass filter (range: 0 to 1)
csdDistortion :: Sig -> Sig -> Sig -> Sig -> Sig
csdDistortion :: Sig -> Sig -> Sig -> Sig -> Sig
csdDistortion Sig
ain Sig
klevel Sig
kdrive Sig
ktone = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.distortionPlugin
    E -> E -> E -> E -> E
f (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
klevel GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdrive GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktone
    where f :: E -> E -> E -> E -> E
f E
ain' E
klevel' E
kdrive' E
ktone' = Name -> Spec1 -> [E] -> E
opcs Name
"Distortion" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
klevel', E
kdrive', E
ktone']


fxEnvelopeFollower :: Sig -> Sig -> Sig -> Sig -> Sig
fxEnvelopeFollower :: Sig -> Sig -> Sig -> Sig -> Sig
fxEnvelopeFollower Sig
ksens Sig
kfreq Sig
kres Sig
ain = Sig -> Sig -> Sig -> Sig -> Sig
csdEnvelopeFollower Sig
ain Sig
ksens Sig
kfreq Sig
kres

-- ; EnvelopeFollower
-- ; ----------------
-- ; A dynamic envelope following resonant lowpass filter
-- ;
-- ; aout  EnvelopeFollower  ain,ksens,kfreq,kres
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be filtered
-- ; ksens  --  sensitivity of the envelope follower (suggested range: 0 to 1)
-- ; kfreq  --  base frequency of the filter before modulation by the input dynamics (range: 0 to 1)
-- ; kres   --  resonance of the lowpass filter (suggested range: 0 to 0.99)
csdEnvelopeFollower :: Sig -> Sig -> Sig -> Sig -> Sig
csdEnvelopeFollower :: Sig -> Sig -> Sig -> Sig -> Sig
csdEnvelopeFollower Sig
ain Sig
ksens Sig
kfreq Sig
kres = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.envelopeFolollowerPlugin
    E -> E -> E -> E -> E
f (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ksens GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfreq GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kres
    where f :: E -> E -> E -> E -> E
f E
ain' E
ksens' E
kfreq' E
kres' = Name -> Spec1 -> [E] -> E
opcs Name
"EnvelopeFollower" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
ksens', E
kfreq', E
kres']

-- ; Flanger
-- ; ----------------
-- ; A flanger effect following the typical design of a so called 'stomp box'
-- ;
-- ; aout  Flanger  ain,krate,kdepth,kdelay,kfback
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to which the flanging effect will be applied
-- ; krate  --  rate control of the lfo of the effect *NOT IN HERTZ* (range 0 to 1)
-- ; kdepth --  depth of the lfo of the effect (range 0 to 1)
-- ; kdelay --  static delay offset of the flanging effect (range 0 to 1)
-- ; kfback --  feedback and therefore intensity of the effect (range 0 to 1)
fxFlanger :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxFlanger :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxFlanger Sig
krate Sig
kdepth Sig
kdelay Sig
kfback Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.flangerPlugin
    E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
krate GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdepth GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdelay GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfback
    where f :: E -> E -> E -> E -> E -> E
f E
ain' E
krate' E
kdepth' E
kdelay' E
kfback' = Name -> Spec1 -> [E] -> E
opcs Name
"Flanger" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
krate', E
kdepth', E
kdelay', E
kfback']


-- ; FreqShifter
-- ; ----------------
-- ; A frequency shifter effect using the hilbert filter
-- ;
-- ; aout  FreqShifter  adry,kmix,kfreq,kmult,kfback
-- ;
-- ; Performance
-- ; -----------
-- ; adry   --  input audio to be frequency shifted
-- ; kmix   --  dry / wet mix of the output signal (range 0 to 1)
-- ; kfreq  --  frequency of frequency shifter effect (suggested range -1000 to 1000)
-- ; kmult  --  multiplier of frequency value for fine tuning control (suggested range -1 to 1)
-- ; kfback --  control of the amount of output signal fed back into the input of the effect (suggested range 0 to 1)
fxFreqShifter :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxFreqShifter :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxFreqShifter Sig
kmix Sig
kfreq Sig
kmult Sig
kfback Sig
adry = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.freqShifterPlugin
    E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
adry GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmix GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfreq GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmult GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfback
    where f :: E -> E -> E -> E -> E -> E
f E
adry' E
kmix' E
kfreq' E
kmult' E
kfback' = Name -> Spec1 -> [E] -> E
opcs Name
"FreqShifter" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr])] [E
adry', E
kmix', E
kfreq', E
kmult', E
kfback']


-- ; LoFi
-- ; ----------------
-- ; 'Low Fidelity' distorting effects of bit reduction and downsampling (foldover)
-- ;
-- ; aout  LoFi  ain,kbits,kfold
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to have low fidelity distortion effects applied
-- ; kbits  --  bit depth reduction (suggested range 0 to 0.6)
-- ; kfold  --  amount of foldover (range 0 to 1)
fxLoFi :: Sig -> Sig -> Sig -> Sig
fxLoFi :: Sig -> Sig -> Sig -> Sig
fxLoFi Sig
kbits Sig
kfold Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.loFiPlugin
    E -> E -> E -> E
f (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kbits GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfold
    where f :: E -> E -> E -> E
f E
ain' E
kbits' E
kfold' = Name -> Spec1 -> [E] -> E
opcs Name
"LoFi" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr])] [E
ain', E
kbits', E
kfold']

-- ; PanTrem
-- ; ----------------
-- ; Auto-panning and tremolo effects
-- ;
-- ; aout1,aout2  PanTrem  ainL,ainR,,krate,kdepth,kmode,kwave
-- ;
-- ; Performance
-- ; -----------
-- ; ainL   --  first/left input audio
-- ; ainR   --  second/right input audio
-- ; krate  --  rate control of the lfo of the effect *NOT IN HERTZ* (range 0 to 1)
-- ; kdepth --  depth of the lfo of the effect (range 0 to 1)
-- ; kmode  --  mode of the effect (0=auto-panning 1=tremolo)
-- ; kwave  --  waveform used by the lfo (0=sine 1=triangle 2=square)
fxPanTrem :: Sig -> Sig -> Sig -> Sig -> Sig2 -> Sig2
fxPanTrem :: Sig -> Sig -> Sig -> Sig -> (Sig, Sig) -> (Sig, Sig)
fxPanTrem Sig
krate Sig
kdepth Sig
kmode Sig
kwave (Sig
ainL, Sig
ainR) = GE [E] -> (Sig, Sig)
forall a. Tuple a => GE [E] -> a
toTuple (GE [E] -> (Sig, Sig)) -> GE [E] -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.panTremPlugin
    E -> E -> E -> E -> E -> E -> [E]
f (E -> E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainL GE (E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainR GE (E -> E -> E -> E -> [E]) -> GE E -> GE (E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
krate GE (E -> E -> E -> [E]) -> GE E -> GE (E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdepth GE (E -> E -> [E]) -> GE E -> GE (E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmode GE (E -> [E]) -> GE E -> GE [E]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kwave
    where f :: E -> E -> E -> E -> E -> E -> [E]
f E
ainL' E
ainR' E
krate' E
kdepth' E
kmode' E
kwave' = ((Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
2) ((Int -> [E]) -> [E]) -> (Int -> [E]) -> [E]
forall a b. (a -> b) -> a -> b
$ Name -> Specs -> [E] -> Int -> [E]
mopcs Name
"PanTrem" ([Rate
Ar,Rate
Ar], [Rate
Ar,Rate
Ar, Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr]) [E
ainL', E
ainR', E
krate', E
kdepth', E
kmode', E
kwave']

-- ; Tremolo
-- ; ----------------
-- ; Tremolo effect
-- ;
-- ; aout MonoTrem  ain,krate,kdepth,kwave
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio
-- ; krate  --  rate control of the lfo of the effect *NOT IN HERTZ* (range 0 to 1)
-- ; kdepth --  depth of the lfo of the effect (range 0 to 1)
-- ; kwave  --  waveform used by the lfo (0=sine 1=triangle 2=square)
fxMonoTrem :: Sig -> Sig -> Sig -> Sig -> Sig
fxMonoTrem :: Sig -> Sig -> Sig -> Sig -> Sig
fxMonoTrem Sig
krate Sig
kdepth Sig
kwave Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.monoTremPlugin
    E -> E -> E -> E -> E
f (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
krate GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdepth GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kwave
    where f :: E -> E -> E -> E -> E
f E
ain' E
krate' E
kdepth' E
kwave' = Name -> Spec1 -> [E] -> E
opcs Name
"MonoTrem" [(Rate
Ar, [Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
krate', E
kdepth', E
kwave']

-- ; Phaser
-- ; ----------------
-- ; An phase shifting effect that mimics the design of a so called 'stomp box'
-- ;
-- ; aout  Phaser  ain,krate,kdepth,kfreq,kfback
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be pitch shifted
-- ; krate  --  rate of lfo of the effect (range 0 to 1)
-- ; kdepth --  depth of lfo of the effect (range 0 to 1)
-- ; kfreq  --  centre frequency of the phase shifting effect in octaves (suggested range 6 to 11)
-- ; kfback --  feedback and therefore intensity of the effect (range 0 to 1)
fxPhaser :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxPhaser :: Sig -> Sig -> Sig -> Sig -> Sig -> Sig
fxPhaser Sig
krate Sig
kdepth Sig
kfreq Sig
kfback Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.phaserPlugin
    E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
krate GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdepth GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfreq GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfback
    where f :: E -> E -> E -> E -> E -> E
f E
ain' E
krate' E
kdepth' E
kfreq' E
kfback' = Name -> Spec1 -> [E] -> E
opcs Name
"Phaser" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
krate', E
kdepth', E
kfreq', E
kfback']

-- ; PitchShifter
-- ; ------------
-- ; A pitch shifter effect based on FFT technology
-- ;
-- ; aout  PitchShifter  ain,kmix,kpitch,kfine,kfback
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be pitch shifted
-- ; kmix   --  dry / wet mix of the output signal (range 0 to 1)
-- ; kscal  -- pitch ratio
-- #### ; kpitch --  pitch shifting interval in thousands of a semitone (suggested range -0.012 to 0.012)
-- #### ; kfine  --  fine control of pitch shifting interval in octaves (range -1/12 to 1/12)
-- ; kfback --  control of the amount of output signal fed back into the input of the effect (suggested range 0 to 1)
fxPitchShifter :: D -> Sig -> Sig -> Sig -> Sig -> Sig
fxPitchShifter :: D -> Sig -> Sig -> Sig -> Sig -> Sig
fxPitchShifter D
ifftsize Sig
kmix Sig
kscal Sig
kfback Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.pitchShifterPlugin
    E -> E -> E -> E -> E -> E
f (E -> E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmix GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kscal GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfback GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
ifftsize
    where f :: E -> E -> E -> E -> E -> E
f E
ain' E
kmix' E
kscal' E
kfback' E
ifftsize' = Name -> Spec1 -> [E] -> E
opcs Name
"PitchShifter" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Ir])] [E
ain', E
kmix', E
kscal', E
kfback', E
ifftsize']


-- ; Reverse
-- ; ----------------
-- ; An effect that reverses an audio stream in chunks
-- ;
-- ; aout  Reverse  ain,ktime
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be reversed
-- ; ktime  --  time duration of each chunk (suggested range: 0.3 to 2)--
fxReverse :: Sig -> Sig -> Sig
fxReverse :: Sig -> Sig -> Sig
fxReverse Sig
ktime Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.reversePlugin
    E -> E -> E
f (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktime
    where f :: E -> E -> E
f E
ain' E
ktime' = Name -> Spec1 -> [E] -> E
opcs Name
"Reverse" [(Rate
Ar,[Rate
Ar,Rate
Kr])] [E
ain', E
ktime']

-- ; RingModulator
-- ; ----------------
-- ; An ring modulating effect with an envelope follower
-- ;
-- ; aout  RingModulator  ain,kmix,kfreq,kenv
-- ;
-- ; Performance
-- ; -----------
-- ; ain    --  input audio to be pitch shifted
-- ; kmix   --  dry / wet mix of the output signal (range 0 to 1)
-- ; kfreq  --  frequency of thew ring modulator *NOT IN HERTZ* (range 0 to 1)
-- ; kenv   --  amount of dynamic envelope following modulation of frequency (range 0 to 1)
fxRingModulator :: Sig -> Sig -> Sig -> Sig -> Sig
fxRingModulator :: Sig -> Sig -> Sig -> Sig -> Sig
fxRingModulator Sig
kmix Sig
kfreq Sig
kenv Sig
ain = GE E -> Sig
forall a. Val a => GE E -> a
fromGE (GE E -> Sig) -> GE E -> Sig
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.ringModulatorPlugin
    E -> E -> E -> E -> E
f (E -> E -> E -> E -> E) -> GE E -> GE (E -> E -> E -> E)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ain GE (E -> E -> E -> E) -> GE E -> GE (E -> E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmix GE (E -> E -> E) -> GE E -> GE (E -> E)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfreq GE (E -> E) -> GE E -> GE E
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kenv
    where f :: E -> E -> E -> E -> E
f E
ain' E
kmix' E
kfreq' E
kenv' = Name -> Spec1 -> [E] -> E
opcs Name
"RingModulator" [(Rate
Ar,[Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr])] [E
ain', E
kmix', E
kfreq', E
kenv']

-- ; StChorus
-- ; ----------------
-- ; A stereo chorus effect
-- ;
-- ; aout  StChorus  ainL,ainR,krate,kdepth,kwidth
-- ;
-- ; Performance
-- ; -----------
-- ; ainL   --  first/left input audio
-- ; ainR   --  second/right input audio
-- ; krate  --  rate control of the lfo of the effect *NOT IN HERTZ* (range 0 to 1)
-- ; kdepth --  depth of the lfo of the effect (range 0 to 1)
-- ; kwidth --  width of stereo widening (range 0 to 1)
fxChorus2 :: Sig -> Sig -> Sig -> Sig2 -> Sig2
fxChorus2 :: Sig -> Sig -> Sig -> (Sig, Sig) -> (Sig, Sig)
fxChorus2 Sig
krate Sig
kdepth Sig
kwidth (Sig
ainL, Sig
ainR) = GE [E] -> (Sig, Sig)
forall a. Tuple a => GE [E] -> a
toTuple (GE [E] -> (Sig, Sig)) -> GE [E] -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.stChorusPlugin
    E -> E -> E -> E -> E -> [E]
f (E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainL GE (E -> E -> E -> E -> [E]) -> GE E -> GE (E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainR GE (E -> E -> E -> [E]) -> GE E -> GE (E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
krate GE (E -> E -> [E]) -> GE E -> GE (E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kdepth GE (E -> [E]) -> GE E -> GE [E]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kwidth
    where f :: E -> E -> E -> E -> E -> [E]
f E
ainL' E
ainR' E
krate' E
kdepth' E
kwidth' = ((Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
2) ((Int -> [E]) -> [E]) -> (Int -> [E]) -> [E]
forall a b. (a -> b) -> a -> b
$ Name -> Specs -> [E] -> Int -> [E]
mopcs Name
"StChorus" ([Rate
Ar,Rate
Ar], [Rate
Ar,Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr]) [E
ainL', E
ainR', E
krate', E
kdepth', E
kwidth']

-- aInL, aInR, kdelayTime, kFeedback, kMix, iMaxDelayTime xin

-- | Stereo ping-pong delay effect
--
-- > fxPingPong maxDelayTime kmix width tone time feedback (ainL, ainR)
fxPingPong :: D -> Sig -> Sig -> Sig -> Sig -> Sig -> Sig2 -> Sig2
fxPingPong :: D -> Sig -> Sig -> Sig -> Sig -> Sig -> (Sig, Sig) -> (Sig, Sig)
fxPingPong D
iMaxDelTime Sig
kmix Sig
kwidth Sig
ktone Sig
ktime Sig
kfeedback (Sig
ainL, Sig
ainR) = GE [E] -> (Sig, Sig)
forall a. Tuple a => GE [E] -> a
toTuple (GE [E] -> (Sig, Sig)) -> GE [E] -> (Sig, Sig)
forall a b. (a -> b) -> a -> b
$ do
    UdoPlugin -> GE ()
addUdoPlugin UdoPlugin
E.stereoPingPongDelayPlugin
    E -> E -> E -> E -> E -> E -> E -> E -> [E]
f (E -> E -> E -> E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainL GE (E -> E -> E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ainR GE (E -> E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktime GE (E -> E -> E -> E -> E -> [E])
-> GE E -> GE (E -> E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kfeedback GE (E -> E -> E -> E -> [E]) -> GE E -> GE (E -> E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kmix GE (E -> E -> E -> [E]) -> GE E -> GE (E -> E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
kwidth GE (E -> E -> [E]) -> GE E -> GE (E -> [E])
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Sig -> GE E
forall a. Val a => a -> GE E
toGE Sig
ktone GE (E -> [E]) -> GE E -> GE [E]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> D -> GE E
forall a. Val a => a -> GE E
toGE D
iMaxDelTime
    where f :: E -> E -> E -> E -> E -> E -> E -> E -> [E]
f E
ainL' E
ainR' E
ktime' E
kfeedback' E
kmix' E
kwidth' E
ktone' E
iMaxDelTime' = ((Int -> [E]) -> Int -> [E]
forall a b. (a -> b) -> a -> b
$ Int
2) ((Int -> [E]) -> [E]) -> (Int -> [E]) -> [E]
forall a b. (a -> b) -> a -> b
$ Name -> Specs -> [E] -> Int -> [E]
mopcs Name
"StereoPingPongDelay" ([Rate
Ar,Rate
Ar], [Rate
Ar,Rate
Ar,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Kr,Rate
Ir]) [E
ainL', E
ainR', E
ktime', E
kfeedback', E
kmix', E
kwidth', E
ktone', E
iMaxDelTime']