Beat detect, Tap tempo with Coyote and Timer?

I try to build a dynamic time reference with coyote. In my example I try sync the LFSaw to my tapping on mic. The poll of the rate spits out the right values, but LFSaw seems not to accept them. What am I missing?

cheers Benu!

SynthDef("coyote", {
	arg tresh=0.3;
	var input, trig, sig, rate;

	input = SoundIn.ar(0,1);

	trig = Coyote.kr(input,0.2,0.2,0.01,0.5, tresh,0.01);

	rate = Timer.kr(trig).reciprocal.poll(5);

	sig = LFSaw.ar(rate,0,1,1);


                      Out.ar(0, sig!2); } ).add;
)

x = Synth.new("coyote");
x.free; ```

Syncing the frequency of an oscillator is not guaranteed to sync the phase.

Maybe try a Phasor instead and use the trigger input to reset the waveform upon a tap…?

hjh

It’s only a test set-up, won’t really use LFSaw. On my macbook I start the server with internal soundcard (built in mic). When I tap on the mic I get the correct values on the poll.

Strange is that it doesn’t do anything with LFSaw.ar, although Timer.kr is generation values. If I use Pulse.ar instead of LFSaw.ar it works?

(
SynthDef("coyote", {
	arg tresh=0.3;
	var input, trig, sig, rate;

	input = SoundIn.ar(0,1);

	trig = Coyote.kr(input,0.2,0.2,0.01,0.5, tresh,0.01);

	rate = Timer.kr(trig).reciprocal.poll(5);

	sig = Pulse.ar(rate,1/100,1/50);


                      Out.ar(0, sig!2); } ).add;
)

x = Synth.new("coyote");
x.free;  ```

Can you be specific about the behavior you expect, and the behavior you’re getting?

“it doesn’t do anything with LFSaw.ar” – this could mean any of several things, and I have no idea which of them it actually is. (What I mean is – LFSaw’s frequency input is definitely modulatable – so it seems unlikely to me that it’s playing a fixed frequency. So I guess it’s something else – maybe you’re expecting the pulses to be in sync with your taps – but based on the available information, I can’t guess what you’re seeing. Needs more detail.)

hjh

Pulse.ar makes sound (clicks) according to rate (poll of Timer.reciprocal)

LFSaw.ar is mute

With Impulse.ar mute as well

After trying your synth – the problem is that ‘rate’ is initially not-a-number – that is, you aren’t controlling the range of values going into reciprocal0.reciprocal is not safe.

a = {
	var trig = Impulse.kr(0);
	Poll.kr(trig, DC.kr(0).reciprocal);
	FreeSelf.kr(trig <= 0);
	Silent.ar(1)
}.play;

UGen(UnaryOpUGen): -nan  // <<-- here is your problem

It seems that LFSaw can’t recover from NaN at the input, while Pulse can. But, FWIW, I don’t think that’s necessarily a bug in LFSaw because putting NaN into a UGen is usually a bad idea – your SynthDef should take care to avoid this.

(
SynthDef("coyote", {
	arg tresh=0.3;
	var input, trig, sig, rate;
	
	input = SoundIn.ar(0,1);
	trig = Coyote.kr(input,0.2,0.2,0.01,0.5, tresh,0.01);
	rate = Timer.kr(trig).clip(0.01, 100).reciprocal.poll(5);
	sig = LFSaw.ar(rate,0,0.1);
	Out.ar(0, sig!2);
}).add;
)

x = Synth.new("coyote");
x.free;

hjh