Hello, Maybe i'm missing something, but I need to share a instantiated object between my shreds, as this object will control the music flow, I need all my shreds to share this instance. It works like this: Shred 1 controls the basic bass sequence Shred 2 controls the fx sequence There is a common class between them notifying each shred when they must change their random parameters (for sequencing everything in the right compasses), but the class itself doesn't work if it has no instance controlling the time poll interval, so in a programming language I should implement a shared memory area with mutexes to control the access of the main object, anyone had this problem before? I'm still figuring out how to put my ideas on Chuck, maybe i'm just doing something that's already done. Basicly i'm thinking this way because of the common way eletronic music is built on (8 beats as a word, 32 beats as phrase, and so on) In this way, I can't just add a new shred to the machine without being in the right compass (in a new phrase) , I could use timing, but I still want to make breaks (with effects of course) live, where I just set the main object to stop allowing the shreds to processes its next words/phrases , play the hole effect, and leave the control of the machine to the old shreds again. Is this just insane? Thanks Piero
Hi, Piero, There is a common class between them notifying each shred when they must
change their random parameters (for sequencing everything in the right compasses), but the class itself doesn't work if it has no instance controlling the time poll interval,
If I read it all corectly, this is the central problem, right? How about making one .CK file that defines this public class and includes a static a event. This file would also broadcasts this event from a looping shred (thast shred will probably also deal with incrementing a counter to keep track of what beat is the current one). All of the other files that you use would then wait for that event and as soon as it happens change their parameters (and start phrases or play beats or whatever). That's what I use and it works for me but your needs might be different. Making a event static in a public class is a bit tricky; it involves a temporary workaround using assignment. I could share some code but it would be way better if somebody could properly explain it who actually understands *how* the workaround works; I have to confess it's a bit hazy to me. And no; none of this sounds insane to me but I use ChucK so it might be wise to consult a profesional expert as well ;-). Kas.
Howdy! There is no explicit mechanism for sharing data between multiple shreds, but using public classes and static data members, you can create and use global data. For example, if you defined the following public class: // GlobalData.ck public class GlobalData { // ChucK doesn't support static // objects which aren't references static Event @ theEvent; }; // initialize our global data - // this starts out as an empty reference Event e @=> GlobalData.theEvent; // end of GlobalData.ck You could then access the same event in any other shreds like so: // 1.ck GlobalData.theEvent => now; // do something // end of 1.ck // 2.ck GlobalData.theEvent.broadcast(); // end of 2.ck You can put as many static data members as you need of whichever types into a single or multiple public classes, and share those single instances of these data members between all running shreds. The one trick is that if you want to use a static member variable that is an object (ie, not an int, float, dur, or time), it has to be an _explicit reference_ to that object. Then you have to make sure to initialize that object before you use it. Feel free to ask questions if any of this is too confusing. hope this helps, spencer On Oct 11, 2006, at 4:48 PM, Piero B. Contezini wrote:
Hello,
Maybe i'm missing something, but I need to share a instantiated object between my shreds, as this object will control the music flow, I need all my shreds to share this instance.
It works like this:
Shred 1 controls the basic bass sequence Shred 2 controls the fx sequence
There is a common class between them notifying each shred when they must change their random parameters (for sequencing everything in the right compasses), but the class itself doesn't work if it has no instance controlling the time poll interval, so in a programming language I should implement a shared memory area with mutexes to control the access of the main object, anyone had this problem before?
I'm still figuring out how to put my ideas on Chuck, maybe i'm just doing something that's already done. Basicly i'm thinking this way because of the common way eletronic music is built on (8 beats as a word, 32 beats as phrase, and so on)
In this way, I can't just add a new shred to the machine without being in the right compass (in a new phrase) , I could use timing, but I still want to make breaks (with effects of course) live, where I just set the main object to stop allowing the shreds to processes its next words/phrases , play the hole effect, and leave the control of the machine to the old shreds again. Is this just insane?
Thanks
Piero
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (3)
-
Kassen
-
Piero B. Contezini
-
Spencer Salazar