[Newbie] basic LFpulse question

Hi there,
I’m a complete beginner, I’m following Eli Fieldsteel’s tutorials and there’s something bugging about his second example in video 3, I copied his code diligently but I don’t get the two signals alternated on L/R as it should be because of phase shift.
Whatever phase value I use for amp2 doesn’t change much. Here’s my code:

(
SynthDef.new(\pulseTest, {
	|ampHz=4, fund=40, maxPartial=4, width=0.5|
	var amp1, amp2, freq1, freq2, sig1, sig2;
	amp1 = LFPulse.kr (ampHz, 0, 0.12) * 0.75;
	amp2 = LFPulse.kr (ampHz, 0.5, 0.12) * 0.75;
	freq1 = LFNoise0.kr(4).exprange(fund, fund*maxPartial).round(fund);
	freq2 = LFNoise0.kr(4).exprange(fund, fund*maxPartial).round(fund);
	freq1 = freq1 * LFPulse.kr (8, add:1);
	freq2 = freq2 * LFPulse.kr (8, add:1);
	sig1 = Pulse.ar(freq1, width, amp1);
	sig2 = Pulse.ar(freq2, width, amp2);
	sig1 = FreeVerb.ar (sig1, 0.7, 0.8, 0.25);
	sig2 = FreeVerb.ar (sig1, 0.7, 0.8, 0.25);
	Out.ar(0, sig1);
	Out.ar(1, sig2);
}).add;
)

x = Synth.new (\pulseTest);

Thanks in advance to anyone who can take the time for this,

Daniele

if you take out the FreeVerb the signal clearly alternates between L/R.

ah…
there-s a typo here:

sig1 = FreeVerb.ar (sig1, 0.7, 0.8, 0.25);
sig2 = FreeVerb.ar (sig1, 0.7, 0.8, 0.25);

should be:

sig1 = FreeVerb.ar (sig1, 0.7, 0.8, 0.25);
sig2 = FreeVerb.ar (sig2, 0.7, 0.8, 0.25);

As an advise: You can take a look at Multichannel Expansion | SuperCollider 3.14.0 Help which is IMO the single best feature of SuperCollider as it allows to create multiple signals in paralell in an easy manner. E.g. your code could be rewritten via

(
SynthDef.new(\pulseTest, {|ampHz=4, fund=40, maxPartial=4, width=0.5, out=0|
	var sig = Pulse.ar(
		freq: LFNoise0.kr(4!2).exprange(fund, fund*maxPartial).round(fund),
	);
	sig = sig * LFPulse.kr(
		freq: ampHz,
		iphase: [0, 0.5],
		width: 0.12
	) * 0.75;
	sig = FreeVerb.ar(
		in: sig,
		mix: 0.7,
		room: 0.8,
		damp: 0.25,
	);
	Out.ar(out, sig);
}).add;
)

x = Synth(\pulseTest);
x.free;

notice LFNoise0.kr(4!2) and iphase: [0, 0.5] to expand the signal at these places.

Hi Daniele,

Quickly looking at the code from Eli, I think you missed changing one number:

thanks mstep, it’s that! typed in sig2 in the freeverb, all good… thanks a lot!

Agreed with @dscheiba that multichannel expansion makes clean work of this otherwise messy example. This code comes from tutorial 3, but multichannel expansion is covered in tutorial 5. As a learning exercise for my university courses, I will sometimes have students copy this example from T3 and express it more concisely with multichannel expansion.

Also FYI, all of the code for these tutorials is on github, which avoids the need to copy manually (often prone to human error).

Eli

1 Like

Hi Eli, thanks a lot for taking the time to reply and making me aware of the github folder.
Eager to get to tutorial 5 now :smiley: