class:: TwoTube			
summary::physical modeling simulation; two tubes
related:: Classes/NTube
categories:: UGens>PhysicalModels
//SLUGens released under the GNU GPL as extensions for SuperCollider 3, by Nick Collins, http://composerprogrammer.com/index.html
keyword:: SLUGens


Description::
Physical model; two tube sections with scattering junction inbetween; their relative areas determine k. 

classmethods::

method::ar


argument::input
Excitation to inject into the system
argument::k
Scattering coefficient for junction of two tubes, usually -1<=k<=1
argument::loss
Amplitude loss factor in circulation
argument::d1length
Length in samples of first delay line
argument::d2length
Length in samples of second delay line (no interpolation implemented yet)


Examples::

code::
(
{
var delay1, delay2, source; 

//k from -1 to 1

//in samples
delay1= 100; 
delay2= 40;

source= WhiteNoise.ar(0.5)*EnvGen.ar(Env([1,1,0],[(delay1+delay2)/SampleRate.ir,0.0]), Impulse.kr(MouseY.kr(1,4)));

TwoTube.ar(source,MouseX.kr(-1,1),0.99,delay1,delay2); 
}.play

)




(
SynthDef(\twotube,{arg delay1=100, delay2=50, k=0.0, loss=0.999, dur=0.5, pan=0.0; 
var source; 

//k from -1 to 1

source= WhiteNoise.ar(0.5)*EnvGen.ar(Env([1,1,0,0],[(delay1+delay2)/SampleRate.ir,0.0,1.0]));

Out.ar(0,Pan2.ar(TwoTube.ar(source,k,loss,delay1,delay2)*EnvGen.ar(Env([0,1,1,0],[0.001]++((dur-0.001)*[0.4,0.6])),doneAction:2),pan)); 
}).send(s); 
)



(
t.stop;
t={

inf.do{

Synth(\twotube,[\delay1, rrand(1,300),\delay2, rrand(1,300),\loss, rrand(0.9,0.999),\dur, rrand(0.1,5.0), \pan, rrand(-1,1.0), \k, rrand(-1,1.0)]);

0.5.wait;
};

}.fork;
)
::
