[flocking] Can I set the envelope values of an existing synth?

Colin Clark colin at colinclark.org
Sat Apr 16 12:59:04 UTC 2016


Glad to hear you're making progress!

It looks like the error you're getting is related to trying to set an invalid path on your unit generator. Maybe you meant "ampEnv.envelope.levels"? But it's not obvious to the eye, since it looks like Flocking is also throwing an error when trying to log its error message. I'll take a look at that.

However, even if the path was right, you probably can't do what you're attempting. In Flocking, envelopes are intended to be immutable; you can't modify individual elements of the envelope in-place. Instead, you'll need to provide a new envelope specification, like this:

mySynth.set("ampEnv.envelope", {
    durations: [...],
    levels: [...]
});

Let me know if this works for you,

Colin


> On Apr 15, 2016, at 10:38 AM, aBe <abe at hamoid.com> wrote:
> 
> I can now correctly trigger envelopes, by changing the gate value to 1;
> and later to 0, as suggested. I'm happy about that :)
> 
> The next problem I encounter is that I can't set the envelope values
> after the synth has been created. If I do this:
> 
> mySynth.set('ampEnv.levels', [0, 0.2, 0, 0.8, 0.4, 0.8, 0]);
> 
> the whole JavaScript program freezes for 10 seconds (I'm setting 6
> envelope-arrays with ~15 values each) and then I get an error:
> 
> Uncaught RangeError: Invalid string length
> out @ flocking-all.js:12131
> printImpl @ flocking-all.js:12181
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12160
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> printImpl @ flocking-all.js:12177
> fluid.prettyPrintJSON @ flocking-all.js:12200
> flock.pathParseError @ flocking-all.js:20769
> flock.get @ flocking-all.js:20793
> flock.input.setValueForPath @ flocking-all.js:20970
> flock.input.set @ flocking-all.js:21010
> flock.synth.set @ flocking-all.js:21794
> invokeInvoker @ flocking-all.js:13923
> Sound.play @ sound.js:84
> App.mousedown @ main.js:126
> App.handleEvent @ main.js:160
> 
> The envelopes run at audio rate, otherwise the sound is very glitchy.
> 
> 1. Would it help if I disconnect the synth from the audio engine while
> setting the new envelopes?
> 
> 2. Is there an alternative way to change the envelope values one by one,
> for instance something like
> mySynth.set('ampEnv.levels.3', 0.3);
> or
> mySynth.set('ampEnv.levels[3]', 0.3);
> 
> 3. Why does my current attempt to set the values as a new array fail?
> 
> Cheers!
> 
> aBe
> _______________________________________________
> flocking mailing list
> flocking at lists.idrc.ocad.ca
> http://lists.idrc.ocad.ca/mailman/listinfo/flocking



More information about the flocking mailing list