# Trigger Impulse and clocks

hey, i boiled down a big chunk of code to this problem and quite happy i was able to isolate the issue:

when the Pmono is played on the clock, only every other trigger comes trough as sound.
Why is that? Its working when using `\trig.tr(1)` instead of `Impulse.ar` and `\tFreq.kr(1)` but then the trigger modulation doesnt work. any suggestions?

``````(
SynthDef(\test, {

var tFreqMod = LFDNoise3.ar(\tFreqMF.kr(15)).linlin(-1, 1, 0, \tFreqModAmount.kr(5));
var tFreq = \tFreq.kr(1) + tFreqMod;
var trig = Impulse.ar(tFreq);

var sig = SinOsc.ar(\freq.kr(440));
var env = EnvGen.ar(Env.perc(\atk.kr(0.01), \rel.kr(0.1)), trig);

sig = sig * env;

sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
OffsetOut.ar(\out.kr(0), sig);
)

t = TempoClock.new(120/60).permanent_(true);

(
Pdef(\test,
Pmono(\test,

\dur, Pseq([3, 2, 1, 1], inf).trace,
\tFreq, Pfunc{ |ev| ev[\dur].reciprocal },

\freq, 440,
\tFreqMF, 15,
\tFreqModAmount, 0, // modulate triggers

\amp, 0.5,
),
).play(t, quant:1); // try without (t, quant:1)
)
``````

I think it has to do with ev[\dur].reciprocal. A \dur value of 3 at bps = 2 (like your example), triggers every 1.5 seconds. Impulse.ar(1/3) triggers every 3 seconds. Try multiplying the reciprocal value with 2 and it will fire every time. I am not quite sure what exactly you are trying to accomplish, In a sense you are doing the same thing twice. I think the more logical way of approaching it would be to let the Pbind control all the triggering so that one value sent from the the Pbind results in one trigger inside the SynthDef instead, but maybe I am misunderstanding what you are after:

``````(
SynthDef(\test, {
var sig = SinOsc.ar(\freq.kr(440));
var env = EnvGen.ar(Env.perc(\atk.kr(0.01), \rel.kr(0.1)), \t_trig.kr(1));

sig = sig * env;

sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
OffsetOut.ar(\out.kr(0), sig);
)

t = TempoClock.new(120/60).permanent_(true);

(
Pdef(\test,
Pmono(\test,

\dur, Pseq([3, 2, 1, 1], inf); // write all you triggering here, can be modulated with ie. Pwhite
\t_trig, 1, // sends a single trigger
\freq, 440,
\amp, 0.5,
),
).play(t, quant:1); // try without (t, quant:1)
)
``````

hey, thanks for your explanation. I know that you can use `\trig.tr(1)` or `t_trig` as you have been doing and get rid of the `Impulse.ar` and everything is fine with the example above. But its nice to modulate the triggers of for example `GrainBuf` with an LFO to move from rhythm to pitch (like i have implemented in my initial example).

In general i want to generate the rhythms via patterns but be able to modulate the triggers for pitched values. I guess both of these concepts are not working together. i have no idea how to go about that.

Ive checked out all the Buffer Granulation Tutorials, recursive Phrasing and Demand Rate Ugens i dont know what works best here. Another option would be to use Pseg but i think modulating the triggers with free running LFOs like LFNoise, Gendy etc. and be able to disable the modulation by setting `\tFreqModAmount.kr` to 0 is more flexible. But i think Pseg would probably the go to choice then.

thanks alot 