Make Music with A Programming Language!!!

0 7


A piece of code can create beautiful music.

Never underestimate the power of a computer code. It is as elegant as a soothing scenery and as cruel as Satan from hell ( the viruses ).

Today we will introduce to you a compact and cool programming language called – ChucK. ChucK is a strongly timed programming language, which means it has its own internal clock and it works along it. ChucK has a very strong friendship with time. Everything which happens in ChucK happens with advance in time. Each line of code can be asked to wait for a particular time period or could be made to get executed at a particular point of time. Lets write a program in ChucK to make some music. Before that here are some features of ChucK.

  • ChucK is a programming language tailored for making sound.
  • ChucK is designed around time.
  • ChucK has concurrency i.e. running multiple Shreds together.
  • ChucK is a High Level Language i.e. has simple text like code which is easy to understand.
  • ChucK is open source and freely available.


What all you need?


  1. Download ChucK from =>


2. Download the installer according to the operating system you use

3. Install it and you are done!


We are using windows OS for this tutorial so we downloaded the windows version of the installer. ChucK has its own Development Environment so don’t worry, the code will be the same for all OS’s.


Now shall we begin!!


So, now navigate to the directory in your file system where you installed ChucK and open the application titled ‘ miniAudicle.exe ‘.

 You’ll see something like this.



You can notice three windows appear. These are –

  1. Console – This windows display the error codes and other information.
  2. miniAudicle – You write all your code here. Save and Open files.
  3. Virtual MachineChucK has its own Engine. It works over this Virtual Machine instance. You’ll get to know more about it in later tutorials.


Now You Are A Little Bit Familiar With The ChucK Interface.


Now click on the miniAudicle window. Create a new file. File > New.

We’ll tell you all the functioning of the code later in this tutorial. For now input this code in your new file.

 1 SinOsc sine_wave => dac;
 3 440 => sine_wave.freq;
 4 0.5::second => now;
 6 880 => sine_wave.freq;
 7 0.5::second => now;
 9 660 => sine_wave.freq;
10 1::second => now;


So, an important thing, ChucK works on that Virtual Machine thingy. Therefore, firstly click on the ‘ Start Virtual Machine ‘ button in the Virtual Machine window. You’ll notice a clock starts running in that window.


Notice the ‘ running time ‘ and the ‘ shred ‘ count. Shreds are nothing but an instance of a ChucK program. The ‘ remove last ‘ button removes the latest added Shred and the ‘ clear VM ‘ button clears all the VM’s from the list.

Now from the miniAudicle window, click on the big green plus button titled ‘ Add Shred ‘. It will add the Shred of your program into the VM and you will hear three variations of a tone for a total of 2 seconds. 0.5 second for a sine wave at 440 Hertz, 0.5 for sine wave at 880 Hertz and 1 second for a sine wave at 660 Hertz.

This may not be pleasing to your ear, but hey! you creating sound through your program.


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!

aa ley ChucK, mai aa gaya!!!

Content Protection by

Leave A Reply

Your email address will not be published.

CommentLuv badge

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More