Make Music with A Programming Language!!!


Explaining the code.


Line 1 is telling ChucK to create a Sine Wave Oscillator named ‘ sine_wave ‘ with the keyword ‘  SinOsc ‘. The symbol ‘ => ‘ is called ‘ ChucKing ‘. So, we are creating an instance of the Sine Wave Oscillator named ‘ sine_wave ‘ and we are ChucKing it to ‘ dac ‘. ‘ dac ‘ is nothing but the Digital to Analog Converter in your computer system. ChucK recognizes the hardware you are using and devices the sound hardware of your computer as a ‘ dac ‘ , in simpler words – your speakers. And a semicolon ‘ ; ‘ to end a ChucK code statement.

Line 3 is telling ChucK to assign ‘ 440 ‘ to the parameter ‘ sine_wave.freq ‘. In ChucK assigning is not really called ‘ Assigning ‘, it is called ChucKing, so later from now we will call this statement as ChucKing the value ‘ 400 ‘ to ‘ sine_wave.freq ‘. The keyword ‘ freq ‘ is a method, predefined for the Oscillators available in ChucK. It is used to set the Frequency of the Sound Wave which ChucK produces. The period is used between ‘ sine_wave ‘ and ‘ freq ‘ as a Dot Operator. It means, ‘ freq ‘ of object ‘ sine_wave ‘.

Line 4 – As told before, ChucK is a strongly timed language and has its own internal clock and also that he works with an Advance in Time. This line of code is telling ChucK to ChucK ‘ 0.5 ‘ as data type ‘ second ‘ to ‘ now ‘. ‘ now ‘ is a special variable in ChucK. It keeps track of the current time in ChucK. We’ll talk more about ‘ now ‘ in our later tutorials. For now know only that ‘ now ‘ only stores the current time of ChucK.

Lines 6, 7, 9, 10 are doing the same functions as the Lines 3 and 4. Just some values are different. Rest semantics are same.

So this is what ChucK really does with that code.


And this was your very first ChucK program. We will post more tutorials about ChucK teaching you how in ChucK you can create beautiful compositions and enjoy music creation while coding.

Have a great time!

Scroll Up