electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
My first steps with chuck and programming
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 2 [29 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Goto page: 1, 2 Next
Author Message
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Wed Aug 23, 2006 9:05 am    Post subject: My first steps with chuck and programming Reply with quote  Mark this post and the followings unread

at the morning i have read an artikle in an Journal about livecoding. 2hours later i hav download the version 1.2.0.6 of chuck. 2h10min later i accomplished the wiki tutorial (jiipieeee) http://wiki.cs.princeton.edu/forums.html/ChucK/WinXP_Install_and_Run. 2h14min Smile i go down on the first command line in the official chuck tutorial on http://chuck.cs.princeton.edu/doc/learn/tutorial.html.
There are some unanswered questions for me as an absolutly noob. Iam not shure about a clean chuck monitor (is this a cmd with c:\? ).
I tried a lot of versions with this line : // connect sine oscillator to D/A convertor (sound card) sinosc s => dac; but nothing happened.
Maybe it is impossible for a programming noob like me to make sound with chuck, but i have the feeling that there is even a way for me.

Thx a lot. specially to the quy who wrote this wonderful wiki tutorial. (a good start is everything Smile
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Aug 23, 2006 9:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Welcome!

I'm not realy sure I understand the question.

The line
Code:
sinosc s => dac;


Does indeed connect a oscilator to the soundcard, that's right.

If that's the only line in your program, however, chuck will just connect the oscilator, then discover there is nothing more to do and so it will stop doing anything.

What you need is to make sure the program keeps running and that it "advances time" so; let's use a loop that loops forver and that advances time for this. then the whole code would look something like this;

Code:

//this is your line
sinosc s => dac;

//let's define the frequency
440 => s.freq;

//this is that loop I was talking about
while(true)
{
//the only thing the loop does is looping, each time it loops takes a second
1::second => now;
}


You save that code as something like "my_tone.ck" as a file.

Now we'll make ChucK run it. At the comand prompt (and while in the directory where you caved your file) type;

chuck my_tone.ck

This will do a few things; it'll start ChucK and it will put your new file in the virtual machine. you should now hear a beep.

next up you could open a second command line window (because the first one is now bussy running chuck it won't take new input.

Edit your file to look like this;

Code:

//this is your line
sinosc s => dac;

//let's define a different frequency
500 => s.freq;

//this is that loop I was talking about
while(true)
{
//the only thing the loop does is looping, each time it loops takes a second
1::second => now;
}


and save it as my_tone2.ck

Notice that the new file will generate a different frequency.

In your new command line window type

chuck + my_tone2.ck

The "+" means you want to add this new file to the running VM that already exists. If all goes well you should now hear two tones at the same time.

I hope that helps? These are the basics, once you get stuff like this down it should be way easier to understand the examples you got in your download and run those as well as modify them.

If I misunderstood, please clarify what you meant intead, it can be confusing in the beginning.

_________________
Kassen

Last edited by Kassen on Wed Aug 23, 2006 12:58 pm; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Wed Aug 23, 2006 10:18 am    Post subject: I solved some problems Reply with quote  Mark this post and the followings unread

Thank You for this fast answer.

5min after i posted my problems i realized that a notepad is necessary to write down the programm lines. Now i create my first tone with a notepad and a black window with blinking dot. Smile
It is hard to imagine how someone can do this just in time.
Do i need to know all the dos commands? (If yes, i have to learn two things simultaneously)
You see I'm a total noob with cmd window an dos language and chuck. (And writing in english)
But it makes real fun to create this kind of sounds with computerlanquage.

Chuck is calling me

read you in a few minutes Smile
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Aug 23, 2006 10:26 am    Post subject: Reply with quote  Mark this post and the followings unread

Cool, sounds like you are doing fine.

You realy don't need to know all the dos commands, what you do need is;

The syntax of the chuck executable (it's all there in the help fileand it's not a lot).

The "cd" command for changing directories.

The "dir" command for what seeing is in a directory (not strictly nesicary but often very usefull).

That's it.

Very few people are actually coding live on stage but after a few nights of playing with ChucK you'll find you can do a lot without looking every bit up in the manual which will make it all a lot more fun. It all requirers a bit of learning in the beginning but it's not nearly as hard as it might look. Oh, and I think your English is fine.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Wed Aug 23, 2006 10:43 am    Post subject: Reply with quote  Mark this post and the followings unread

I tried your programm advice but the only thing i got from chuck is an error message. He say´s line 9 char 2 syntax error.

//this is your line
sinosc s => dac;

//let's define the frequency
440 => c.freq;

//this is that loop I was talking about
While(true)
{
//the only thing the loop does is looping, each time it loops takes a second
i::second => now;
}


And what about the comments, how can chuck know what is important and what are comments for me?
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Aug 23, 2006 11:08 am    Post subject: Reply with quote  Mark this post and the followings unread

OOOPS.

Not on a pc that has chuck installed at the moment. For on thing s.freq should be s.freq, I'll correct that in my example. Can't see any other real istakes at the moment.

AH! got it, for some silly reason I typed "i" instead of "1" in the last line. My bad, I'll correct that too.

About comments; all the comment lines start with two slasshes

//like this

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Aug 23, 2006 12:57 pm    Post subject: Reply with quote  Mark this post and the followings unread

Right, I made yet another typo in this realy simple program, putting a uppercase "W" where it should of cource have been lowercase. Terribly sorry for confusing matters so much more by typing too quickly.

Will correct now.

-edit-
Right, it turns out I left my laptop's adaper last night (OOOOPS!) so from this we can conclude;

A) No checking of chuckcode from me untill tomorow afternoon (my time, meaning western Europ)

B)Your moderator has been particularly chaotic lately and will now be forced to play vifeo games instead of doing real work.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23500
Location: The Netherlands, Enschede
Audio files: 262
G2 patch files: 320

PostPosted: Wed Aug 23, 2006 3:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Right, I made yet another typo in this realy simple program,


It works now Very Happy

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Aug 23, 2006 3:47 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yeah, usually I just type away, then have the compiler figure out where the typos are. This turns out to work siginificantly worse without the compiler.

;¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Thu Aug 24, 2006 5:35 am    Post subject: Reply with quote  Mark this post and the followings unread

thx for the help. I keep on learning an my headaches are growing. Cool So much Information about chuck and everything around chuck.
Are there some other good tutorials or examples in www which i look over?
I hope my motivation stay with me on this long and hard way.
Back to top
View user's profile Send private message
seraph
Editor
Editor


Joined: Jun 21, 2003
Posts: 12331
Location: Firenze, Italy
Audio files: 33
G2 patch files: 2

PostPosted: Thu Aug 24, 2006 8:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Honza wrote:

I hope my motivation stay with me on this long and hard way.

that's the hardest part Cool

_________________
homepage - blog - forum - youtube

Quote:
Don't die with your music still in you - Wayne Dyer
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Aug 24, 2006 9:33 am    Post subject: Reply with quote  Mark this post and the followings unread

Well, it's not realy that hard at all!

I think the best way of getting to grips with it is looking at the example files, running those, figuring them out and modifying them. If something is unclear just look it up in the manual.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Fri Aug 25, 2006 12:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

I am still learning Smile
But i often read the example files and ask me, what the hell is this. So here is my next question. Exist a list with all possible chuck programming words and operator? Something like:

s.freg = "explanation"
std.rand2f = " explanation"
:: = " explanation"

with the programming guide i need to much time until i find a answer. And a lot of words be a mystery for ever.
Back to top
View user's profile Send private message
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Fri Aug 25, 2006 1:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

I think my background knowledge isn´t enough. Actually i´m stuy sociologie so i never get contact with programming before. This could be the reason for all the questionmarks in my brain when i try to understand chuck. Maybe i meet a real teacher sometime in my life, but with the method of autodidact i will never produce meaningful sounds.
Thanks to all who helped me, but i think i give up. The computer engineer in me is to small. I look out for performances in germany and chucker who cross my way.
everytime a free cmd window and a good sound.

cu
Back to top
View user's profile Send private message
Alexander



Joined: Apr 22, 2006
Posts: 373
Location: NL/QC
Audio files: 1
G2 patch files: 4

PostPosted: Fri Aug 25, 2006 1:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

Come on...

You are really getting there and you started the perfect getting started thread.. just keep asking any questions and go at it, everybody who uses software had to start at some point. A little bit of patience and willpower are maybe more important than engineering skills!

_________________
http://husc-sound.com
Back to top
View user's profile Send private message
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Fri Aug 25, 2006 2:22 pm    Post subject: Reply with quote  Mark this post and the followings unread

Actually you are right but i have so many questions that it is nearly impossible to ask them all. For example: Today i managed the first step of the tutorial, i create a tone with different osc but then came the next step "the effect" (gain).
I tried to understand it and to integrate " .5 => g.gain; " in my existing file tut1.ck but there are only errors.
My questions for this short tutorial part are:
were is the different between s.gain and g.gain?
what is a ugen?
what exactly was a patch again?
what is the different between sinosc and sinsosc?
were is my cmd window?
why cant chuck speak with me?
what, two hours are gone? Shocked
why are all my friends without knowledge about chuck?

You see it is not easy, but on the other hand i realy like it to make music in this way. (in my case it isn´t music probably, but sound)
I assume that chuck will call me tommorow, again and than i probly try again to integrate the gain effect. (looks like a never ending story)
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Aug 25, 2006 2:42 pm    Post subject: Reply with quote  Mark this post and the followings unread

Honza wrote:
I am still learning Smile
But i often read the example files and ask me, what the hell is this. So here is my next question. Exist a list with all possible chuck programming words and operator? Something like:

s.freg = "explanation"
std.rand2f = " explanation"
:: = " explanation"

with the programming guide i need to much time until i find a answer. And a lot of words be a mystery for ever.


Well, the manual goes a long way in this direction but I suppose it can be hard to figure out how to read it. Let's take these one by one, shall we?

s.freq ----- This means there is a thingy called "s" and it has a parameter that's called "freq". It's probably safe to assume "freq" refers to a frequency, but what sort of a thing might "s" be? Chances are somewhere earlier in the file there will be a line like this;

sinosc s => dac;

This means "create a sine oscillator, call it "s" and connect it to the dac". We do it like this because now that specific sinosc has a name and so any controllers send to it will know where to go. We could give it any other name like "LFO" or "modulator", it's often best to use a name that's related toit's function in the program. Ok, now that we know it's a sinosc we can look that ugen (it's a ugen, a "unit generator" that generates sound) up in the manual and see what other functions it might have.

std.rand2f ----- Ok, this is a little tricky but quite useful. "std" refers to the standard library in ChucK. There are quite a few functions in it and they are documented here; http://chuck.cs.princeton.edu/doc/program/stdlib.html (for some reason not yet in the manual, hmm). there you can find it "generates random floating point number in the range [min, max]" and that it takes two floats as input. I admit these are a little hard to find but they are all in one place, they are all quite useful and not that hard to understand. You can look at them as little machines; you throw in a number or two and out comes something else. In this case you throw in two umbers and out comes a random number in the range defined by those. You don't need to know all of those by heart right away but if you'd like something that would seem like ti might be in there it's a good idea to look over that list.

:: ---- I'm not a hundred percent sure myself about the exact meaning (ge????) but you use it to indicate how many of what sort of time unit you want to use. like 1::samp or 3::hour. it only gets used for duration.

Most of all those words are in the manual or the language specs. Actually; in a way the last section of the manual is exactly the sort of list you are looking for, you just need a little experience in learning how to use it. For example; it won't say what "s.freq" means because "s" here was defined by the programmer. It's actually a advantage that you get to name your own things; this saves confusion, both for chuck and for you. What you need now is a little experience in figuring out where in the file "s" got defined (and so knowing you need to look up "sinosc"). This is not that hard because all of the examples are quite simple. Once you figure out how it works with simple files reading larger ones as well as writing your own will be possible because the core principles are quite simple and they stay the same regardless of how large the structure gets; it may look hard but it's just a big stack of very simple things that you can tackle one at a time.

Nobody was born being a fluent programmer and nobody expects you to write a huge synthesiser by tomorrow night. ChucK, admittedly, at the moment does require a little looking around for what is what but once you get to terms with how to look up ugens and the different std functions you should be able to find the stuff used in the examples relatively quickly.

Oh, and could you list some of these "mystery words" that are unclear? The manual is still being written and it might very well be that some things could be explained better. Even if you do quite it would be nice to know what bits were confusing.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ge



Joined: Aug 13, 2006
Posts: 105
Location: Palo Alto, CA

PostPosted: Fri Aug 25, 2006 2:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yeah Alexander is right! You started a great thread - don't give up yet.

An example: we taught ChucK to 15 incoming freshmen (none of whom had any programming experience - they just had a fierce interest in creating music) in the Princeton Laptop Orchestra, and they were rocking long before the end. They composed and performed pieces in ChucK; some early compositions can be heard here.

The point is that these students got really good with ChucK, but it didn't happen in the span of a few days, but rather over the course of 4 or 5 weeks. They didn't do everything at once (they were all taking insane courses in addition to PLOrk), and only kept learning little pieces here and there.

Any language (spoken or programmed) takes time to internalize... ChucK, while potentially easier than many others, is no different. Take your time, and learn it bit by bit in time.

I am willing to guarantee that if you (or anyone else interested in making music with computers) stuck with it and just spend one hour every other day playing with ChucK, there will come a moment when things will click, a gestalt, and you will have grokked how time and stuff work together in ChucK. It won't mean you'll know everything about the language, but it will mark a tipping point: you will know how to dissect and make sense of pretty much anything ChucKian that comes your way from that point on. Maybe it will happen in a few weeks/days/months, or maybe you've already grokked it, but it will happen, if you stick with it. Plus, there is this forum with great people will to help, and the mailing lists.

I bet my next meal on it, and I LOVE food!!!

Sorry for this rambling... I guess I just want to say:

Keep on ChucKin'
Back to top
View user's profile Send private message Visit poster's website
ge



Joined: Aug 13, 2006
Posts: 105
Location: Palo Alto, CA

PostPosted: Fri Aug 25, 2006 3:01 pm    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
what is the different between s.gain and g.gain?

if you have 'sinosc s => gain g => dac;' then in the following code, 's.gain' refers to the gain parameter of 's' (the sinosc), and 'g.gain' refers to the gain parameter of 'g' (the gain).

Quote:
what is a ugen?

Short for unit generator. A ugen is nothing but a single building block for generating and/or processing audio. Some ugens (like sinosc - the sine wave oscillator) generate sound, others(like gain) modifies the input sound and spit out the result in the output, and yet others (like dac) which is a destination that sound goes to.

Quote:
what exactly was a patch again?

A 'patch' is just a fancy name for program. The patch refers to the fact you've connected (or patched) together the ugens.

Quote:
what is the different between sinosc and sinsosc?

Wait, there is no ugen or object called 'sinsosc'.

Quote:
why cant chuck speak with me?

Because chuck is, for now, deaf and dumb and blind - but he sure plays a mean pinball. And you can tell him things much more flexibly in code than speech.

Quote:
what, two hours are gone? Shocked

You mean 2::hour?

Quote:
why are all my friends without knowledge about chuck?

Because they are all waiting for you to learn ChucK and to teach it to them one day. Smile

Quote:
You see it is not easy, but on the other hand i realy like it to make music in this way. (in my case it isn´t music probably, but sound)

Hey, if you organize sound, you get music right?

Quote:
I assume that chuck will call me tommorow

chuck might not, but we will still be here to help, if you want!
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Aug 25, 2006 3:03 pm    Post subject: Reply with quote  Mark this post and the followings unread

Honza wrote:
Actually you are right but i have so many questions that it is nearly impossible to ask them all. For example: Today i managed the first step of the tutorial, i create a tone with different osc but then came the next step "the effect" (gain).
I tried to understand it and to integrate " .5 => g.gain; " in my existing file tut1.ck but there are only errors.
My questions for this short tutorial part are:


great! Let's have a look at these.


Quote:
were is the different between s.gain and g.gain?


Well, here it seems that there are two ugens, one called "s" and one called "g". Both have a "gain" setting which refers to the volume of the signal that comes out. In fact all ugens have a "gain".This is very useful for mixing sounds together in a nice ratio (like on a mixer). This leads us to the next question;

Quote:
what is a ugen?


A ugen is like a module in a modular synthesiser. It's a small building block, a few of those together can make different sounds. Ugens work with sound, generating one sample (value) at a time. Per default on Windows they generate 44100 of those per second (like a cd player). The whole train of samples forms a waveform. Ugens either generate sound on their own (for example a sine wave) or modify sound they get as a input (for example filters).

Quote:
what exactly was a patch again?


Basically a set of ugens in a specific configuration.

Quote:

what is the different between sinosc and sinsosc?


"sinsosc" will generate a error at compilation, sinosc creates a sine wave.

Quote:
were is my cmd window?


Likely below your browser?

Quote:
why cant chuck speak with me?


In fact it could! You could start here;
http://chuck.cs.princeton.edu/doc/program/ugen_full.html#VoicForm

Quote:

what, two hours are gone? Shocked


It's always "now"....

Quote:
why are all my friends without knowledge about chuck?


Excellent question! Maybe we should have a billboard campaign featuring Ge with his hat and a pointing finger, uncle Sam style!

Quote:

You see it is not easy, but on the other hand i realy like it to make music in this way. (in my case it isn´t music probably, but sound)
I assume that chuck will call me tommorow, again and than i probly try again to integrate the gain effect. (looks like a never ending story)


Well, not's not very easy but not all that hard either, once you get over the bump.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Aug 25, 2006 3:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

Crossing posts! Only two real disagreements; I still think ChucK could talk and I think we need billboards.

;¬)

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ge



Joined: Aug 13, 2006
Posts: 105
Location: Palo Alto, CA

PostPosted: Fri Aug 25, 2006 3:17 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Crossing posts! Only two real disagreements; I still think ChucK could talk and I think we need billboards.

Maybe just one - I agree with Kassen about the talking. chuck is mostly likely still deaf and blind, however.

And I am not entirely against making Uncle Sam ChucK propaganda of some kind...
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23500
Location: The Netherlands, Enschede
Audio files: 262
G2 patch files: 320

PostPosted: Fri Aug 25, 2006 3:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Crossing posts! Only two real disagreements; I still think ChucK could talk and I think we need billboards.

;¬)


Kees vd Maarel could make the Nord Modular talk, so it should be doable in ChucK as well Very Happy

I was about to post a reply on the questions as well, but got caught in the cross fire, I had some pretty good ansers though Exclamation

@Honza : Learning a new programming language (especially the first one) is not something to be done in two or three days. A few weeks could do miracle though. It's getting used to some concepts first, and then you'll have to be at home in the documentation to be able to quickly find the stuff that refuses to be remebered. A next programming language will be easier, but still you must go out to discover the documentation then.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Honza



Joined: Aug 23, 2006
Posts: 8
Location: germany

PostPosted: Sun Aug 27, 2006 3:22 am    Post subject: Reply with quote  Mark this post and the followings unread

I´m convinced, I keep on Chucking. With your support it will work. For the next 10 days i will have a chuck break (earning some money and visit some friends) but then i´ll be back with a lot of questions and maybe some advices for a manual upgrades.

The power of osc is with me. Wink
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Aug 29, 2006 3:58 pm    Post subject: Reply with quote  Mark this post and the followings unread

Honza, you're getting cool with chuck now!
i'm a newbie around here also. so i'll be around to share with you
(and all folks, for sure) (and oh you can MSN me)

i have a newbie question to ask also.
i've been through some of Honza's experiences also
but the pdf manual that comes with the chuck executable package really helps me out.
i understood the basics quite fast after reading the tutorial and overview for a couple of times.
and so i can reduce syntax error lol... (but there are still some syntax error i made everyday hahah)

so here i goes:

when i chuck things..
___ => ___ => dac;
the manual says: When a patch is compiled, ChucK looks
at what is connected to the dac and as each sample is computed ChucK
looks through the network of Ugens and grabs the next sample.


so if i unchuck .. will the CPU load for the patch be freed?


Code:
triosc s[10][10]; // prepare 10x10 array of triangle oscs
int status[10][10];

for(0 => int i; i < 10; i++)
for(0 => int j; j < 10; j++) {
   // make each osc's gain 0.01
   0.01 => s[i][j].gain;
   
   // make the oscs' pitches chromatic
   std.mtof(i * 10 + j + 24) => s[i][j].freq;
   
   // clear cell status
   false => status[i][j];
}   

   
while(true) {
   // select a random (i, j) cell
   std.rand2(0, 9) => int i;
   std.rand2(0, 9) => int j;
   // 50% -> connect, 50% -> disconnect the selected osc
   if (maybe)
      // connect only if it's currently off
      if (status[i][j] == false) {
         // connect the selected osc
         s[i][j] => dac;
         // reset its phase
         0 => s[i][j].phase;
         // record status as 'oscillator on'
         true => status[i][j];
      }   
   else {
      // disconnect the selected osc
      s[i][j] =< dac;
      // record status as 'oscillator off'
      false => status[i][j];
   }
   // wait a little bit
   100::ms => now;
}   


in the above chuckling i'm experimenting with
(now wanna play more with array of oscs)
i used to (try to) chuck all those 100 oscillators to dac
and i noticed it really used up a lot of CPU power..

did i make a good decision for cpu by unchucking them when not in used?
thanks for checking out..

i'd try something more complicated
(for example, granular synthesis) from this idea.
but worried about CPU lol..
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 2 [29 Posts]
View unread posts
View new posts in the last week
Goto page: 1, 2 Next
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use