electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  EdisonRex Edison's Electronic Review
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Blocked Shreds?!?! What does this mean?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [18 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Tue Feb 27, 2007 10:11 am    Post subject:  Blocked Shreds?!?! What does this mean?
Subject description: MIDI control in this program seems to f%cK with my ChucK
Reply with quote  Mark this post and the followings unread

So I'm pretty excited to do this gig on a local radio station this weekend. I really want to use chuck for some sampling and messing around. I've started to write this program:

Code:


// here we go MIDI implementation
//jack ryon 2007

SndBuf samp1 => Echo echo1 => dac;
"/andyloops/dnb/DN078B~1.WAV" => samp1.read;
10::second => echo1.max;
0 => echo1.mix;
1 => samp1.loop;
0 => samp1.play;
2 => samp1.interp;

float playrate;

MidiIn min1;
MidiMsg msg1;
min1.open(2) => int minopen1;
if(!minopen1) me.exit();

MidiIn min2;
MidiMsg msg2;
min2.open(1) => int minopen2;
if(!minopen2) me.exit();

while(true)
{
   //-------------CONTROLS FOR OXYGEN8 KEYBOARD--------------//

   min1 => now;
   while(min1.recv(msg1))
   {
      <<<msg1.data1,msg1.data2,msg1.data3,"MIDI OXY!">>>;
      
      //----sample playback rate (MOD CTRL ON OXYGEN)----//
      
      if(msg1.data1 == 176)
      {
         if(msg1.data2 == 1)
         {
            64.0 => float ratediv;
            (msg1.data3/ratediv) - 1.0 => samp1.rate;
            samp1.rate() => playrate;
            <<<(msg1.data3/ratediv) - 1, "playback rate">>>;
         }
      }
         
      //----TURN OFF PLAYING SAMPLE (MID C ON OXY8)----//
   
      if(msg1.data1 == 144)
      {
         if(msg1.data2 == 60)
         {
            if(msg1.data3 != 0)
            {
               0 => samp1.play;
            }
         }               
      }
   }

   //-------------CONTROLS FOR FCB1010 FOOTSWITCHER-------------//
   
   min2 => now;
   while(min2.recv(msg2))
   {
      <<<msg2.data1, msg2.data2, msg2.data3, "MIDI 1010!">>>;
   }
}



I can compile this, but after moving one MIDI control knob, the program freezes. When I query chuck [chuck ^] it tells me that the shred has been blocked. What does this mean? What can I do to get this thing up and running? Is there a more efficient way to write this (if that is what my problem is)?

Help?

jack Shocked
Back to top
View user's profile Send private message
spencer



Joined: Aug 16, 2006
Posts: 53
Location: northern california

PostPosted: Wed Feb 28, 2007 12:08 pm    Post subject: Reply with quote  Mark this post and the followings unread

hey jack,
I think your problem here is that you are running the code for your two MIDI controllers alternating in sequence, when you probably want to be running them in parallel. To do this, you have to separate the code for the two controllers into two functions, one for each controller, and then spork those functions into new shreds. See below for a short outline. You can still access all of your ugens and variables from within the functions, so you can pretty much just copy and paste your current code into the function bodies without too much editing.

Itd definitely be worth reading the relevant portions of the language specification, also:
http://chuck.cs.princeton.edu/doc/language/func.html
http://chuck.cs.princeton.edu/doc/language/spork.html

Code:
// setup variables, ugens, patches, etc. here

spork ~ oxygen8();
spork ~ fcb1010();

// this is needed to keep the current shred from exiting.
// if the current shred exits, it takes down all the shreds it sporked with it
while( true )
    1::day => now;

fun void oxygen8()
{
   // oxygen8 code goes here
}

fun void fcb1010()
{
  // fcb1010 code goes here
}
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Thu Mar 01, 2007 12:13 am    Post subject: Reply with quote  Mark this post and the followings unread

Jack, will you be recording this "sampling and messing around"? Or maybe this station has a online presence?

"crash & burn", if I remember corectly they say that in this movie called "robojox" for good luck. Wink

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Thu Mar 01, 2007 10:19 am    Post subject: Reply with quote  Mark this post and the followings unread

I think it will be webcast from www.wdst.com. That's the woodstock radio station. And this just in....

the gig got moved to the following weekend March 10th. So log on if you'd like to check it out. Time TBA.

I'm glad I've got an extra week to put something together in ChucK. I sure need the practice!

Thanks for the help Spencer.

Jack

BTW- I might use Chuck to program some pieces of an art installation for a rather large public piece that's coming up. If I get the gig, I'll be sure to fill y'all in. I can't divulge anything yet, but it seems like it's going to be totally amazing.
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


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

PostPosted: Thu Mar 01, 2007 12:02 pm    Post subject: Reply with quote  Mark this post and the followings unread

I think I have to play on the 10th myself.

...90% ChucK, of cource. Not all finished yet, of cource Smile

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Thu Mar 01, 2007 1:45 pm    Post subject: Reply with quote  Mark this post and the followings unread

but i'm in the states....

so you might be done when I'm shreduled to start my sporkin' gig.

I think it'll get recorded anyway.

I'd like to hear what kinda chucKles you're doing live Very Happy

any Mp3's of your stuff?

you can hear some of my music @ www.myspace.com/sirhoney.

jack
Back to top
View user's profile Send private message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Thu Mar 01, 2007 1:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

spencer,

I thought I had been a good chuck student by reading the whole manual that is distributed with the chuck download. I didn't know about all the online stuff (lang. specif.). It seems like the online references are a bit richer in content, too. Maybe the manual should be updated to include the material that is posted on the web?
just a suggestion.

thanks anyhow,
jack
Back to top
View user's profile Send private message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Thu Mar 01, 2007 7:52 pm    Post subject: aaarrghh!!! Reply with quote  Mark this post and the followings unread

I've gotten a bit further with this project. But, even after following spencer's advice and reading the doc, I can't this thing to work properly.

I'm still getting blocked shreds.

Here's the code:

Code:

// here we go MIDI implementation
//jack ryon 2007

//-----------GLOBAL PARAMETERS/UGENS/ETC.----------//

SndBuf s => dac;

spork ~ oxygen();
spork ~ fcb();

while(true) 1::day => now;

//----------------OXYGEN 8 FUNCTION---------------//

fun void oxygen()
{
   MidiIn min1;
   MidiMsg msg1;
   if(!min1.open(2)) me.exit();
   min1 => now;
   while(min1.recv(msg1))
   {
      <<<msg1.data1,msg1.data2,msg1.data3,"OXYGEN8">>>;
   }
}
   
//--------------FCB1010 FUNCTION----------------//

fun void fcb()
{
   MidiIn min2;
   MidiMsg msg2;
   if(!min2.open(1)) me.exit();      
   min2 => now;
   while(min2.recv(msg2))
   {
      <<<msg2.data1,msg2.data2,msg2.data3,"FCB1010">>>;
   }
}


when I run this, I actually get the desired 3 shreds up and running. But again when queried, tell me that they've been blocked by the VM.

Code:

[chuck](VM): sporking incoming shred: 1 (rev.ck)...
[chuck](VM): status (now == 0h1m6s, 2940672.0 samps) ...
    [shred id]: 1  [source]: rev.ck  [spork time]: 10.44s ago
    [shred id]: 2  [source]: spork~exp  [spork time]: 10.44s ago (blocked)
    [shred id]: 3  [source]: spork~exp  [spork time]: 10.44s ago (blocked)


what's even more frustrating, is the fact that precisely 1 MIDI message is sent from my controller and registers in chuck.

Code:

176 16 65 OXYGEN8
192 6 0 FCB1010


then if I query chuck again, the child shreds have disappeared, and only the parent is present.

what is wrong here?
thanks for any input,

jack Confused
Back to top
View user's profile Send private message
moudi



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Fri Mar 02, 2007 1:37 am    Post subject: Reply with quote  Mark this post and the followings unread

hi jack

the sporked function just finishes after receiving the first message, because there is no endless loop for the receiver.
the code needs to look like the following.
Code:
fun void oxygen()
{
   MidiIn min1;
   MidiMsg msg1;
   if(!min1.open(2)) me.exit();
   while(true)
   {
     min1 => now;
     while(min1.recv(msg1))
     {
        <<<msg1>>>;
     }
   }
}

notice the endless loop starting before the wait for a next event.

i just started with my daily work at office. i will post my personal midi implementation when i return in the evening...

jassas
/moudi
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


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

PostPosted: Fri Mar 02, 2007 5:54 am    Post subject: Reply with quote  Mark this post and the followings unread

sir honey wrote:

I think it'll get recorded anyway.


Cool!

Quote:
I'd like to hear what kinda chucKles you're doing live Very Happy

any Mp3's of your stuff?


I didn't record any of my ChucK stuff yet; there didn't seem much of a point yet (but this"ll change!)

Here's some previews of my last record thingy
http://clone.nl/item6736.html

It's kinda acoustical-inspirered but nearly all of it is pure electronics.


I'll check out your tracks later today; now I have to go on a expedition for some strange ingredients that are only to be found in a asian supermarket Smile

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Fri Mar 02, 2007 5:57 am    Post subject: Reply with quote  Mark this post and the followings unread

oh yeah,

I had the endless loop in previous incarnations of this program. I become sort of blind to these subtle differences when
a) I become slightly frustrated,
and
b) up against a deadline.
I thank you for your help, hope to be able to return the favor once I get a little more programming experience!

best,
jack

I'd sure like to see your MIDI program, just for the sake of comparison.
cheers.
Back to top
View user's profile Send private message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Fri Mar 02, 2007 6:02 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen,

what're you cooking?

I'll make empeethrees of the gig and share, provided everything goes relatively well.

It's going to be an ambient set. I play saxophone and electronics, and I'm joining a rock band called Mercury Rev. They're great.

enjoy!
jack
Back to top
View user's profile Send private message
spencer



Joined: Aug 16, 2006
Posts: 53
Location: northern california

PostPosted: Fri Mar 02, 2007 8:24 am    Post subject: Reply with quote  Mark this post and the followings unread

Jack/all,
With regards to the manual and documentation in general, lack of documentation is definitely one of the major weak points of ChucK right now. I think in general the web page is slightly more up-to-date, but some parts (specifically the UGen page) need some serious fixing. Anyways documentation is at the "working on it right now" priority level, and we plan to have it in decent shape before the upcoming release.

Shreds that are "blocked" by the VM are by no means a bad thing. A "blocked" shred is just a shred that is waiting on an event (e.g. input from MIDI, HID, OSC, etc.). (The term is a holdover from operating system design, where being "blocked" does in fact have a negative connotation.)

Also, sounds awesome about the gig. Definitely post some mp3s!

spencer
Back to top
View user's profile Send private message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Fri Mar 02, 2007 2:06 pm    Post subject: Reply with quote  Mark this post and the followings unread

thanks spencer.

I figured out that [blocked] shreds were not my problem when I eventually fixed the infinite loop problem I was having (courtesy of moudi).

Better doc would certainly help those of us (hmm hmm) who are lacking in real programming expertise.

Very Happy
jack
Back to top
View user's profile Send private message
moudi



Joined: Oct 07, 2006
Posts: 63
Location: Bern Switzerland

PostPosted: Sat Mar 03, 2007 12:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

sir honey wrote:
I'd sure like to see your MIDI program, just for the sake of comparison.
cheers.

ok, here we go...
the implementation is especially for my old PocketControl http://www.doepfer.de/pc.htm and i mostly use it for controlling volume of different shreds.

in generally, i made a public class with static variables to hold the values sent by the device. the watcher is running the whole time, captures the data and writes the values to the static variables.

to make use of them, you only need to write something like this in your shred:
Code:
 ... => Gain g => dac;
//add this wherever you want to set the volume
g.gain(PocketC.Vol01);

any thoughts about it?

regards
/moudi


PocketC.ck
 Description:

Download
 Filename:  PocketC.ck
 Filesize:  1.24 KB
 Downloaded:  161 Time(s)


PocketC_Watcher.ck
 Description:

Download
 Filename:  PocketC_Watcher.ck
 Filesize:  1.57 KB
 Downloaded:  154 Time(s)

Back to top
View user's profile Send private message Visit poster's website
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Sat Mar 03, 2007 3:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hey All,

Thanks for all of the engaging posts and help with this project of mine! There's no way I'd be able to pull this off without all of the great tips, and helpful advice! Very Happy

Now I'm really close to having a great Live Chuck program, and I'm really excited to be able to bust it out on the air next weekend. One thing that is crucial to the live functionality of this thing is to be able to update the sample in the shred that's running in the VM when I hit my MIDI foot controller. Right now it writes a new sample to disk, but the buffer goes un-updated.

My thoughts on this were that I might be able to use Machine.replace(1,"rev.ck") after the sample is recorded, and that would update the wave file, and re-spork the program.

I could live with the fact that all of my MIDI controls would be re-initialized, if I could just get Machine.replace() to work! Right now it tells me that there is no shred with id 1 (even though [chuck ^] tells me that there is). Is it possible to replace a sporked shred from the code contained within it? I'm guessing that this is a possibility.

Any other thoughts on how to refresh the buffer to reflect a newly recorded sample would be a big help!

thanks
jack Smile
Back to top
View user's profile Send private message
spencer



Joined: Aug 16, 2006
Posts: 53
Location: northern california

PostPosted: Sun Mar 04, 2007 9:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Jack,
have you considered rechucking the name of the WAV file to your SndBuf's .read parameter? That should be sufficient to reload the file into memory, assuming that the associated WvOut has been closed.

spencer
Back to top
View user's profile Send private message
sir honey



Joined: Aug 04, 2006
Posts: 36
Location: NY

PostPosted: Tue Mar 06, 2007 9:07 am    Post subject: Reply with quote  Mark this post and the followings unread

spencer,

Basically that was the solution I arrived at. Only I built a Machine.replace() into the record method. I eventually got Machine.replace() to work correctly.

I'm going to give your solution a try though, Then my other effect parameters won't get reset with the re-sporking of the shred!

Cheers!
jack
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [18 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
e-m mkii

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 through 2009 by electro-music.com - Conditions Of Use