A piece of code can create beautiful music.
Never underestimate the power of a computer code. It is as elegant as 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 the 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 in time. Let’s write a program in ChucK to make some music. Before that here are some features of ChucK.
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.
So, now navigate to the directory in your file system where you installed ChucK and open the application titled ‘ miniAudicle.exe ‘.
You can notice three windows appear. These are –
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; 2 3 440 => sine_wave.freq; 4 0.5::second => now; 5 6 880 => sine_wave.freq; 7 0.5::second => now; 8 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 a 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 create sound through your program.
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, and 10 are doing the same functions as Lines 3 and 4. Just some values are different. Rest semantics are the 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!!!
This post was last modified on January 6, 2023 9:08 pm
Struggling with a locked Samsung Galaxy or Note smartphone? Remove KG Lock, a U.S.-based company,…
When you open Adobe Photoshop for the first time, it's easy to click around in…
Social Media Influencer apps for mobile With the increasing number of social media platforms and…
Microsoft Dynamics 365 is a suite of Business Applications from Microsoft that covers the traditional…
While torrents and peer-to-peer (P2P) file sharing have long been popular for data transfer, concerns…
In today's increasingly interconnected world, reliable communication is paramount. But what happens when emergencies strike…
This website uses cookies.
Leave a Comment