electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Unchucking has no effect?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
olejorgen



Joined: Apr 09, 2008
Posts: 2
Location: Norway

PostPosted: Wed Apr 09, 2008 11:06 pm    Post subject: Unchucking has no effect? Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6247
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Apr 09, 2008 11:29 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
olejorgen



Joined: Apr 09, 2008
Posts: 2
Location: Norway

PostPosted: Wed Apr 09, 2008 11:45 pm    Post subject: Reply with quote  Mark this post and the followings unread

Done. Seems like I mixed up the order, thanks Smile
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6247
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Apr 09, 2008 11:58 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Stochastic



Joined: Feb 25, 2008
Posts: 20
Location: Vancouver

PostPosted: Thu Apr 10, 2008 1:16 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1166
Location: Florida, USA
Audio files: 50

PostPosted: Thu Apr 10, 2008 1:21 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6247
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Apr 10, 2008 1:40 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6247
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Apr 10, 2008 1:46 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Buy N Save

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com