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

Safe HaskellNone
LanguageHaskell98

Synthesizer.LLVM.Causal.Process

Synopsis

Documentation

class C process => C process where Source

Methods

simple :: C state => (forall r c. Phi c => a -> state -> T r c (b, state)) -> (forall r. CodeGenFunction r state) -> process a b Source

alter :: (forall context initState exitState. Core context initState exitState a0 b0 -> Core context initState exitState a1 b1) -> process a0 b0 -> process a1 b1 Source

replicateControlled :: (Undefined x, Phi x) => Int -> process (c, x) x -> process (c, x) x Source

Instances

C T 
C (T p) 

data T a b Source

Instances

Arrow T 
C T 
C T 
Category * T 
Functor (T a) 
Applicative (T a) 
(Field b, Real b, RationalConstant b) => Fractional (T a b) 
(PseudoRing b, Real b, IntegerConstant b) => Num (T a b) 
(Field b, RationalConstant b) => C (T a b) 
(PseudoRing b, IntegerConstant b) => C (T a b) 
Additive b => C (T a b) 
type SignalOf T = T 

data Core context initState exitState a b Source

Constructors

forall state . C state => Core (forall r c. Phi c => context -> a -> state -> T r c (b, state)) (forall r. initState -> CodeGenFunction r state) (state -> exitState) 

alterSignal :: (C process, SignalOf process ~ signal) => (forall context initState exitState. Core context initState exitState a0 -> Core context initState exitState a1 b1) -> signal a0 -> process a1 b1 Source

amplify :: (C process, IsArithmetic a, IsConst a) => a -> process (Value a) (Value a) Source

amplifyStereo :: (C process, IsArithmetic a, IsConst a) => a -> process (T (Value a)) (T (Value a)) Source

apply :: T a b -> T a -> T b Source

applyFst :: T (a, b) c -> T a -> T b c Source

applySnd :: T (a, b) c -> T b -> T a c Source

applyConst :: (MakeValueTuple a, ValueTuple a ~ al) => T al b -> a -> T b Source

applyConstFst :: (MakeValueTuple a, ValueTuple a ~ al) => T (al, b) c -> a -> T b c Source

applyConstSnd :: (MakeValueTuple b, ValueTuple b ~ bl) => T (a, bl) c -> b -> T a c Source

($<) :: 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, Storable ah, MakeValueTuple ah, ValueTuple ah ~ a, C a) => process (a, b) c -> ah -> process b c infixl 0 Source

($>#) :: (C process, Storable bh, MakeValueTuple bh, ValueTuple bh ~ b, C b) => process (a, b) c -> bh -> process a c infixl 0 Source

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

provide constant input in a comfortable way

feedFst :: T a -> T b (a, b) Source

feedSnd :: T a -> T b (b, a) Source

feedConstFst :: (MakeValueTuple a, ValueTuple a ~ al) => a -> T b (al, b) Source

feedConstSnd :: (MakeValueTuple a, ValueTuple a ~ al) => a -> T b (b, al) Source

first :: C process => process b c -> process (b, d) (c, d) Source

envelope :: (C process, PseudoRing a) => process (a, a) a Source

You may also use '(*)'.

envelopeStereo :: (C process, PseudoRing a) => process (a, T a) (T a) Source

fromModifier :: C process => (Flatten ah, Registers ah ~ al, Flatten bh, Registers bh ~ bl, Flatten ch, Registers ch ~ cl, Flatten sh, Registers sh ~ sl, C sl) => Simple sh ch ah bh -> process (cl, al) bl Source

fromSignal :: T b -> T a b Source

toSignal :: T () a -> T a Source

loopConst :: (C process, C c) => c -> process (a, c) (b, c) -> process a b Source

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

Like loop but uses zero as initial value and it does not need a zero as Haskell value.

delay1Zero :: (C process, Additive a, C a) => process a a Source

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

map :: C process => (forall r. a -> CodeGenFunction r b) -> process a b Source

mapAccum :: (C process, C state) => (forall r. a -> state -> CodeGenFunction r (b, state)) -> (forall r. CodeGenFunction r state) -> process a b Source

zipWith :: C process => (forall r. a -> b -> CodeGenFunction r c) -> process (a, b) c Source

mapProc :: C process => (forall r. b -> CodeGenFunction r c) -> process a b -> process a c Source

zipProcWith :: C process => (forall r. b -> c -> CodeGenFunction r d) -> process a b -> process a c -> process a d Source

mix :: (C process, Additive a) => process (a, a) a Source

You may also use '(+)'.

pipeline :: (C process, Positive n, C x, v ~ T n x, a ~ T x, Zero v, C v) => process v v -> process 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.

stereoFromVector :: (C process, IsPrimitive a, IsPrimitive b) => process (Value (Vector D2 a)) (Value (Vector D2 b)) -> process (T (Value a)) (T (Value b)) Source

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

replaceChannel :: (C process, Positive n, C x, T x ~ a, T n x ~ va, C y, T y ~ b, T n y ~ vb) => Int -> process a b -> process va vb -> process va vb Source

Given a vector process, replace the i-th output by output that is generated by a scalar process from the i-th input.

arrayElement :: (C process, IsFirstClass a, Natural index, Natural dim, index :<: dim) => Proxy index -> process (Value (Array dim a)) (Value a) Source

Read the i-th element from each array.

element :: (C process, IsFirstClass a, GetValue agg index, ValueType agg index ~ a) => index -> process (Value agg) (Value a) Source

Read the i-th element from an aggregate type.

osciCoreSync :: (C process, C t, Fraction t) => process (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 process, C t, Fraction t) => process (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 process, C t, Fraction t) => (forall r. t -> CodeGenFunction r y) -> process (t, t) y Source

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

skip :: (C process, SignalOf process ~ signal, Undefined v, Phi v, C v) => signal v -> process (Value Word32) v 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 process, SignalOf process ~ signal, IntegerConstant a, IsFloating a, CmpRet a, CmpResult a ~ Bool, FirstClass a, Stored a ~ am, IsSized am, Undefined nodes, Phi nodes, C nodes) => (forall r. Value a -> nodes -> CodeGenFunction r v) -> signal nodes -> process (Value a) v Source

interpolateConstant :: (C process, SignalOf process ~ signal, C a, FirstClass b, Stored b ~ bm, IsSized bm, IntegerConstant b, IsFloating b, CmpRet b, CmpResult b ~ Bool) => signal a -> process (Value b) a Source

Stretch signal in time by a time-varying factor.

quantizeLift :: (C process, C b, IntegerConstant c, IsFloating c, CmpRet c, CmpResult c ~ Bool, FirstClass c, Stored c ~ cm, IsSized cm) => process a b -> process (Value c, a) b Source

applyStorable :: (Storable a, MakeValueTuple a, ValueTuple a ~ valueA, C valueA, Storable b, MakeValueTuple b, ValueTuple b ~ valueB, C valueB) => T valueA valueB -> Vector a -> Vector b Source

applyStorableChunky :: (Storable a, MakeValueTuple a, ValueTuple a ~ valueA, C valueA, Storable b, MakeValueTuple b, ValueTuple b ~ valueB, C valueB) => T valueA valueB -> Vector a -> Vector b Source

runStorableChunky :: (Storable a, MakeValueTuple a, ValueTuple a ~ valueA, C valueA, Storable b, MakeValueTuple b, ValueTuple b ~ valueB, C valueB) => T valueA valueB -> IO (Vector a -> Vector b) Source

Deprecated: this function will not work when the process itself depends on a lazy storable vector

This function will not work as expected, since feeding a lazy storable vector to the causal process means that createIOContext creates a StablePtr to an IORef refering to a chunk list. The IORef will be created once for all uses of the generated function of type (SVL.Vector a -> SVL.Vector b). This means that the pointer into the chunks list will conflict. An alternative would be to create the StablePtr in a foreign function that calls back to Haskell. But this way is disallowed for foreign finalizers.