Pseg/Pfunc and s.latency

Hello,

I have noticed that setting some other parameters using Pseg + Pfunc of external synths from within Patterns do not obey latency. Consider the following code:

( // simple noise synth with low pass filter
SynthDef(\noise, { |ff=100|
	Out.ar(0, LPF.ar(WhiteNoise.ar(0.2)!2, ff))
}).add
)

// synth instance
n = Synth(\noise);
n.set(\ff, 1500) // set filter frequency
n.set(\ff, 100)

( 
s.latency = 0.1;
Pbindef(\latency_test, *[
	instrument:\default,
	legato:0.05,
	decay:0,
	amp:0.3,
	dur:1/2,
	filtfreq: Pseg([100,10000], [4,0], \lin, inf),
	setfiltfreq: Pfunc({|ev| n.set(\ff, ev.filtfreq )})
]).play(quant:2)
)

My expectation was that Pseg with Pfunc would ‘honor’ the latency setting. But this seems to not be the case.

When using latency 0.02 the effect is not noticable, but when I have a lot of processing, 0.02 is too tight and produces “late” messages and it has consequences that can be heard, and I need to raise the latency towards 0.1 when this is then noticable.

Is there a way around this? Is there a way to create an offset with quant for example? I could separate code with Pseg & Pfunc to achieve sync of x.set() of externally running synth (an effect synth) in my composition.

Any help more than appreciated!

1 Like

http://doc.sccode.org/Classes/Server.html#-makeBundle

hjh

2 Likes

thank you, @jamshark70
I should have tried that before asking.

L.

the makeBundle help file also talks about s.bind which already takes into account the set server latency. My above example is then modified simply by wrapping anything within Pfunc into another s.bind{}, like so:

(
SynthDef(\noise, { |ff=100|
	Out.ar(0, LPF.ar(WhiteNoise.ar(0.2)!2, ff) )
}).add
)

// start the synth
n = Synth(\noise, [\ff, 500]);

(
s.latency = 0.4; // try chainging this to 0.2, 0.02...
Pbindef(\latency_test, *[
	instrument:\default,
	legato:0.05,
	decay:0,
	amp:0.3,
	dur:1/2,
	filtfreq: Pseg([500,10000], [4,0], \lin, inf),
	setfiltfreq: Pfunc({|ev|
		s.bind {
			n.set(\ff, ev.filtfreq)
		}
	})
]).play(quant:2)
)

No worries, it’s fine to ask.

One point of confusion is that patterns don’t do anything with or about latency.

The default event prototype does.

So, you use Pbind to stick data into an event, and server messages produced by the event will be sent with latency.

Other messages that you send within Pfunc are outside of the event, hence, no latency.

hjh

1 Like