This is the most simple low pass filter implementation imaginable:
reg lastValueL = 0.0;
reg lastValueR = 0.0;
reg thisCutoff = 0.0;
reg invCutoff = 0.0;
const var Cutoff = Content.addKnob("Cutoff", 0, 0);
// [JSON Cutoff]
Content.setPropertiesFromJSON("Cutoff", {
"min": 0.01,
"max": 0.99,
"middlePosition": 0.1
});
// [/JSON Cutoff]
function prepareToPlay(sampleRate, blockSize)
{
}
function processBlock(channels)
{
thisCutoff = Cutoff.getValue();
invCutoff = 1.0 - thisCutoff;
for(sample in channels[0])
{
sample = thisCutoff * sample + invCutoff * lastValueL;
lastValueL = sample;
}
for(sample in channels[1])
{
sample = thisCutoff * sample + invCutoff * lastValueR;
lastValueR = sample;
}
}
function onControl(number, value)
{
}
However, iterating over every sample and process it is where a weakly typed language like Javascript comes to a performance bottleneck - this example needs about 2% while the CPU usage of native code of the same functionality should be totally neglectible. So for now it's OK to play around with it (and prototype new algorithms), but I wouldn't consider using it in an actual instrument.
I am planning to offer a collection of basic DSP building blocks that can be assembled via scripting (just like REAKTOR or MAX). The basic API is already there, but creating all those little modules will take a while...