Hi, I am quite new to ChucK (new to audio programming even), but my first impressions are positive. The language is clear and uses familiar concepts, so it is easy to pick up. I have written a demo application to let Chuck be controlled through Processing. See my blog post: http://visiblearea.com/blog/bin/view/ VisibleArea/ProcessingandChucK The demo now plays audio files, but it would be easy to change this to let it create and play custom audio. A number of issues I encountered (perhaps due to my ignorance): - It should be possible to start and stop the ChucK VM in Processing, but no stop handlers are called at closing the app, leaving the VM in the air. I understand this is an issue with Java applets. - I would have liked to use 1 FilePlayer class that is loaded only once into the VM, but I have not found a way to do this. Either: 1) call 'chuck fileplayer.ck' before demo files are called causes errors on running the demo files that FilePlayer is unknown 2) for every demo file call 'chuck fileplayer.ck chuckdemo.ck:all:sorts:of:params' causes an error that FilePlayer is already in the global VM space and this will stop the demo file from running - It would be great if MP3 files are played - How can I use the analysis tools to create an equalizer-like display? I am interested in your opinions and suggestions. Arthur Clemens
On 9/2/07, Arthur Clemens
Hi,
Hi Arthur, welcome! I'll try to help you with some of this, we'll see how far we get. Some of it looks a bit odd to me.
I have written a demo application to let Chuck be controlled through Processing. See my blog post: http://visiblearea.com/blog/bin/view/ VisibleArea/ProcessingandChucK
Cool stuff. The demo now plays audio files, but it would be easy to change this
to let it create and play custom audio.
- It should be possible to start and stop the ChucK VM in Processing, but no stop handlers are called at closing the app, leaving the VM in the air. I understand this is an issue with Java applets.
Yes, this is a bit mysterious to me. The way to go about this would be staring ChucK using either "chuck --loop" or by feeding it a file like this; "ChucK myfile.ck" using a file that will keep running. The ChucK VM should exit after you give the system a command to "chuck --kill" or after the last shred has been removed from it (if it's not set to --loop). If it doesn't properly exit after either then that would probably be a bug. I don't see how applets would affect this as this would be something between the OS and ChucK, ChucK shouldn't be affected by what sort of thing send those system calls. Strange. - I would have liked to use 1 FilePlayer class that is loaded only
once into the VM, but I have not found a way to do this. Either: 1) call 'chuck fileplayer.ck' before demo files are called causes errors on running the demo files that FilePlayer is unknown 2) for every demo file call 'chuck fileplayer.ck chuckdemo.ck:all:sorts:of:params' causes an error that FilePlayer is already in the global VM space and this will stop the demo file from running
I looked at your code for a bit and noticed you wrote a public class in one file, then redefined the class in another... Maybe it would be best if I'd review how public classes should work in ChucK. A public class is usable by everything in the whole VM. So; in order to use it you define it once and run this code. If the class enters the VM without errors then it should be fine, if it isn't acessible afterwards the first thing I'd verify in your situation is wether you aren't accidentally starting a second instance of the ChucK VM (which wouldn't yet have this class defined). Because of the way public classes work right now they can only be defined once and trying to define them again will result in errors. I'm not sure how the VM will deal with a non-public class of the same name getting defined in other files, generally I simply wouldn't do that as it's asking for confusion and trouble. Beyond that it's hard for me to say what exactly is going wrong because I don't have Processing on this computer right now and it's hard to tell exactly what's happening in what order by just quickly reading your code. Most likely it's just something small and silly, because of what you wrote above I have a hunch it might have something to do with starting and stopping the VM.
- How can I use the analysis tools to create an equalizer-like display?
I'd like to know stuff like that too. The analysis stuff is very, very new, I have yet to poke around in it. I'm planning to try to write some functions that would deal with the arrays those produce in order to try to find the highest peaks in the spectrum and so on but FFT on such a practical and low level is very new to me. Hope this was of some use to you, I'm sure we'll get to the bottom of this, likely it's just a very minor misunderstanding. Yours, Kas.
- It should be possible to start and stop the ChucK VM in Processing, but no stop handlers are called at closing the app, leaving the VM in the air. I understand this is an issue with Java applets.
Yes, this is a bit mysterious to me. The way to go about this would be staring ChucK using either "chuck --loop" or by feeding it a file like this; "ChucK myfile.ck " using a file that will keep running. The ChucK VM should exit after you give the system a command to "chuck --kill" or after the last shred has been removed from it (if it's not set to --loop). If it doesn't properly exit after either then that would probably be a bug. I don't see how applets would affect this as this would be something between the OS and ChucK, ChucK shouldn't be affected by what sort of thing send those system calls. Strange.
No, this is just because of the way applets are quit in Java. If 'chuck --kill' is sent the processed are killed normally, so ChucK behaves predictable
- I would have liked to use 1 FilePlayer class that is loaded only once into the VM, but I have not found a way to do this. Either: 1) call 'chuck fileplayer.ck' before demo files are called causes errors on running the demo files that FilePlayer is unknown 2) for every demo file call 'chuck fileplayer.ck chuckdemo.ck:all:sorts:of:params' causes an error that FilePlayer is already in the global VM space and this will stop the demo file from running
I looked at your code for a bit and noticed you wrote a public class in one file, then redefined the class in another...
The public class not used in the demo, but I kept the file because that is the way I would ideally solve it. What I do in Processing is: 1) start chuck with 'chuck --loop' (because Processing will not quit the process I start it from the command line) 2) add the fileplayer class with 'chuck -add fileplayer.ck' 3) for each of the sound files, add it with 'chuck -add chuckdemo.ck:with:a:lot:of:params' This is the order the commands are sent to ChucK. But what I get back is: $ chuck --loop [chuckdemo.ck]:line(43): undefined type 'FilePlayer'... [chuckdemo.ck]:line(43): ... in declaration ... [chuckdemo.ck]:line(43): undefined type 'FilePlayer'... [chuckdemo.ck]:line(43): ... in declaration ... [chuckdemo.ck]:line(43): undefined type 'FilePlayer'... [chuckdemo.ck]:line(43): ... in declaration ... [chuckdemo.ck]:line(43): undefined type 'FilePlayer'... [chuckdemo.ck]:line(43): ... in declaration ... [chuck](VM): sporking incoming shred: 1 (fileplayer.ck)... So even if 'fileplayer.ck' is called earlier, it is added last to the VM. First the chuckdemo.ck files are run and they do not know any FilePlayer class at that time. Note that the order varies at each run. Sometimes the FilePlayer class is added second or third, sometimes first. I don't know if this is because of the way Java calls the processes, or if class initialization in ChucK happens after file processing. So I would be fine if I could call for each file: 'chuck -add fileplayer.ck chuckdemo.ck:with:a:lot:of:params', but after the first file ChucK is bailing out: [fileplayer.ck]:line(1): class/type 'FilePlayer' is already defined in namespace 'global' why can't it just ignore this? Arthur
On 9/3/07, Arthur Clemens
No, this is just because of the way applets are quit in Java. If 'chuck --kill' is sent the processed are killed normally, so ChucK behaves predictable
Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
The public class not used in the demo, but I kept the file because that is the way I would ideally solve it.
That's what I suspected now. <snip>
So even if 'fileplayer.ck' is called earlier, it is added last to the VM. First the chuckdemo.ck files are run and they do not know any FilePlayer class at that time. Note that the order varies at each run. Sometimes the FilePlayer class is added second or third, sometimes first.
I don't know if this is because of the way Java calls the processes, or if class initialization in ChucK happens after file processing.
This is very odd, I'm inclined to suspect Processing is sending the commands in the wrong order. What you could do is start ChucK using this; chuck --loop fileplayer.ck That should force it to be added at the right moment. So I would be fine if I could call for each file: 'chuck -add fileplayer.ck
chuckdemo.ck:with:a:lot:of:params', but after the first file ChucK is bailing out: [fileplayer.ck]:line(1): class/type 'FilePlayer' is already defined in namespace 'global' why can't it just ignore this?
Because (right now) you can't re-define existing public classes. I don't quite understand why it won't add the second file after running the first has failed, there might be a good reason for that but I don't see it. I'd sugest you try the sugestion of adding the public class to the VM at the time you start the VM, that should force the order to be the right way around, let's see where that gets us. Yours, Kas.
On Sep 3, 2007, at 8:56 PM, Kassen wrote:
On 9/3/07, Arthur Clemens
wrote: No, this is just because of the way applets are quit in Java. If 'chuck --kill' is sent the processed are killed normally, so ChucK behaves predictable
Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
I have to try this. It would mean I have a message sent from Processing at least once in a while.
The public class not used in the demo, but I kept the file because that is the way I would ideally solve it.
That's what I suspected now.
<snip> So even if 'fileplayer.ck' is called earlier, it is added last to the VM. First the chuckdemo.ck files are run and they do not know any FilePlayer class at that time. Note that the order varies at each run. Sometimes the FilePlayer class is added second or third, sometimes first.
I don't know if this is because of the way Java calls the processes, or if class initialization in ChucK happens after file processing.
This is very odd, I'm inclined to suspect Processing is sending the commands in the wrong order.
The commands are sent in the right order. But they are sent though Java processes, and I don't know how Java handles these calls.
What you could do is start ChucK using this;
chuck --loop fileplayer.ck
That should force it to be added at the right moment.
This works. But this is not a flexible solution from a Processing user point of view. I would prefer to use a generic setup. Arthur
On 9/3/07, Arthur Clemens
I have to try this. It would mean I have a message sent from Processing at least once in a while.
It might be usefull, particularly while developing. Another thing that might work; When I'm trying to write something larger and re-running it often I sometimes create a hotkey that will simply kill the whole thing. In your case it would have Processing kill ChucK, then itself. The commands are sent in the right order. But they are sent though Java
processes, and I don't know how Java handles these calls.
Hmmm, would any harm be done by forcing some (short amount of) time to pass between sending the public class and the files that use it? Are the other commands ariving in order? This works. But this is not a flexible solution from a Processing user point
of view. I would prefer to use a generic setup.
Yes, clearly there is more to this but at least it works now which is a nice development after all of this strange stuff! Kas.
Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
How would this work? Unfortunately there is no command 'Machine.kill ()'. 'Machine.crash()' is not so neat. Also, I cannot use 'OscEvent oeAlive => now;' because that will wait for the message that will not arive anymore... Arthur
On 9/5/07, Arthur Clemens
Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
How would this work? Unfortunately there is no command 'Machine.kill ()'. 'Machine.crash()' is not so neat.
The easiest and safest way is probably to use the standard library function that issues a call to the OS and have the OS execute "chuck --kill". The advantage of this is that it will also work in the case the VM is set to --loop. This would elimiate the need for the sugestion below since you could have Processing ask ChucK to terminate directly (or more precicely; have Processing ask ChucK to ask the OS to terminate ChucK). That being said; now that I think about it I have no idea why there is no Machine.kill() command. Considdering that defining public classes will make changes to the VM that can't be undone from within ChucK it would seem ballanced to be able to destroy the VM from within ChucK without crashing. Also, I cannot use 'OscEvent oeAlive => now;' because that will wait
for the message that will not arive anymore...
Yes. True. A clean solution would be to have your OSC parsing function write "now" to a variable of type "time" named "last_time_we_heard_from_processing" (or the like) every time a OSC event comes in. Then you could have a function that would periodically substract this from "now" and if the outcome is longer then -say- ten seconds this shred would call for the destruction of the VM. The exact tuning of this might need some care because obviously we wouldn't want to accidentally destroy the VM (and we don't want to wait more then we have to) but as a general principle this seems like a good plan to me and it also deals with the chance that processing would crash/get stuck. You might want to check /examples/time/ for details on how variables of the type "time" work. Disclaimer; these sound like good plans to me but I don't think I ever actually tried either. May catch fire, no waranties, no refunds. Hope that helps, Kas.
I have solved 1 main problem: starting and stopping Chuck by Processing. I have created a 'monitor' chuck file that listens for incoming events and shuts down Chuck when it no longer receives any messages. New demo + video: http://visiblearea.com/blog/bin/view/VisibleArea/ ProcessingandChucKHelloWorlddemo Arthur On Sep 5, 2007, at 1:45 AM, Kassen wrote:
On 9/5/07, Arthur Clemens
wrote: Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
How would this work? Unfortunately there is no command 'Machine.kill ()'. 'Machine.crash()' is not so neat.
The easiest and safest way is probably to use the standard library function that issues a call to the OS and have the OS execute "chuck --kill". The advantage of this is that it will also work in the case the VM is set to --loop.
This would elimiate the need for the sugestion below since you could have Processing ask ChucK to terminate directly (or more precicely; have Processing ask ChucK to ask the OS to terminate ChucK).
That being said; now that I think about it I have no idea why there is no Machine.kill() command. Considdering that defining public classes will make changes to the VM that can't be undone from within ChucK it would seem ballanced to be able to destroy the VM from within ChucK without crashing.
Also, I cannot use 'OscEvent oeAlive => now;' because that will wait for the message that will not arive anymore...
Yes. True. A clean solution would be to have your OSC parsing function write "now" to a variable of type "time" named "last_time_we_heard_from_processing" (or the like) every time a OSC event comes in. Then you could have a function that would periodically substract this from "now" and if the outcome is longer then -say- ten seconds this shred would call for the destruction of the VM. The exact tuning of this might need some care because obviously we wouldn't want to accidentally destroy the VM (and we don't want to wait more then we have to) but as a general principle this seems like a good plan to me and it also deals with the chance that processing would crash/get stuck. You might want to check / examples/time/ for details on how variables of the type "time" work.
Disclaimer; these sound like good plans to me but I don't think I ever actually tried either. May catch fire, no waranties, no refunds.
Hope that helps, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
The Processing demos I posted earlier wouldn't play on Windows. I have found the issue and updated new demo files at http://visiblearea.com/blog/bin/view/VisibleArea/ProcessingandChucK and http://visiblearea.com/blog/bin/view/VisibleArea/ ProcessingandChucKHelloWorlddemo Arthur
On 9/5/07, Arthur Clemens
Ok, so the issue is that ChucK keeps running when Processing is killed? If that's a real problem you could try to make ChucK poll processing over OSC every second or so and if it isn't running ChucK could send a system command to kill ChucK.
How would this work? Unfortunately there is no command 'Machine.kill ()'. 'Machine.crash()' is not so neat.
The easiest and safest way is probably to use the standard library function that issues a call to the OS and have the OS execute "chuck --kill". The advantage of this is that it will also work in the case the VM is set to --loop. This would elimiate the need for the sugestion below since you could have Processing ask ChucK to terminate directly (or more precicely; have Processing ask ChucK to ask the OS to terminate ChucK). That being said; now that I think about it I have no idea why there is no Machine.kill() command. Considdering that defining public classes will make changes to the VM that can't be undone from within ChucK it would seem ballanced to be able to destroy the VM from within ChucK without crashing. Also, I cannot use 'OscEvent oeAlive => now;' because that will wait
for the message that will not arive anymore...
Yes. True. A clean solution would be to have your OSC parsing function write "now" to a variable of type "time" named "last_time_we_heard_from_processing" (or the like) every time a OSC event comes in. Then you could have a function that would periodically substract this from "now" and if the outcome is longer then -say- ten seconds this shred would call for the destruction of the VM. The exact tuning of this might need some care because obviously we wouldn't want to accidentally destroy the VM (and we don't want to wait more then we have to) but as a general principle this seems like a good plan to me and it also deals with the chance that processing would crash/get stuck. You might want to check /examples/time/ for details on how variables of the type "time" work. Disclaimer; these sound like good plans to me but I don't think I ever actually tried either. May catch fire, no waranties, no refunds. Hope that helps, Kas.
My blog diagrammes modernes now has several articles of interest to this community, including one on ChucK. More are coming soon, and as I have 50K hits a year this might help spread the word! Surf: http://diagrammes-modernes.blogspot.com/ -- robin ----- Robin Parmar robinparmar.com
I read those this afternoon.
One factual note; functions have their own name-space as well.
One opinion; I completely fail to see what's wrong with "miniaudicle" as a
name.
One helpfull note; garbage collection is indeed a issue but in most cases a
lot can be done to avoid generating garbage, both Ugens and sporked
functions can be re-used, etc.
Aside from those I look forward to reading more about your progress.
Cheers,
Kas.
On 9/2/07, robin.escalation
My blog diagrammes modernes now has several articles of interest to this community, including one on ChucK. More are coming soon, and as I have 50K hits a year this might help spread the word!
Surf: http://diagrammes-modernes.blogspot.com/
-- robin
----- Robin Parmar robinparmar.com _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
One factual note; functions have their own name-space as well.
OK. I am already missing the package / module concept however.
One opinion; I completely fail to see what's wrong with "miniaudicle" as a name.
Well, there's no such thing as an "audicle" so tacking on the prefix "mini" makes it less than informative as to what it might actually be. That said I also hate the name "ChucK", especially with that spelling, but thought it impolite to mention that as well. ;-) One has to admit that Supercollider is a very cool name!
One helpfull note; garbage collection is indeed a issue but in most cases a lot can be done to avoid generating garbage, both Ugens and sporked functions can be re-used, etc.
Yes, I saw some code for that somewhere. Though it's nice to have a workaround, it does make what should be trivial into something less than trivial. -- robin
On 9/3/07, robin.escalation
One factual note; functions have their own name-space as well.
OK. I am already missing the package / module concept however.
I'm not sure what those are or why we need them, could you kindly explain?
One opinion; I completely fail to see what's wrong with
"miniaudicle" as a name.
Well, there's no such thing as an "audicle" so tacking on the prefix "mini" makes it less than informative as to what it might actually be.
At this stage I suspect I need to point something out to you; http://audicle.cs.princeton.edu/ There in fact is a "Audicle" but it can be quite heavy on the CPU and GPU, the MiniAudicle is a smaller version with the most important elements yet a far smaller footprint resource-wise. This makes a lot of sense, IMHO. That said I also hate the name "ChucK", especially with that
spelling, but thought it impolite to mention that as well. ;-)
One has to admit that Supercollider is a very cool name!
SuperCollider has a very cool name, I admit. Future writers might engage in long articles interperting the act of chucking something in comparision to the effect of it colliding against something else *ducks*. If all else fails you can re-name the executable. ;¬)
Yes, I saw some code for that somewhere. Though it's nice to have a workaround, it does make what should be trivial into something less than trivial.
Yes, that's true. We definately need garbage collection but in practice I don't think too many people are stuck now without it because in most cases it's not a issue at all. If you are writing code for a instalation it could become a very real matter but at that point whatever you write will need to be double-checked so many times that working around garbage will mostly be a relatively minor adition to this work-load. Kas.
I'm not sure what those are or why we need them, could you kindly explain?
I'll explain using Python, which I am the most familiar with. Each file of code is a module, which can contain an arbitrary number of functions or classes. Each of these has their own addressable namespace, but the key thing is that the module itself has its own namespace too. So in a new file I am working on I can say: import MyNiceLibrary newInstance = MyNiceLibrary.MyNiceClass() newInstance.someProperty = 'hi there' This shows the power of namespaces. All the names are distinct and cleanly separated. (You can do even more than this with different forms of "import", packages etc., but this illustrates the ideas.) As I understand it, in ChucK there is nothing similar to an import. Files do not have explicit namespaces, though one is created if a file is sporked as a shred. But this is not addressable, it merely keeps private data in each process from colliding. A further limitation is there can be only one public class in a file.
At this stage I suspect I need to point something out to you; http://audicle.cs.princeton.edu/
Oh yes, I know about the audicle and have tried it. Someday this might rule the world. But it's still not a word. :-)
SuperCollider has a very cool name, I admit. Future writers might engage in long articles interperting the act of chucking something in comparision to the effect of it colliding against something else *ducks*.
This would be good fun and is not totally a joke. As a poet I would argue that how we name things and what language we choose to describe them affects how we work with them in an intimate way. One of the reasons I like ChucK is that the expressive use of the language, especially the chuck operator, makes good sense to me for the domain of audio operations. -- robin
On 9/3/07, robin.escalation
I'm not sure what those are or why we need them, could you kindly explain?
I'll explain using Python, which I am the most familiar with. Each file of code is a module, which can contain an arbitrary number of functions or classes. Each of these has their own addressable namespace, but the key thing is that the module itself has its own namespace too.
Ok, got it.
As I understand it, in ChucK there is nothing similar to an import. Files do not have explicit namespaces, though one is created if a file is sporked as a shred. But this is not addressable, it merely keeps private data in each process from colliding. A further limitation is there can be only one public class in a file.
Yes, you are right. As you might've seen in the list archives; we just went trough a process where everybody could list his/her wishes and sugestions for chucK and a import/inclusion process turned out to be very high on that list. Likely this will (have to?) bring a more sophisiticated namespace method with it. In my own experience the current method covers the needs of chucK. Another matter is that in the past far more people ran into a desire to have seperate elements share their namespace then that ran into the desire for more seperation. Perhaps this will change as imports/inclusions make it easier and more inviting to start larger projects.
Oh yes, I know about the audicle and have tried it. Someday this might rule the world. But it's still not a word. :-)
Ah, sorry, for a moment I thought you were unaware of the Audicle. Personally I like how it's named; it's a new thing, arguably it's a completely new *sort* of thing so it has a new name. The same hold true for "spork". "Cubase" isn't a word either yet that doesn't seem to cause any confusion or loss of sales either compared to "Logic", "Sonar" or "Live" which are words.
SuperCollider has a very cool name, I admit. Future writers might
engage in long articles interperting the act of chucking something in comparision to the effect of it colliding against something else *ducks*.
This would be good fun and is not totally a joke. As a poet I would argue that how we name things and what language we choose to describe them affects how we work with them in an intimate way.
Yeah, absolutely. SC-fanatics will likely interpert the analogies with a different emphasis, could be a fun debate :¬) One of the reasons I like ChucK is that the expressive use of the
language, especially the chuck operator, makes good sense to me for the domain of audio operations.
Same here. After a long time of thinking like "sending this there, then making foo go to bar and seeing what happens" the "ChucK" name might well become more apealing to you. I mean; we realy are sending stuff in directions, sometimes like a ninja throwing stars, at others more like a drunk garbage-man. Perhaps ChucK will once get so mature and stable that "chucking" no longer seems like a apropriate analogy, perhaps at that stage we will have to considder a different name that expresses a more precise and controlled sort of throwing. Perhaps "ParticleAccelerator" ;¬). Cheers, Kas. P.S. joking aside I think SC is great and so are my SC-using friends, I believe we can learn a lot from them.
Hello all, It's weird, but I think there may be a bug in for-loop's declaration when used inside a class. Not sure it has been discussed earlier. The code below explains it better than words. Can anyone try if it gives a Bus Error when using myClass2? BTW, I'm using Chuck-1.2.1.0 // *********************************** // this is ok int i, j; for( 0 => i => j; i < 12; 3 +=> i, j++ ) { <<< i, j>>>; } // *********************************** //this class is ok class myClass1 { int i, j; for( 0 => i => j; i < 12; 3 +=> i ) { <<< i, j++>>>; // note j is incremented here } } // *********************************** // next class is not ok: seems that declaring 2 increments at the end of the for-loop declaration rises a Bus Error. class myClass2 { int i, j; for( 0 => i => j; i < 12; 3 +=> i, j++ ) // note i and j are incremented here and this is supposedly the problem { <<< i, j>>>; } } myClass2 c; eduard
Hi Eduard and all, Thanks for narrowing this down and reporting it! We have repro bug, and have tracked it down to incorrect handling of multi-expression on the third clause in for loop statements. The happens both inside and out of class definitions, but is more crash-prone when inside the class. The fix is in CVS. Anyone else notice anything else fishy with new release (aside from known bugs)? If there is enough cause, we may do an incremental release. Thanks again! Best, Ge! On Sep 3, 2007, at 9:22 AM, eduard aylon wrote:
Hello all,
It's weird, but I think there may be a bug in for-loop's declaration when used inside a class. Not sure it has been discussed earlier. The code below explains it better than words. Can anyone try if it gives a Bus Error when using myClass2? BTW, I'm using Chuck-1.2.1.0
// *********************************** // this is ok int i, j;
for( 0 => i => j; i < 12; 3 +=> i, j++ ) { <<< i, j>>>; }
// *********************************** //this class is ok class myClass1 { int i, j;
for( 0 => i => j; i < 12; 3 +=> i ) { <<< i, j++>>>; // note j is incremented here } }
// *********************************** // next class is not ok: seems that declaring 2 increments at the end of the for-loop declaration rises a Bus Error. class myClass2 { int i, j;
for( 0 => i => j; i < 12; 3 +=> i, j++ ) // note i and j are incremented here and this is supposedly the problem { <<< i, j>>>; } }
myClass2 c;
eduard _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Sorry for top-posting, but I'm writing this in Outlook Web Access.
To keep the discussion quoted below constructive, I'd like to know what is the opinion of ChucK developers about copying the module import mechanisms of Python, which (to me) appears conceptually simple and at the same time flexible enough to trade off namespace cleanness against minimizing keystrokes according to every user's needs.
There is a hierarchy of "packages" (directories) containing nested packages or "modules" (source files) which, when imported (and therefore executed) bind named objects in the global namespace.
A reload() built-in function can reinitialize a module object from sources, without affecting existing function, class, module etc. objects from the previous version which are garbage collected in due time.
The import statement itself has variants which, after loading and executing the module file to initialize the module object, differ in the names they create and can have different purposes.
1) To avoid namespace pollution as much as possible:
import somepackage.somemodule
x=somepackage.somemodule.someclass(somepackage.somemodule.somefunction())
A module or package object is created and bound as "somemodule" in the global namespace; references to its content must be qualified, which is safe and explicit but verbose.
2) To avoid qualifying names:
from somepackage.somemodule import somefunction, someclass
x=someclass(somefunction())
from somepackage import somemodule
x=somemodule.someclass(somemodule.somefunction())
Each of the listed objects is added to the global namespace; the enclosing module or package isn't directly accessible.
3) To avoid listing identifiers:
from somepackage.somemodule import *
x=someclass(somefunction())
Spilling all names in a module, sight unseen, into the global namespace is obviously expedient but obviously dangerous; for interactive sessions which have neither complex library dependencies nor many names of their own it can be an acceptable practice.
4) To change and shorten identifiers:
import somepackage.somemodule as spsm
x=spsm.someclass(spsm.somefunction())
from somepackage.somemodule import somefunction as bar, someclass as foo
x=foo(bar())
Using "as", one can specify what names are put into the global namespace. Apart from being able to fix conflicting or unpleasant names, being able to use very short or fancy names should be useful for live coding.
Two advanced Python features that might be unneeded or replaced by different mechanisms are the customization of packages with a special file (__init__.py) listing which subdirectories are nested packages and which are not, and the customization of a module's exported symbols list through the special __all__ variable.
The only significant complication of Python import statements, which I suggest not adopting, is the use of relative paths with leading dots representing the enclosing packages of the current module: module "a.b.c.qwerty" should import "a.asdfg" with an absolute path like any other script, not the ugly and context-sensitive "...asdfg".
Python unfortunately started with relative imports as the default, but a new language like ChucK can learn from the experience; see http://www.python.org/dev/peps/pep-0328/
.
Regards,
Lorenzo Gatti
________________________________
Da: chuck-users-bounces@lists.cs.princeton.edu per conto di Kassen
Inviato: lun 03/09/2007 13.05
A: robin.escalation@acm.org; ChucK Users Mailing List
Oggetto: Re: [chuck-users] ChucK article(s)
On 9/3/07, robin.escalation
I will not quote all of Gatti Lorenzo's post, which basically suggested adding (most of) the Python namespace and import features into ChucK. I think this would be wonderful and furthermore concur with those features that needn't be implemented. I would like to point out that the import mechanism relies on having a list of paths to search in order to find the libraries. This would also be needed in Chuck. Specifying such a list could happen in an environment variable, configuration file, command-line argument, or some combination of all three. -- robin
A significant difference in usage between Python and ChucK is that Python libraries and extensions tend to be either an integral part of a project or stable shared dependencies of other libraries or applications, while most ChucK libraries can be expected to be 1) experimental or hacked versions of standard library modules, overriding the originals 2) foreign and/or hacked code adopted from other people 3) personal work-in-progress toolboxes. Therefore, most Python libraries are located in some application directory or in the global Lib directory of the interpreter and in both cases controlling the search path is unnecessary; on the contrary ChucK libraries would be rarely appropriate for a global or shared search path and would be often specified differently for specific invocations. Java is very sensitive to library path mistakes (e.g. the "same" class, loaded from two different libraries, is fatally different) and has a very complex search path which is usually specified in a rather explicit and predictable way from the command line and sometimes with references inside libraries. The CLASSPATH environment variable that was initially recommended has become unpopular because it makes application behaviour dependent on which completely unrelated scripts have been run and how they altered this global but transient search path. ChucK can be expected to have the same kind of problems: environment variables are more complex than a global library repository and less reliable than self-contained scripts that invoke the interpreter with the appropriate libraries for different purposes. The only possible advantage of environment variables is that they can be invisible and allow users to avoid invoking scripts or cluttering the command line with options, but this invisibility is also a liability (what if you realize from sudden errors or silence that you used the wrong terminal window where variables are different? What if you need to look up these variables because you forgot?). There are two mostly orthogonal important design decisions about library search paths on the command line: whether to specify directories (including all their content) or single files and whether the list of library locations should be in a command line option or indirectly referenced from a configuration file. Regards, Lorenzo Gatti ________________________________ Da: chuck-users-bounces@lists.cs.princeton.edu per conto di robin.escalation Inviato: lun 03/09/2007 19.35 A: chuck-users@lists.cs.princeton.edu Oggetto: Re: [chuck-users] Importing in Python - was: ChucK article(s) I will not quote all of Gatti Lorenzo's post, which basically suggested adding (most of) the Python namespace and import features into ChucK. I think this would be wonderful and furthermore concur with those features that needn't be implemented. I would like to point out that the import mechanism relies on having a list of paths to search in order to find the libraries. This would also be needed in Chuck. Specifying such a list could happen in an environment variable, configuration file, command-line argument, or some combination of all three. -- robin _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Gatti Lorenzo
A significant difference in usage between Python and ChucK is that Python libraries and extensions tend to be either an integral part of a project or stable shared dependencies of other libraries or applications, while most ChucK libraries can be expected to be
1) experimental or hacked versions of standard library modules, overriding the originals
2) foreign and/or hacked code adopted from other people
3) personal work-in-progress toolboxes.
Actually I don't see how this is really different for the two languages. If anything it's a difference of degree and not of kind. I hack lots of my own libraries in Python, and some of these fit all the above categories. In no cases do I want to store them in the application tree, and so I need to be able to specify where they are. I am not a big fan of environment variables, since they are global for all apps on the system. I take it from your comments you are of like mind. However they are simple solutions that work for simple cases. Other solutions are better.
There are two mostly orthogonal important design decisions about library search paths on the command line: whether to specify directories (including all their content) or single files and whether the list of library locations should be in a command line option or indirectly referenced from a configuration file.
In the first case: why not both? A path could point to either a file of a folder. In the second: A configuration file is more flexible. The command-line can reference it, reducing verbosity. Multiple configs can be maintained for different environments. Apps could alter the config file directly (OK, not ChucK apps... yet) for further flexibility (and potential mayhem!). The config can be a simple list of paths. When searching for a file to import, ChucK first looks in the folder of invocation, then in the config file, reading bottom up, then lastly in the ChucK application mandated location. This means that a file I'm hacking in the current folder will be found first. If the file isn't there, it will be loaded from one of my library locations, and finally the standard library. The same sort of search could be done to find data files, like wavs to open. Similarly, to find the config file itself, ChucK looks first on the command-line, next in the invocation folder, and lastly in the ChucK application folder. (And maybe looks to an environment variable.) -- robin
tis 2007-09-04 klockan 06:37 -0700 skrev robin.escalation:
In the second: A configuration file is more flexible. The command-line can reference it, reducing verbosity. Multiple configs can be maintained for different environments. Apps could alter the config file directly (OK, not ChucK apps... yet) for further flexibility (and potential mayhem!).
The config can be a simple list of paths.
This ~/.chuckrc could also handle many more options, like which soundcard to use, samplerate, and so on. Everything you would normally type on the command line can be more "static". Gasten
Sorry for asking this here, but I see no email contact on the forum for this problem. I tried to register, received no confirmation and cannot log in. I should have got an activation email, but did not. No, it's not in my spam box and after waiting 2 days I don't think it's in limbo either. Clues? While I'm asking: Is there much use double-posting to the forum and here? Which has the most traffic? -- robin
I'm forwarding this to the Forum admins.
I find there is very little double-posting between the forum and the list,
ech has it's own little culture and emphasis even if many people are on
both. To me it seems that the forum is generally a bit more practical in
nature while the topics on the list have a tendency towards the theoretical.
Perhaps most importantly it's looking like the forum is more accesible to
people curious about ChucK.
Kas.
On 9/2/07, robin.escalation
Sorry for asking this here, but I see no email contact on the forum for this problem.
I tried to register, received no confirmation and cannot log in. I should have got an activation email, but did not. No, it's not in my spam box and after waiting 2 days I don't think it's in limbo either.
Clues?
While I'm asking: Is there much use double-posting to the forum and here? Which has the most traffic?
-- robin _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
--- Kassen
I'm forwarding this to the Forum admins.
Thanks. Got a message from them.
I find there is very little double-posting between the forum and the list, ech has it's own little culture and emphasis even if many people are on both. To me it seems that the forum is generally a bit more practical in nature while the topics on the list have a tendency towards the theoretical. Perhaps most importantly it's looking like the forum is more accesible to people curious about ChucK.
So would it be better for me to ask my practical questions on the forum? I don't want to start double-posting and spamming people. -- robin
On 9/2/07, robin.escalation
Thanks. Got a message from them.
I got a CC :¬) They are very friendly and helpfull people, named "Mosc" and "Elektro80" on the forum.
So would it be better for me to ask my practical questions on the forum? I don't want to start double-posting and spamming people.
Generally the forum seems very conductive to colaborative solving of practical issues. Another advantage is that posting a 1MB attachment is no problem on the forum at all but less then polite on a list. These two work well in combination. On the other hand the list has a larger membership which includes (nearly?) everybody who contributed to ChucK so if your question concerns odd/unexpected behaviour the list might be better. I'd say you will be fine if you just do what feels right and if in doubt pick the list. Kas.
I started with the pan example with a gain setting added to prevent my head from getting blown off: // white noise pan Noise n => Pan2 p => dac; .4 => n.gain; while(true) { Math.sin( now / 3::second * 2 * pi ) => p.pan; 10::ms => now; } I wanted to generalise this to several outputs, so I recoded it: // white noise pan without using Pan2 Noise n; n => Gain gleft => dac.left; n => Gain gright => dac.right; .4 => n.gain; 5::second => dur period; while(true) { (Math.sin( now / period * 2 * pi ) +1) / 2 => float amount; amount => gleft.gain; 1-amount => gright.gain; 10::ms => now; } I made sure I had all 8 outputs turned on my soundcard by running this in one window: chuck --out(8) --loop Then, in a second window I fed it the shreds. The two above worked fine. So, I tried this: // white noise four-channel "pan" Noise n; n => Gain gfl => dac.chan(1); n => Gain gfr => dac.chan(2); n => Gain grl => dac.chan(3); n => Gain grr => dac.chan(4); .4 => n.gain; 5::second => dur panperiod; 6::second => dur fadeperiod; while(true) { (Math.sin( now / panperiod * 2 * pi ) +1) / 2 => float panamount; (Math.sin( now / fadeperiod * 2 * pi ) +1) / 2 => float fadeamount; panamount * fadeamount => gfl.gain; (1-panamount) * fadeamount => gfr.gain; panamount * (1-fadeamount) => grl.gain; (1-panamount) * (1-fadeamount) => grr.gain; 10::ms => now; } And got this: NullPointerException: (UGen link) in shred[id=1:x.ck], PC=[33] I have no idea how to use this to diagnose the issue. I am using the latest win32 ASIO build. -- robin
participants (7)
-
Arthur Clemens
-
eduard aylon
-
Gatti Lorenzo
-
Ge Wang
-
Kassen
-
Martin Ahnelöv
-
robin.escalation