![](https://secure.gravatar.com/avatar/ee011fe18fef6a9799a25c1adc1b08ab.jpg?s=120&d=mm&r=g)
Hi, I started using ChucK some weeks ago and must say it looks promising. It seems to be the language I have been waiting for: simple enough to be usable for musical application yet low level enough to provide enough control. I have stumbled across some questions though. 1) Here is an example of a simple synthesizer with two envelopes, one for gain and one for frequency. For the first one it is rather straight forward how to connect it using the chuck operator, but as for the frequency envelope: is there some better way to implement it? I get the feeling I make things a bit complicated and inefficient this way. It would feel more natural to me to chuck it to a frequency input of osc. public class Synth{ SawOsc osc => ADSR ampEnv => dac; ADSR freqEnv => blackhole; spork~frequencyEnvelope(); float freq; fun void keyOn(float f) { f => freq; ampEnv.keyOn(); freqEnv.keyOn(); } fun void keyOff() { ampEnv.keyOff(); freqEnv.keyOff(); } fun void frequencyEnvelope() { while(10::ms => now) { freqEnv.value() * 1000 + freq => osc.freq; } }} 2) Suppose I want to rout the synth from the above example through a delay, this would feel like a natural way to do that: Synth synth => Delay delay => dac; Is it possible to define your own chuck operator for some class? To get around this I have added a Gain out to the synth which can be routed like this: synth.out => delay => dac; It works, but it is not too beautiful 3) I got the idea I wanted to kill a shread someting like this: spork~theShred() => @ Shred handle; // this is exactly like the "sporking shreds" chapter in the lang spechandle.kill(); //this is pure imagination 3a) My first concern is that the first line doesn’t compile. The compiler gives “cannot resolve operator ‘=>’ on types ‘Shred’ and ‘Shred’… Am I supposed to use the @=> operator in this situation?3b) Is it possible to kill a shred by reference? Thanks for a wonderful musical programming language, Johan Nilsson _________________________________________________________________ Trött på krångliga mejladresser? Skaffa en live.se-adress här! http://get.live.com/mail/options
![](https://secure.gravatar.com/avatar/fa5a8de5c6e6c5838fc8106b390c7a6d.jpg?s=120&d=mm&r=g)
On 14/01/2008, Johan Nilsson
this would feel like a natural way to do that:
Synth synth => Delay delay => dac;
Is it possible to define your own chuck operator for some class? To get around this I have added a Gain out to the synth which can be routed like this:
synth.out => delay => dac;
It works, but it is not too beautiful
You are right. It works, it's not beautifull. What would be good would indeed be a way to extend Ugen, for example by having a equivalent of what "return" does for functions for in and out. Being a rather young language ChucK has a rather long wish-list.... For now though the method you found is probably the best one, it works just fine, I use it too. 3) I got the idea I wanted to kill a shread someting like this:
spork~theShred() => @ Shred handle; // this is exactly like the "sporking shreds" chapter in the lang spec handle.kill(); //this is pure imagination
3a) My first concern is that the first line doesn't compile. The compiler gives "cannot resolve operator '=>' on types 'Shred' and 'Shred'… Am I supposed to use the @=> operator in this situation?
Yeah, the @=> operator is your friend here. The language specs may be wrong here or it may be a ommision in ChucK itself. This happens and can be confusing. If you have the time and would like to contribute you can make a account on the WiKi and add such confusing items to the page on erata in the manual and docs where the maintainers can find them when they do another round of documentation updating. 3b) Is it possible to kill a shred by reference?
It is. It's also possible to ask a shred reference for the shred's id. Personally (but I'm no language designer) it's my opinion that this could be extended and used for inter-shred comunication as well. Right now you can just kill them, ask them for their id or replace them, I think, kinda like playing a absolute goverment :-). Keep on ChucKing! Kas.
participants (2)
-
Johan Nilsson
-
Kassen