DSP Circuit Compiler

DSP circuit compiler for WebAudio/wani. is a program which can read an arithmetic expressions and prints a JavaScript code which creates a WebAudio DSP circuit which works as same as expressions do.

How to use?

Just copy and paste the generated code into your code ;)

Note

Currently, WebAudio API doesn't have AudioParam node constructor, so some of this compiler's function are depends on wani's audioParam emulator (sorry not yet documented. please see code.)

Is it really works?

You can see how the code in above box (at page was loaded) is working when use SimpleTremoro at wani's demo page. Also can see it's source code here.

Is it faster than scriptNode?

I believe so, but not yet benchmarked :P Now looking for good way to calculate and compare the circuit's speed.

Syntax

Supported operators

+ * -

Substitution

connect the right value's output to left value's input

Variable

Non prefixed word name / name.foo
Node name, without constructor. this would be printed as is into generated Javascript code. this means, you need to construct the node with named variable before generated code.
var myOsc = ctx.createOscillator();

// copy of auto generated code
Prefixed by : like :name
look up for existing named node
Prefixed by $ like $name
If used in LeftValue of substitution, it saves the right value. otherwise, it construct the saved value. Note that this function is not optimized, so using this could be a reason to create more audioNodes unnecessarilly.

String

quoted string is string ;) Now it's usable only at passing name parameters to functions.

Number

Number always creates new DC Offset.

Function

of course, funcname(arg1,arg2) is function. (Way to define new function is not supported.) Currently implemented functions are...
audioParam(name,defaultValue)
# create New audioParam named depth.
audioParam("depth", 0.4);

# and then, You can reference it by name with ':' prefix.
output = lfo.gain * :depth;

Comment

From hashmark # to the end on line will be ignored.

JavaScript

From exclamation mark ! to the end of line will be printed as raw JavaScript.

CompileOptions

No options now :)
Fork me on GitHub