Envelopeにてgate=0でreleaseを作動させるには、SynthDefのargにgateを設定し、なおかつEnvGenにgateを渡す必要がある。これを怠ると、当然ながら.set(\gate,0)
と実行しても音は止まない。
doneAction:2
と設定していると、gateを0にしreleaseが終わったタイミングで、実行したSynthがGroupeから消える。なので、再び実行するときはSynthをServerにnewなりnewPausedなりする必要がある。
gate
This triggers the envelope and holds it open while > 0. If the Env is fixed-length (e.g. Env.linen, Env.perc), the gate argument is used as a simple trigger. If it is an sustaining envelope (e.g. Env.adsr, Env.asr), the envelope is held open until the gate becomes 0, at which point is released. If gate < 0, force release with time -1.0 - gate. See EnvGen: Forced%20release example.
作ったコード
(s.meter(0,2); s.plotTree; ) (SynthDef(\tri, {|out=0,gate=1,amp=0.1,freq=440| var sig,e,eg; e = Env.adsr(attackTime:1,decayTime:3,sustainLevel:0.5,releaseTime:3,peakLevel:1,curve:-8); eg = EnvGen.kr(e,gate,amp,0,1,2); sig = LFTri.ar(freq); sig = sig * eg; Out.ar(out,sig); } ).add; ) ~x = Synth(\tri,[\freq,500]); ~x.set(\gate,0);