mohayonao / timbre.js

JavaScript library for objective sound programming
http://mohayonao.github.io/timbre.js/
MIT License
963 stars 74 forks source link

Dynamically adjusting ADSR and other parameters #51

Open Gadgetoid opened 8 years ago

Gadgetoid commented 8 years ago

Is there a way to dynamically adjust ADSR or other synth parameters to add expression to notes as they play? I've trawled the documentation and Google and can only find someone who had the same problem as me; being unable to find the answer.

As a simple example, I'll have a synth setup like so with noteOn used to trigger a note:

var env  = T("adsr", {a:50,d:300,s:0,r:200});
var synth = T("OscGen", {fwave:"sin", mul:0.5, env:self.env}).play();

Now, I'd expect the following to work:

synth.set({a:300});

or

synth.set({attackTime:300)}

But it has no effect.

Am I missing something, or is it impossible to adjust the envelope without replacing the entire OscGen object?