Hello, some newbie questions
Hello everyone, I've been playing with chuck for a couple weeks and am having a lot of fun with it. Really cool environment and I was impressed how easy it was to set up the MIDI stuff. After reading over a lot of material though, I still couldn't answer a few questions, so I thought I'd try the list. - Is there any way to have a script load it's own dependencies? I tried Machine.add which is listed on http://github.com/heuermh/lick/wiki, but it doesn't seem to work. Here's the code I'm trying: http://gist.github.com/611486 - Similar to the last question, when I do load both of the above files into chuck at once, it seems like only the class ends up in the global space. Is there any way share raw functions or variables between files? The reason I want to do this is mostly to avoid having to do timing code like this http://gist.github.com/611515, or note definitions (cs, Cs) in every file. Something like a pre-processor include would probably do the trick. - Is there a way to pass functions as arguments to another function or return a function? Also, are fun's proper closures or am I just getting lucky? I was thinking maybe I could use functional style programming to build things like arpeggiations. If this is totally overkill let me know :) - The SinOsc seems to click whenever I stop or disconnect it. I've tried moving the gain to 0.1, then 0, but it still seems to click. Is there some technique for avoiding this? Thanks in advance for your help. Looking forward to spending more time with ChucK in the future. -Mat
Mat Schaffer:
I've been playing with chuck for a couple weeks and am having a lot of fun with it. Really cool environment and I was impressed how easy it was to set up the MIDI stuff.
After reading over a lot of material though, I still couldn't answer a few questions, so I thought I'd try the list.
- Is there any way to have a script load it's own dependencies? I tried Machine.add which is listed on http://github.com/heuermh/lick/wiki, but it doesn't seem to work. Here's the code I'm trying: http://gist.github.com/611486
No, you have to determine the dependencies and dependency order by hand. This is my number one feature request, to have a proper namespace and import mechanism.
- Similar to the last question, when I do load both of the above files into chuck at once, it seems like only the class ends up in the global space. Is there any way share raw functions or variables between files? The reason I want to do this is mostly to avoid having to do timing code like this http://gist.github.com/611515, or note definitions (cs, Cs) in every file. Something like a pre-processor include would probably do the trick.
Only public classes are shared. You can add static fields & methods to public classes.
- Is there a way to pass functions as arguments to another function or return a function? Also, are fun's proper closures or am I just getting lucky? I was thinking maybe I could use functional style programming to build things like arpeggiations. If this is totally overkill let me know :)
No. As you may have seen, LiCK uses functors to approximate function arguments/closures. Feature request #2. :)
- The SinOsc seems to click whenever I stop or disconnect it. I've tried moving the gain to 0.1, then 0, but it still seems to click. Is there some technique for avoiding this?
Thanks in advance for your help. Looking forward to spending more time with ChucK in the future.
Welcome! michael
On Tue, Oct 5, 2010 at 10:58 AM, Michael Heuer
No, you have to determine the dependencies and dependency order by hand. This is my number one feature request, to have a proper namespace and import mechanism.
Any idea if this is getting worked on? It seems like ChucK development is a little slow judging from the dev mailing list traffic. Only public classes are shared. You can add static fields & methods
to public classes.
Where's the deference for how to define static fields? Can you have static methods too? That might be good enough.
- Is there a way to pass functions as arguments to another function or return a function? Also, are fun's proper closures or am I just getting lucky? I was thinking maybe I could use functional style programming to build things like arpeggiations. If this is totally overkill let me know :)
No. As you may have seen, LiCK uses functors to approximate function arguments/closures. Feature request #2. :)
Yeah, is there an example somewhere on how to use those? The `Object @ default` makes no sense to me :) Welcome!
Thank you! And thanks for your answers! Mat
Mat Schaffer:
No, you have to determine the dependencies and dependency order by hand. This is my number one feature request, to have a proper namespace and import mechanism.
Any idea if this is getting worked on? It seems like ChucK development is a little slow judging from the dev mailing list traffic.
I don't know.
Only public classes are shared. You can add static fields & methods to public classes.
Where's the deference for how to define static fields? Can you have static methods too? That might be good enough.
- Is there a way to pass functions as arguments to another function or return a function? Also, are fun's proper closures or am I just getting lucky? I was thinking maybe I could use functional style programming to build things like arpeggiations. If this is totally overkill let me know :)
No. As you may have seen, LiCK uses functors to approximate function arguments/closures. Feature request #2. :)
Yeah, is there an example somewhere on how to use those? The `Object @ default` makes no sense to me :)
http://github.com/heuermh/lick/blob/master/Loops.ck has static fields and methods, and uses Procedure to build composite loops class Kick extends Procedure { fun void run() { // make kick sound } } class Snare extends Procedure { fun void run() { // make snare sound } } Kick kick; Snare snare; Loops.append(Loops.append(kick, 200::ms), Loops.append(snare, 200::ms))) @=> Procedure beat; Loops.loop(beat, 2) @=> Procedure measure; Loops.loop(measure, 4) @=> Procedure verse; Loops.append(verse, Loops.append(verse, Loops.append(chorus, Loops.append(verse, chorus)))) @=> Procedure song; song.run(); But yeah the syntax is icky. michael
2010/10/5 Mat Schaffer
- The SinOsc seems to click whenever I stop or disconnect it. I've tried moving the gain to 0.1, then 0, but it still seems to click. Is there some technique for avoiding this?
Typically you'd use an envelope to avoid clicks by slowly ramping the gain. For example, you could use an Envelope: SinOsc s => Envelope e => dac; 50::ms => e.duration; while(1) { e.keyOn(1); second => now; e.keyOff(1); second => now; } Or ADSR, which lets you give it a little kick: SinOsc s => ADSR e => dac; e.set(50::ms, 50::ms, .4, 50::ms); while(1) { e.keyOn(1); second => now; e.keyOff(1); second => now; } -- Tom Lieber http://AllTom.com/ http://favmusic.net/
On Tue, Oct 5, 2010 at 2:33 PM, Tom Lieber
2010/10/5 Mat Schaffer
: - The SinOsc seems to click whenever I stop or disconnect it. I've tried moving the gain to 0.1, then 0, but it still seems to click. Is there some technique for avoiding this?
Typically you'd use an envelope to avoid clicks by slowly ramping the gain.
For example, you could use an Envelope:
SinOsc s => Envelope e => dac; 50::ms => e.duration; while(1) { e.keyOn(1); second => now; e.keyOff(1); second => now; }
Or ADSR, which lets you give it a little kick:
SinOsc s => ADSR e => dac; e.set(50::ms, 50::ms, .4, 50::ms); while(1) { e.keyOn(1); second => now; e.keyOff(1); second => now; }
Thanks, Tom! Just noticed you also did Ruck which I was looking at. Good luck on the project! I'd love something like ChucK that had a more full-featured language driving it. Thanks again, Mat
participants (3)
-
Mat Schaffer
-
Michael Heuer
-
Tom Lieber