hsc3-0.20: Haskell SuperCollider
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.Sc3.Ugen.Optimise

Description

Optimisations of Ugen graphs.

Synopsis

Documentation

c_rand :: Random a => Int -> a -> a -> a Source #

Constant form of rand Ugen.

c_irand :: (Num b, RealFrac a, Random a) => Int -> a -> a -> b Source #

Constant form of iRand Ugen.

ugen_optimise_ir_rand :: Ugen -> Ugen Source #

Optimise Ugen graph by re-writing rand and iRand Ugens that have Constant inputs. This, of course, changes the nature of the graph, it is no longer randomised at the server. It's a useful transformation for very large graphs which are being constructed and sent each time the graph is played.

import Sound.Sc3.Ugen.Dot 
let u = sinOsc ar (randId 'a' 220 440) 0 * 0.1
draw (u + ugen_optimise_ir_rand u)

ugen_optimise_const_operator :: Ugen -> Ugen Source #

Optimise Ugen graph by re-writing binary operators with Constant inputs. The standard graph constructors already do this, however subsequent optimisations, ie. ugen_optimise_ir_rand can re-introduce these sub-graphs, and the Plain graph constructors are un-optimised.

let u = constant
u 5 * u 10 == u 50
u 5 ==** u 5 == u 1
u 5 >** u 4 == u 1
u 5 <=** u 5 == u 1
abs (u (-1)) == u 1
u 5 / u 2 == u 2.5
min (u 2) (u 3) == u 2
max (u 1) (u 3) == u 3
let u = lfPulse ar (2 ** randId 'α' (-9) 1) 0 0.5
let u' = ugen_optimise_ir_rand u
draw (mix (mce [u,u',ugen_optimise_const_operator u']))
ugen_optimise_const_operator (Bindings.mulAdd 3 1 0) == 3

mulAddOptimised :: Ugen -> Ugen -> Ugen -> Ugen Source #

Constant optimising MulAdd.

mulAddOptimised (sinOsc ar 440 0) 1 0 == sinOsc ar 440 0
mulAddOptimised (sinOsc ar 440 0) 0.1 0 == sinOsc ar 440 0 * 0.1
mulAddOptimised (sinOsc ar 440 0) 1 1 == sinOsc ar 440 0 + 1
mulAddOptimised (sinOsc ar 440 0) 0.1 1 == mulAdd (sinOsc ar 440 0) 0.1 1