synthesizer-llvm-1.1.0.1: Efficient signal processing using runtime compilation

Safe HaskellNone
LanguageHaskell98

Synthesizer.LLVM.Causal.Process

Synopsis
  • data T a b
  • type MV a b = T (T a) (T b)
  • fromSignal :: C process => SignalOf process b -> process a b
  • toSignal :: C process => process () a -> SignalOf process a
  • ($<) :: C process => process (a, b) c -> SignalOf process a -> process b c
  • ($>) :: C process => process (a, b) c -> SignalOf process b -> process a c
  • ($*) :: C process => process a b -> SignalOf process a -> SignalOf process b
  • ($<#) :: (C process, C a) => process (T a, b) c -> a -> process b c
  • ($>#) :: (C process, C b) => process (a, T b) c -> b -> process a c
  • ($*#) :: (C process, SignalOf process ~ signal, C a) => process (T a) b -> a -> signal b
  • map :: (Aggregate ae a, Aggregate be b) => (ae -> be) -> T a b
  • zipWith :: (Aggregate ae a, Aggregate be b, Aggregate ce c) => (ae -> be -> ce) -> T (a, b) c
  • takeWhile :: Aggregate ae a => (ae -> Exp Bool) -> T a a
  • take :: Exp Word -> T a a
  • mix :: Additive a => T (a, a) a
  • raise :: (C a, Additive a) => Exp a -> MV a a
  • envelope :: PseudoRing a => T (a, a) a
  • envelopeStereo :: PseudoRing a => T (a, T a) (T a)
  • amplify :: (Aggregate ea a, C a, PseudoRing a) => ea -> T a a
  • amplifyStereo :: (C a, PseudoRing a, T (T a) ~ stereo) => Exp a -> T stereo stereo
  • mapLinear :: (C a, T a ~ am, PseudoRing a, IntegerConstant a) => Exp a -> Exp a -> T am am
  • mapExponential :: (C a, T a ~ am, Transcendental a, RationalConstant a) => Exp a -> Exp a -> T am am
  • loop :: (Aggregate ce c, C c) => ce -> T (a, c) (b, c) -> T a b
  • loopZero :: (Additive c, C c) => T (a, c) (b, c) -> T a b
  • integrate :: (Aggregate ae a, Additive a, C a) => ae -> T a a
  • integrateZero :: (Additive a, C a) => T a a
  • delay1 :: (Aggregate ae a, C a) => ae -> T a a
  • delayControlled :: (Aggregate ae al, C al) => ae -> Exp Word -> T (T Word, al) al
  • delayControlledInterpolated :: C nodes => T a ~ am => (NativeFloating a ar, Additive a) => (Aggregate ve v, C v) => (forall r. T r nodes am v) -> ve -> Exp Word -> T (am, v) v
  • differentiate :: (Additive a, Aggregate ae a, C a) => ae -> T a a
  • feedbackControlled :: (Aggregate ce c, C c) => ce -> T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b
  • feedbackControlledZero :: (Additive c, C c) => T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b
  • mapAccum :: (Aggregate state statel, C statel, Aggregate a al, Aggregate b bl) => (a -> state -> (b, state)) -> state -> T al bl
  • fromModifier :: (Aggregate ae al, Aggregate be bl, Aggregate ce cl, Aggregate se sl, C sl) => Simple se ce ae be -> T (cl, al) bl
  • osciCoreSync :: (C t, Fraction t) => T (t, t) t
  • osciCore :: (C t, Fraction t) => T (t, t) t
  • osci :: (C t, Fraction t) => (forall r. t -> CodeGenFunction r y) -> T (t, t) y
  • shapeModOsci :: (C t, Fraction t) => (forall r. c -> t -> CodeGenFunction r y) -> T (c, (t, t)) y
  • skip :: (Undefined a, Phi a, C a) => T a -> T (T Word) a
  • frequencyModulation :: (C a, IntegerConstant a, Additive a, Comparison a, Undefined nodes, Phi nodes, C nodes) => (forall r. T a -> nodes -> CodeGenFunction r v) -> T nodes -> T (T a) v
  • frequencyModulationLinear :: (PseudoRing a, IntegerConstant a, Comparison a, C a) => MV a -> MV a a
  • quantizeLift :: (C b, C c, IntegerConstant c, Additive c, Comparison c) => T a b -> T (T c, a) b
  • track :: (Aggregate ae al, C al) => ae -> Exp Word -> T al (T al)
  • delay :: (Aggregate ae al, C al) => ae -> Exp Word -> T al al
  • delayZero :: (Aggregate ae al, C ae, C al) => Exp Word -> T al al
  • replicateControlled :: (Undefined a, Phi a) => Exp Word -> T (c, a) a -> T (c, a) a
  • replicateControlledParam :: Natural n => (Undefined a, Phi a) => (C b, (n :*: SizeOf (Struct b)) ~ bSize, Natural bSize) => (Exp b -> T (c, a) a) -> Exp (Array n b) -> T (c, a) a
  • stereoFromMono :: (Phi a, Undefined a, Phi b, Undefined b) => T a b -> T (T a) (T b)
  • stereoFromMonoControlled :: (Phi a, Phi b, Phi c, Undefined a, Undefined b, Undefined c) => T (c, a) b -> T (c, T a) (T b)
  • stereoFromMonoParametric :: (C x, Phi a, Undefined a, Phi b, Undefined b) => ((D2 :*: SizeOf (Struct x)) ~ xSize, Natural xSize) => (Exp x -> T a b) -> T (Exp x) -> T (T a) (T b)
  • comb :: (C a, PseudoRing a) => Exp a -> Exp Word -> MV a a
  • combStereo :: (C a, PseudoRing a, T (T a) ~ stereo) => Exp a -> Exp Word -> T stereo stereo
  • reverbExplicit :: (Natural n, (n :*: UnknownSize) ~ paramSize, Natural paramSize) => (C a, Field a, Real a, IntegerConstant a) => Exp (Array n (a, Word)) -> MV a a
  • reverbParams :: (RandomGen g, Integer n, Random a) => g -> Proxy n -> (a, a) -> (Word, Word) -> Array n (a, Word)
  • trigger :: (C a, Undefined b, Phi b) => (Exp a -> T b) -> T (T (T a)) (T b)
  • arrayElement :: (C a, Struct a ~ aStruct, IsFirstClass aStruct, Natural i, Natural n, i :<: n) => Proxy i -> T (T (Array n a)) (T a)
  • vectorize :: (Positive n, C x, T x ~ a, T n x ~ va, C y, T y ~ b, T n y ~ vb) => T a b -> T va vb
  • pipeline :: (Positive n, C x, v ~ T n x, a ~ T x, Zero v, C v) => T v v -> T a a

Documentation

data T a b Source #

Instances
Arrow T Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

arr :: (b -> c) -> T b c #

first :: T b c -> T (b, d) (c, d) #

second :: T b c -> T (d, b) (d, c) #

(***) :: T b c -> T b' c' -> T (b, b') (c, c') #

(&&&) :: T b c -> T b c' -> T b (c, c') #

C T Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Associated Types

type SignalOf T :: Type -> Type #

Methods

toSignal :: T () a -> SignalOf T a #

fromSignal :: SignalOf T b -> T a b #

Functor (T a) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

fmap :: (a0 -> b) -> T a a0 -> T a b #

(<$) :: a0 -> T a b -> T a a0 #

Applicative (T a) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

pure :: a0 -> T a a0 #

(<*>) :: T a (a0 -> b) -> T a a0 -> T a b #

liftA2 :: (a0 -> b -> c) -> T a a0 -> T a b -> T a c #

(*>) :: T a a0 -> T a b -> T a b #

(<*) :: T a a0 -> T a b -> T a a0 #

Category T Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

id :: T a a #

(.) :: T b c -> T a b -> T a c #

(Field b, Real b, RationalConstant b) => Fractional (T a b) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

(/) :: T a b -> T a b -> T a b #

recip :: T a b -> T a b #

fromRational :: Rational -> T a b #

(PseudoRing b, Real b, IntegerConstant b) => Num (T a b) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

(+) :: T a b -> T a b -> T a b #

(-) :: T a b -> T a b -> T a b #

(*) :: T a b -> T a b -> T a b #

negate :: T a b -> T a b #

abs :: T a b -> T a b #

signum :: T a b -> T a b #

fromInteger :: Integer -> T a b #

(Field b, RationalConstant b) => C (T a b) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

(/) :: T a b -> T a b -> T a b #

recip :: T a b -> T a b #

fromRational' :: Rational -> T a b #

(^-) :: T a b -> Integer -> T a b #

(PseudoRing b, IntegerConstant b) => C (T a b) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

(*) :: T a b -> T a b -> T a b #

one :: T a b #

fromInteger :: Integer -> T a b #

(^) :: T a b -> Integer -> T a b #

Additive b => C (T a b) Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

Methods

zero :: T a b #

(+) :: T a b -> T a b -> T a b #

(-) :: T a b -> T a b -> T a b #

negate :: T a b -> T a b #

type SignalOf T Source # 
Instance details

Defined in Synthesizer.LLVM.Causal.Private

type SignalOf T = T

type MV a b = T (T a) (T b) Source #

fromSignal :: C process => SignalOf process b -> process a b #

toSignal :: C process => process () a -> SignalOf process a #

($<) :: C process => process (a, b) c -> SignalOf process a -> process b c infixl 0 #

($>) :: C process => process (a, b) c -> SignalOf process b -> process a c infixl 0 #

($*) :: C process => process a b -> SignalOf process a -> SignalOf process b infixl 0 #

($<#) :: (C process, C a) => process (T a, b) c -> a -> process b c infixl 0 Source #

($>#) :: (C process, C b) => process (a, T b) c -> b -> process a c infixl 0 Source #

($*#) :: (C process, SignalOf process ~ signal, C a) => process (T a) b -> a -> signal b infixl 0 Source #

provide constant input in a comfortable way

map :: (Aggregate ae a, Aggregate be b) => (ae -> be) -> T a b Source #

zipWith :: (Aggregate ae a, Aggregate be b, Aggregate ce c) => (ae -> be -> ce) -> T (a, b) c Source #

takeWhile :: Aggregate ae a => (ae -> Exp Bool) -> T a a Source #

take :: Exp Word -> T a a Source #

mix :: Additive a => T (a, a) a Source #

You may also use '(+)'.

raise :: (C a, Additive a) => Exp a -> MV a a Source #

You may also use '(+)' and a constant signal or a number literal.

envelope :: PseudoRing a => T (a, a) a Source #

You may also use '(*)'.

envelopeStereo :: PseudoRing a => T (a, T a) (T a) Source #

amplify :: (Aggregate ea a, C a, PseudoRing a) => ea -> T a a Source #

You may also use '(*)' and a constant signal or a number literal.

amplifyStereo :: (C a, PseudoRing a, T (T a) ~ stereo) => Exp a -> T stereo stereo Source #

mapLinear :: (C a, T a ~ am, PseudoRing a, IntegerConstant a) => Exp a -> Exp a -> T am am Source #

mapExponential :: (C a, T a ~ am, Transcendental a, RationalConstant a) => Exp a -> Exp a -> T am am Source #

loop :: (Aggregate ce c, C c) => ce -> T (a, c) (b, c) -> T a b Source #

loopZero :: (Additive c, C c) => T (a, c) (b, c) -> T a b Source #

integrate :: (Aggregate ae a, Additive a, C a) => ae -> T a a Source #

integrateZero :: (Additive a, C a) => T a a Source #

delay1 :: (Aggregate ae a, C a) => ae -> T a a Source #

delayControlled :: (Aggregate ae al, C al) => ae -> Exp Word -> T (T Word, al) al Source #

Delay by a variable amount of samples. The momentum delay must be between 0 and maxTime, inclusively. How about automated clipping?

delayControlledInterpolated :: C nodes => T a ~ am => (NativeFloating a ar, Additive a) => (Aggregate ve v, C v) => (forall r. T r nodes am v) -> ve -> Exp Word -> T (am, v) v Source #

Delay by a variable fractional amount of samples. Non-integer delays are achieved by interpolation. The momentum delay must be between 0 and maxTime, inclusively.

differentiate :: (Additive a, Aggregate ae a, C a) => ae -> T a a Source #

feedbackControlled :: (Aggregate ce c, C c) => ce -> T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b Source #

feedbackControlledZero :: (Additive c, C c) => T ((ctrl, a), c) b -> T (ctrl, b) c -> T (ctrl, a) b Source #

mapAccum :: (Aggregate state statel, C statel, Aggregate a al, Aggregate b bl) => (a -> state -> (b, state)) -> state -> T al bl Source #

fromModifier :: (Aggregate ae al, Aggregate be bl, Aggregate ce cl, Aggregate se sl, C sl) => Simple se ce ae be -> T (cl, al) bl Source #

osciCoreSync :: (C t, Fraction t) => T (t, t) t Source #

Compute the phases from phase distortions and frequencies.

It's like integrate but with wrap-around performed by fraction. For FM synthesis we need also negative phase distortions, thus we use addToPhase which supports that.

osciCore :: (C t, Fraction t) => T (t, t) t Source #

Compute the phases from phase distortions and frequencies.

It's like integrate but with wrap-around performed by fraction. For FM synthesis we need also negative phase distortions, thus we use addToPhase which supports that.

osci :: (C t, Fraction t) => (forall r. t -> CodeGenFunction r y) -> T (t, t) y Source #

shapeModOsci :: (C t, Fraction t) => (forall r. c -> t -> CodeGenFunction r y) -> T (c, (t, t)) y Source #

skip :: (Undefined a, Phi a, C a) => T a -> T (T Word) a Source #

Feeds a signal into a causal process while holding or skipping signal elements according to the process input. The skip happens after a value is passed from the fed signal.

skip x $* 0 repeats the first signal value in the output. skip x $* 1 feeds the signal to the output as is. skip x $* 2 feeds the signal to the output with double speed.

frequencyModulation :: (C a, IntegerConstant a, Additive a, Comparison a, Undefined nodes, Phi nodes, C nodes) => (forall r. T a -> nodes -> CodeGenFunction r v) -> T nodes -> T (T a) v Source #

frequencyModulationLinear :: (PseudoRing a, IntegerConstant a, Comparison a, C a) => MV a -> MV a a Source #

quantizeLift :: (C b, C c, IntegerConstant c, Additive c, Comparison c) => T a b -> T (T c, a) b Source #

track :: (Aggregate ae al, C al) => ae -> Exp Word -> T al (T al) Source #

delay :: (Aggregate ae al, C al) => ae -> Exp Word -> T al al Source #

Delay time must be non-negative.

delayZero :: (Aggregate ae al, C ae, C al) => Exp Word -> T al al Source #

replicateControlled :: (Undefined a, Phi a) => Exp Word -> T (c, a) a -> T (c, a) a Source #

replicateControlledParam :: Natural n => (Undefined a, Phi a) => (C b, (n :*: SizeOf (Struct b)) ~ bSize, Natural bSize) => (Exp b -> T (c, a) a) -> Exp (Array n b) -> T (c, a) a Source #

stereoFromMono :: (Phi a, Undefined a, Phi b, Undefined b) => T a b -> T (T a) (T b) Source #

Run a causal process independently on each stereo channel.

stereoFromMonoControlled :: (Phi a, Phi b, Phi c, Undefined a, Undefined b, Undefined c) => T (c, a) b -> T (c, T a) (T b) Source #

stereoFromMonoParametric :: (C x, Phi a, Undefined a, Phi b, Undefined b) => ((D2 :*: SizeOf (Struct x)) ~ xSize, Natural xSize) => (Exp x -> T a b) -> T (Exp x) -> T (T a) (T b) Source #

comb :: (C a, PseudoRing a) => Exp a -> Exp Word -> MV a a Source #

Delay time must be greater than zero!

combStereo :: (C a, PseudoRing a, T (T a) ~ stereo) => Exp a -> Exp Word -> T stereo stereo Source #

reverbExplicit :: (Natural n, (n :*: UnknownSize) ~ paramSize, Natural paramSize) => (C a, Field a, Real a, IntegerConstant a) => Exp (Array n (a, Word)) -> MV a a Source #

reverbParams :: (RandomGen g, Integer n, Random a) => g -> Proxy n -> (a, a) -> (Word, Word) -> Array n (a, Word) Source #

trigger :: (C a, Undefined b, Phi b) => (Exp a -> T b) -> T (T (T a)) (T b) Source #

trigger fill signal sends signal to the output and restarts it whenever the process input is Just. Before the Arrow.first occurrence of Just and between instances of the signal the output is filled with nothing.

arrayElement :: (C a, Struct a ~ aStruct, IsFirstClass aStruct, Natural i, Natural n, i :<: n) => Proxy i -> T (T (Array n a)) (T a) Source #

Read the i-th element from each array.

vectorize :: (Positive n, C x, T x ~ a, T n x ~ va, C y, T y ~ b, T n y ~ vb) => T a b -> T va vb Source #

pipeline :: (Positive n, C x, v ~ T n x, a ~ T x, Zero v, C v) => T v v -> T a a Source #

This allows to compute a chain of equal processes efficiently, if all of these processes can be bundled in one vectorial process. Applications are an allpass cascade or an FM operator cascade.

The function expects that the vectorial input process works like parallel scalar processes. The different pipeline stages may be controlled by different parameters, but the structure of all pipeline stages must be equal. Our function feeds the input of the pipelined process to the zeroth element of the Vector. The result of processing the i-th element (the i-th channel, so to speak) is fed to the (i+1)-th element. The (n-1)-th element of the vectorial process is emitted as output of the pipelined process.

The pipeline necessarily introduces a delay of (n-1) values. For simplification we extend this to n values delay. If you need to combine the resulting signal from the pipeline with another signal in a zip-like way, you may delay that signal with pipeline id. The first input values in later stages of the pipeline are initialized with zero. If this is not appropriate for your application, then we may add a more sensible initialization.