Controlling FX Synth with event type \set

This week I’m trying some strategies for composing a piece which develops over time without me having to give too much input - mostly using a few Psegs to change parameters over a longer period of time. At the moment I’m having trouble getting an FX Synth to play nicely with this idea.

                                                                                                    
SynthDef(\a, {
       var sig, env;
       
    
       env = Env.new([0, 1, 0], [\atk.kr(7), \rel.kr(7)], \sine);
       env = EnvGen.ar(env, doneAction: 2);
       sig = SinOsc.ar(\freq.kr(110)) * \index.kr(3) * Line.kr(1.5, 1, \atk.kr(7) + \rel.kr(7));
       sig = sig + VarSaw.ar(\freq.kr(110), 0, LFNoise2.kr(0.2).range(0.1, 0.9));
       sig = sig * RLPF.ar(sig, 1000 * LFNoise2.kr(1).exprange(1, 5));
       sig = sig.tanh;
       sig = sig * env * \amp.kr(0.2);
       sig = Pan2.ar(sig, \pan.kr(0));
       sig = LeakDC.ar(sig);   
       Out.ar(\out.kr(0), sig);
).add;


                
SynthDef(\aFx, {     
       var sig, wet;

       sig = In.ar(\in.kr(0), 2);
       wet = sig;
       wet = wet + Pan2.ar(CombC.ar(wet, 2, 0.5) * \delayAmp0.kr(0), -0.5);
       wet = wet + Pan2.ar(CombC.ar(wet, 2, 0.5) * \delayAmp1.kr(0), 0.75);
       wet = wet + NHHall.ar(wet);
       wet = Limiter.ar(wet);
       sig = XFade2.ar(sig, wet, \mix.kr(0));
       ReplaceOut.ar(\out.kr(0), sig);


).add;

x = Synth.tail(s, \aFx);
(
Pdef(\a, 
        Pbind(
                \instrument, \a,
                \dur, Pseg([0.001, 2.5], [380], \exp, 1),
                \freq, 110 * Pseq([
                        Prand([1, 9/8, 3/2], 18), 
                        Prand([1, 9/8, 3/2, 3/4, 1/2], 24), 
                        Prand([1, 9/8, 3/2, 9/4, 2, 4/3, 3/4, 1/2], 36), 
                        Prand([1, 9/8, 3/2, 9/4, 2, 4/3, 3/4, 1/2, 3, 0.25, 9/2, 4, 8/3], 480)
                        
                ].mirror, inf),
                \pan, Pseq([-1, 1], inf),
                \amp, 0.2,
                \atk, Pseg([0.001, 0.1, 7, 9], [200, 80, 100], \exp, 1),
                \rel, Pkey(\atk),
                \index, Pwhite(1, 7),

        );
).play;
)
(
Pdef(\aFx, 
        Pbind(
                
                \type, \set,
                \id, x.nodeID,
                \args, #[\mix, \delayAmp0, \delayAmp1],
                \mix, Pseg([0, 0.75, 0.4], [190, 190], \sine, 1),
                \delayAmp0, Pseg([0, 1], 380, \sine),
                \delayAmp1, Pseg([0, 0.5], [380], \sine)
                ) 
        
).play;
)

At the moment the FX Synth ‘works’ but for some reason the values aren’t changing over time as I’d hoped. Is there some kind of obvious oversight here? Or is what I’m trying to do harder than I’d thought?

Cheers,
Jordan

Hello,
your code works for me, if I add } before ).add; at the end of both SynthDefs.
Maybe the problem comes from the crossfade position in XFade2 which as to be in between -1 and 1 (not 0 and 1).

I add this: \mix.kr(0).linlin(0, 1, -1, 1) and a HPF on dry sig in your \aFx SynthDef in order to demonstrate:

(
SynthDef(\a, {
	var sig, env;
	env = Env.new([0, 1, 0], [\atk.kr(7), \rel.kr(7)], \sine);
	env = EnvGen.ar(env, doneAction: 2);
	sig = SinOsc.ar(\freq.kr(110)) * \index.kr(3) * Line.kr(1.5, 1, \atk.kr(7) + \rel.kr(7));
	sig = sig + VarSaw.ar(\freq.kr(110), 0, LFNoise2.kr(0.2).range(0.1, 0.9));
	sig = sig * RLPF.ar(sig, 1000 * LFNoise2.kr(1).exprange(1, 5));
	sig = sig.tanh;
	sig = sig * env * \amp.kr(0.2);
	sig = Pan2.ar(sig, \pan.kr(0));
	sig = LeakDC.ar(sig);   
	Out.ar(\out.kr(0), sig);
}).add;

SynthDef(\aFx, {     
	var sig, wet;
	sig = In.ar(\in.kr(0), 2);
	wet = sig;
	wet = wet + Pan2.ar(CombC.ar(wet, 2, 0.5) * \delayAmp0.kr(0), -0.5);
	wet = wet + Pan2.ar(CombC.ar(wet, 2, 0.5) * \delayAmp1.kr(0), 0.75);
	wet = wet + NHHall.ar(wet);
	wet = Limiter.ar(wet);
	sig = XFade2.ar(HPF.ar(sig, 2000), wet, \mix.kr(0).linlin(0, 1, -1, 1));
	ReplaceOut.ar(\out.kr(0), sig);
}).add;

x = Synth.tail(s, \aFx);
)
(
Pdef(\a, 
	Pbind(
		\instrument, \a,
		\dur, Pseg([0.001, 2.5], [380], \exp, 1),
		\freq, 110 * Pseq([
			Prand([1, 9/8, 3/2], 18), 
			Prand([1, 9/8, 3/2, 3/4, 1/2], 24), 
			Prand([1, 9/8, 3/2, 9/4, 2, 4/3, 3/4, 1/2], 36), 
			Prand([1, 9/8, 3/2, 9/4, 2, 4/3, 3/4, 1/2, 3, 0.25, 9/2, 4, 8/3], 480)
			
		].mirror, inf),
		\pan, Pseq([-1, 1], inf),
		\amp, 0.2,
		\atk, Pseg([0.001, 0.1, 7, 9], [200, 80, 100], \exp, 1),
		\rel, Pkey(\atk),
		\index, Pwhite(1, 7)
	);
).play;
)
(
Pdef(\aFx, 
	Pbind(
		
		\type, \set,
		\id, x.nodeID,
		\args, #[\mix, \delayAmp0, \delayAmp1, \in],
		\mix, Pseg([0, 0.75, 0], [19, 9], \sine, 1).trace(prefix: "mix: "),
		\delayAmp0, Pseg([0, 1], 380, \sine),
		\delayAmp1, Pseg([0, 0.5], [380], \sine)
	) 
	
).play;
)

I hope that helps

1 Like

Hey thanks, I think I copy+pasted badly, the {} are in the original code but somehow not here, whoops…

Thanks for your help, the .linlin is definitely the solution!

Small question: where to find the NHHall UGen ?

It’s in sc3 plugins.