| Author |
Message |
sebpiq

Joined: Apr 02, 2011 Posts: 4 Location: finland
|
Posted: Sat Apr 02, 2011 8:33 am Post subject:
Lisa doesn't stop when killing the shred ! |
 |
|
Hi all !
I am currently trying to code some kind of Jamman with chuck and Python, using LiSa. So, in order to have multiple loops, I create one shred for every loop, and containing each its own lisa ! But when removing those shreds, I have noticed that even if the shred seems to be removed, the loop doesn't stop !!! Here a simplified code that reproduces the problem :
| Code: |
1::second => dur looplength;
fun void runloop() {
// LiSa object
SinOsc s => LiSa lisa => dac;
5::second => lisa.duration;
looplength => lisa.loopEnd;
1 => lisa.loop;
//recording loop
lisa.record(1);
looplength => now;
lisa.record(0);
lisa.play(1);
while(true) {
lisa.playPos(0::ms);
looplength => now;
}
}
spork ~ runloop() @=> Shred loopshred;
3::second => now;
Machine.remove(loopshred.id());
|
Could it be because there is no garbage collector, causing the lisa not to be destroyed ?
I have actually found a workaround, which is to exit the lisa shreds by exiting the while loop, and then stopping the lisa before exiting the shred like this :
| Code: |
// ... blablabla
while(aFlag) {
lisa.playPos(0::ms);
looplength => now;
}
lisa.play(0);
lisa.clear();
// ...
|
But it doesn't satisfy me, because it means that I cannot stop the loop whenever I want : I have to wait for it to terminate !
So the best would be to kill the shred, with everything working nicely, and the lisa being deleted as well !!!
Does anyone have a solution for that ?
Sébastien
PS : When it'll be working a little better, I'll publish the code on bitbucket ![/code] |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 373
G2 patch files: 100
|
Posted: Sat Apr 02, 2011 3:36 pm Post subject:
|
 |
|
This is well-known behaviour, and I don't think it's going to change anytime soon.
I usually do a stop function that both sets the flag that you're checking in the while loop as well as shutting down whatever sound-making is going on, like:
| Code: | fun void shutMeDown() {
aFlag = false;
0 => lisa.gain;
}
|
There are languages (such as Java) where this is actually best practice, even if it may look cumbersome. You don't usually rely on a garbage collector to do things synchronous to things you're doing in your code. You might argue that ChucK could have a garbage collector that does things synchronously, due to the nature of shreds, but well, the garbage collector isn't really there yet, and judging by ChucK's progress lately, I wouldn't bet on it coming at all.
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
|
Back to top
|
|
 |
sebpiq

Joined: Apr 02, 2011 Posts: 4 Location: finland
|
Posted: Thu Apr 14, 2011 2:20 am Post subject:
|
 |
|
Wow ... my gmail had put the notification in spams, I didn't get the answer at first !
Thanks for the answer !
| Quote: | | There are languages (such as Java) where this is actually best practice |
Yes ... actually I remember back in university when I was doing system programming in C on linux, there used to be a handler for when a process terminates.
That would be cool to have that also in shreds ! It would be an intermediary solution, simpler than garbage collection to implement, but cleaner than calling the cleaning-up code in the parent shred !!!
Actually, I found this after posting the question :
| Code: |
Machine.remove(shredIds[lisaId]);
lisas[lisaId] => LiSa lisa;
lisa.play(0);
adc =< lisa;
lisa =< dac;
lisa.clear();
|
So basically, I save a reference to the lisa object, and use it for the cleaning-up, no need to use a flag.
| Quote: |
judging by ChucK's progress lately, I wouldn't bet on it coming at all.
|
Well ... they said that a new release is coming ! I just hope that they will open-up to users and contributors after this release, so this great project could actually go forward. |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 373
G2 patch files: 100
|
Posted: Thu Apr 14, 2011 2:33 am Post subject:
|
 |
|
| sebpiq wrote: |
Actually, I found this after posting the question :
| Code: |
Machine.remove(shredIds[lisaId]);
lisas[lisaId] => LiSa lisa;
lisa.play(0);
adc =< lisa;
lisa =< dac;
lisa.clear();
|
So basically, I save a reference to the lisa object, and use it for the cleaning-up, no need to use a flag.
| Quote: |
judging by ChucK's progress lately, I wouldn't bet on it coming at all.
|
Well ... they said that a new release is coming ! I just hope that they will open-up to users and contributors after this release, so this great project could actually go forward. |
Glad you got it working. I was glad to see the hint of a new version, and apparently some kind of opening up to contributers is in there!
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
|
Back to top
|
|
 |
|