Amplitude send problem

Hello,

I am trying to cross modulate the positions of 2 audio samples.

So channel 1 is sending to an Amplitude and when it goes beyond a certain threshold it changes the position of channel 2 (and retriggers of course). Channel 2 does the same, when it goes beyond a certain peak it changes the sample position of channel 1.
I can easily get one channel to work. The left channel changes the position of the right channel.
But I am having a difficult time figuring out how to do this for both channels. I tried creating 2 synthdefs and sending them to each other. No luck.

Any help is appreciated. Here is the working version of the file in the left speaker changing the file position of the right speaker.

I stopped using max msp years ago but strangely this is something that is done easier in max…first thing I have encountered.

~br4=Buffer.read(s,)

~br3=Buffer.read(s,)

(

{

var sig, amp, gate, trig,sig2;

sig =PlayBuf.ar(2,~br4,BufRateScale.kr(~br4),loop:1);

amp = Amplitude.ar(sig, attackTime:0, releaseTime:0.0002,mul:2);

gate = amp > 0.13;

trig = Trig1.ar(HPZ1.ar(gate),0.001).poll;

sig2 = PlayBuf.ar(2,~br3,BufRateScale.kr(~br3)*1,trig[0],TRand.ar(0,~br3.numFrames,trig[0]),1);

[sig0.3,sig20.3];

}.play

)

The second buffer’s trigger depends on the first buffer player, and the first buffer’s trigger depends on the second buffer player.

That means: in the signal domain, you need feedback. See LocalIn / LocalOut. At the top of the SynthDef, you would read the signal supplying the trigger for the first player (using LocalIn); at the end, send that signal back using LocalOut.

Max can send control messages back to an earlier object arbitrarily but if you try to do feedback with signals, it will need special handling just as it does in SC. You might be assuming that signals in a SynthDef behave like Max control messages. They don’t. In a SynthDef, everything is like a ~ object in Max.

(Edit: Method calls in the language can be recursive, as control messages in Max can be. One difference between SC and Max is that Max signal objects can send control messages, while SC UGens can’t [not directly anyway]. If you’re taking a control domain trigger from a signal object and sending that back to the other player, that’s idiomatic in Max but in SC, it needs to be done entirely in the signal domain. That requires feedback.)

hjh

I got this working.
Let me know if you something worth improving or fixing!
Thanks!
//

~br4=Buffer.read(s,)
~br3=Buffer.read(s,)
(
{
var sig, amp, gate, trig,sig2,twoIn,amp2,gate2,trig2,a;
twoIn=LocalIn.ar(2);

amp2 = Amplitude.ar(twoIn, attackTime:0, releaseTime:0.02,mul:2);
gate2 = amp2 > 0.2;
trig2 = Trig1.ar(HPZ1.ar(gate2),0.001);

sig =PlayBuf.ar(2,~br4,BufRateScale.kr(~br4),trig2[0],TRand.ar(0,~br3.numFrames,trig2[0]).poll(label:\buf1),loop:1);
amp = Amplitude.ar(sig, attackTime:0, releaseTime:0.02,mul:2);
gate = amp > 0.4;
trig = Trig1.ar(HPZ1.ar(gate),0.001);
sig2 = PlayBuf.ar(2,~br3,BufRateScale.kr(~br3)*1,trig[0],TRand.ar(0,~br3.numFrames,trig[0]).poll(label:\buf_2),1);
LocalOut.ar(sig2);
sig=[sig*0.3,sig2*0.3];

}.play
)