| Author |
Message |
olejorgen
Joined: Apr 09, 2008 Posts: 2 Location: Norway
|
Posted: Wed Apr 09, 2008 11:06 pm Post subject:
Unchucking has no effect? |
 |
|
| Code: | SndBuf buf => dac;
me.arg(0) => buf.read;
0.5 => buf.gain;
1 => buf.rate;
0 => buf.pos;
while (true) {
20000::ms => now;
<<< "disconnect" >>>;
dac =< buf;
10000::ms => now;
<<< "connect" >>>;
buf => dac;
}
|
disconnect and connect is printed at correct times, but the wav just continues to play.. ? Last edited by olejorgen on Wed Apr 09, 2008 11:44 pm; edited 1 time in total |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6247 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Apr 09, 2008 11:29 pm Post subject:
|
 |
|
Hi, olejorgen!
Could you please re-post this code while turning HTML off? That's the top checkbox below the field where you enter your text, If you don't turn it off the board will get confused by all the triangular brackets and you end up with lines like " dac =<buf> now; " which I'm sure wasn't what you intended.
In the meantime here's a working chuck/unchuck example;
| Code: |
SinOsc lfo => SinOsc s;
500 => lfo.gain;
.5 => lfo.freq;
2 => s.sync;
while(1)
{
s => dac;
second => now;
s =< dac;
second => now;
} |
_________________ while(!machine.crash() ) <<<"all is well">>>; |
|
|
Back to top
|
|
 |
olejorgen
Joined: Apr 09, 2008 Posts: 2 Location: Norway
|
Posted: Wed Apr 09, 2008 11:45 pm Post subject:
|
 |
|
Done. Seems like I mixed up the order, thanks  |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6247 Location: The Hague, NL
G2 patch files: 3
|
Posted: Wed Apr 09, 2008 11:58 pm Post subject:
|
 |
|
Yes, you were disconnecting the dac from the buf, not the buf from the dac.
In ChucK signals flow like you read&write English; from left to right. Your code didn't generate a error because the dac can in fact be connected to modules, for example to make ChucK sample it's own output. Here the dac wasn't connected to any Ugen but that doesn't stop your from trying to unchuck it, that just doesn't do anything but it's not illegal either.
With that fix, one of my own samples and shorter durations (because my sample was just a few seconds) your code worked fine. _________________ while(!machine.crash() ) <<<"all is well">>>; |
|
|
Back to top
|
|
 |
Stochastic

Joined: Feb 25, 2008 Posts: 20 Location: Vancouver
|
Posted: Thu Apr 10, 2008 1:16 am Post subject:
|
 |
|
| would it be a feature consideration for the VM to output a warning that the code is trying to unchuck a non-chucked set of modules? or would that generate too many warning messages for advanced codes? |
|
|
Back to top
|
|
 |
Inventor

Joined: Oct 13, 2007 Posts: 1166 Location: Florida, USA
Audio files: 50
|
Posted: Thu Apr 10, 2008 1:21 am Post subject:
|
 |
|
| Stochastic wrote: | | would it be a feature consideration for the VM to output a warning that the code is trying to unchuck a non-chucked set of modules? or would that generate too many warning messages for advanced codes? |
Such a feature would have helped me debug Guitar Lab and Synth Lab which are constantly ChucKing and unChucking ugens. _________________ @(ºoº)@ ><}}}º> ~(^.^) <:3 )~ |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6247 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Apr 10, 2008 1:40 am Post subject:
|
 |
|
Here you go;
| Code: |
SinOsc lfo => SinOsc s;
500 => lfo.gain;
.5 => lfo.freq;
2 => s.sync;
while(1)
{
//introduce randomness
//so we have something to detect
if(maybe) s => dac;
second => now;
//interesting bit starts here
//(where "interesting" means rather straight forward
//but nearly entirely undocumented :¬) )
if( s.isConnectedTo(dac) ) s =< dac;
else <<<"not connected!">>>;
second => now;
} |
Three cheers for arcane commands and Gmail's search function! (see Ge's reply to Kijjaz on the users mailing list 13/07/2007) _________________ while(!machine.crash() ) <<<"all is well">>>; |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 6247 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Apr 10, 2008 1:46 am Post subject:
|
 |
|
Also note that chucking a ugen to another ugen (or the dac) if it's already connected to it won't do anything. This means you need a second gain to square a signal (chucking it twice to a gain set to multiply won't do since the double connection is ignored) but mostly this is convenient. This means the "maybe" above doesn't need a check. _________________ while(!machine.crash() ) <<<"all is well">>>; |
|
|
Back to top
|
|
 |
|