Using envelope for spatialization


#1

How can I use the envelope of my synth to control a transform action (RTT, for example) in the Ambisonic Toolkit?
For example:

SynthDef.new(\waveGenerator, {

	| out = 0, t_trig = 0, attack = 3, decay = 2, amp = 0.8, freqfactor = 0.75, doneAction = 2 |
	var sig;

	~waveEnv = EnvGen.ar(Env.perc(attack, decay), t_trig, doneAction: doneAction);

	// Mix pink and brown noise for wave signal
	sig = (PinkNoise.ar(1) * freqfactor) + (BrownNoise.ar(EnvGen.kr(Env.new([0.2, 1, 0], [attack, decay], [1, -1]))) * (1 - freqfactor));

	// Apply envelope
	sig = amp * sig * ~waveEnv;
	sig = sig * 0.3;

	Out.ar(out, sig);

}).add;

I tried to pass ~waveEnv to the transform action (FoaRTT(sig, ~waveEnv, 0, 0)), which didn’t work out.
You can find my code repository on GitHub.