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

Safe HaskellNone
LanguageHaskell98

Synthesizer.LLVM.Causal.Process

Synopsis

Documentation

class (C process, C (SignalOf process)) => C process where Source

Minimal complete definition

simple, alter, replicateControlled

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

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

Instances

C T Source 
C (T p) Source 

data T a b Source

Instances

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 a, Phi a, C a) => signal a -> process (Value Word32) 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.

foldChunks :: (C process, SignalOf process ~ signal, Undefined b, Phi b) => T a b -> signal a -> process (Value Word32) b Source

The input of the process is a sequence of chunk sizes. The signal is chopped into chunks of these sizes and each chunk is folded using the given initial value and the accumulation function. A trailing incomplete chunk will be ignored.

foldChunksPartial :: (C process, SignalOf process ~ signal, Undefined a, Phi a, Undefined b, Phi b) => T a b -> signal a -> process (Value Word32) b Source

Like foldChunks but an incomplete chunk at the end is treated like a complete one.

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