How to aply triger to amp and freq?

I try making triger sound some times in synth. (using gate)
and triger affect amp and freq.

arg loop affect sound play times.
if i set loop:3 , i could hear sound 3 times, so triger affect amp.
but freq was changed 1 time.
I expected freq also chnaging 3times.

(


SynthDef("sin", {arg out = 0, amp = 0.3,  sustain = 1, pan = 0 , att=0.01 , freq=1000 , loop=4;
	var crv, envAmp , envFreq , envAll, snd , trig;
	
	trig =  Impulse.ar( loop )  ;

	crv= Env.perc(att, 1/8 - att, amp, curve:8);
	envAmp = EnvGen.ar( crv , gate:trig  );
	envFreq = EnvGen.ar(  Env( [freq,freq*0.1],[  1/8   ]   )  );
	envAll = EnvGen.ar(  Env( [0,1,1,0],[att,sustain-att,0]   ) , doneAction:2  );
	
	snd = SinOsc.ar(freq: envFreq, mul: envAmp);
	snd = snd * envAll;
	snd = Pan2.ar(snd, pan);
	Out.ar(out, snd);
}).add;


Synth( \sin ,[loop:3] ); 


)

envFreq is missing gate: trig.

hjh

I tried , but still freq cha nged 1 time.

1st sound , freq chnaged high to low . This is what i ecpected.
2nd , 3rd sound, keep low freq.
I expect 2nd,3rd sound also freq chnaged high to low .

(


SynthDef("sin", {arg out = 0, amp = 0.3,  sustain = 1, pan = 0 , att=0.01 , freq=1000 , loop=4;
	var crv, envAmp , envFreq , envAll, snd , trig;

	trig =  Impulse.ar( loop )  ;

	crv= Env.perc(att, 1/8 - att, amp, curve:8);
	envAmp = EnvGen.ar( crv , gate:trig  );
	envFreq = EnvGen.ar(  Env( [freq,freq*0.1],[  1/8   ]   ) , gate:trig );
	envAll = EnvGen.ar(  Env( [0,1,1,0],[att,sustain-att,0]   ) , doneAction:2  );

	snd = SinOsc.ar(freq: envFreq, mul: envAmp);
	snd = snd * envAll;
	snd = Pan2.ar(snd, pan);
	Out.ar(out, snd);
}).add;


Synth( \sin ,[loop:3] );


)

This is a very common misconception.

I had written an explanation but the window crashed. So I’ll have to just requote the documentation:

http://doc.sccode.org/Classes/Env.html#examples

NOTE: The starting level for an envelope segment is always the level you are at right now. For example when the gate is released and you jump to the release segment, the level does not jump to the level at the beginning of the release segment, it changes from whatever the current level is to the goal level of the release segment over the specified duration of the release segment.

There is an extra level at the beginning of the envelope to set the initial level. After that each node is a goal level and a duration, so node zero has duration equal to times[0] and goal level equal to levels[1].

TL;DR you need Env([freq, freq, freq * 0.1], [0, 1/8]).

hjh

1 Like

Oh , thank you.
I did not know this .