How to trig a buffer with OSC

Hi All ! :slightly_smiling_face:
I have a sound that i want to trig.
I have read in the help, when a condition is false it’s equal to 0 and true equal to 1.
I have done that on a gate and it works to trig an envelope but for trig a buffer it not works i mean the sound is always triged in loop and never stop.
I have an SynthDef:

	   arg out=0, amp=1, sound=0, t_trig=0;
	   var sig;
	   sig =, sound,, t_trig, 0,0,2);, sig);

And my OSC receiver:

   \righthandx ,
        arg msg, time, addr, port;\drums, [\t_trig, msg[1] < -0.80] );

Could someone help me ?
Thanks to all.

I’m assuming you want to play the buffer in its entirety when your right hand dips below -0.8, and then wait until the right hand goes above -0.8, then trigger again when it dips below… in that case you don’t actually need a trigger in your SynthDef but rather to keep track of the incoming OSC values and start a new Synth every time they pass the threshold in the desired direction… something like this should work:

~buffer =, "/path/to/sound.wav");

(\drums, { |out=0, amp=1, bufnum=0|
  var sig =, bufnum,, doneAction: 2);, sig);

var prevPos = 0;\righthandx, { |msg|
  var pos = msg[1];
  if ((prevPos >= -0.8) and: (pos < -0.8)) {
    Synth(\drums, [\bufnum: ~buffer] );
  prevPos = pos;
}, '/right_hand/x');

You can test it locally like this:

NetAddr.localAddr.sendMsg('/right_hand/x', -0.9)
NetAddr.localAddr.sendMsg('/right_hand/x', -0.7)

BTW, it’s good practice to always pass the buffer number into your synth instead of relying on it always being a certain buffer number, helps avoid bugs later.

So Good !
It’s exactly what I need :grinning:
Thanks a lot !