JYISMUSIC
  • Blog
  • WORK WITH US

When Engineering (programming) Meets Music

30/10/2013

0 Comments

 
Picture
I love learning new things. It always gives me excitement especially when you see results from learning! This time around, I was playing with a new music programming language that I found online. It is called ChucK, a programming language that is so different from the rest. It's strongly based on time! How cool can that be! Okay, for those who love to find out more, just click on the link on ChucK! 

I have just started learning, so my digital art piece consists only one sine wave and one square wave, nothing fancy :) Well, this digital art piece is called 'Kikai no Jinsei' - it means a life of a robot.

Picture
Wall E was what I had in mind while writing the code, or say the 'music'. The short mp3 is included below along with the code that I have written. It's just a simple for and while loop with some random numbers generator in it! I can't wait to learn more about it!

// Author: Jyi Sim
// Date: 27 Oct 2013

// Using sine and square wave to create simple 1dimension music
// Title of Music piece : Kikai no Jinsei
// This piece of music is about a life of a robot, 
// how it was produced, its life with other robots,
// and how it malfunctioned and died.

SinOsc s => dac;
SqrOsc t => dac;

//part 1 composition (5 seconds) : it is being manufactured!
//================================
//add 5 seconds to time now to make 5 seconds composition
now + 5::second => time later;
while (now<later)
{
    //set 0 gain to square wave
    0 => t.gain;
    //playing  3 different notes produced by sine wave 
    220 => s.freq;
    .5::second => now; //lasting 0.5 sec
    440 => s.freq;
    .5::second => now; //lasting 0.5 sec
    880 => s.freq;
    1::second => now; //lasting 1 sec
} 

//part 2 composition (5 seconds) : it is born!
//================================
//add 5 seconds to time now to make 5 seconds composition
now + 5::second => time later1;

while (now<later1)
{
    //only play s with a swept synth sound
    0.5 => s.gain;
    0 => t.gain;
    for(0 => int i; i<400; i++)
    {
        i => s.freq;
        0.001::second => now;
    }
    
    //only play t with a swept snyth sound
    0.1 => t.gain;
    0=> s.gain;
    
    for(0 => int i; i<400; i++)
    {
        i => t.freq;
        0.001::second => now;
    }
    1::second => now;  //adding 1 second after each loop   
}

//part 3 composition (15 seconds) : its life with others!
//================================
//add 15 seconds to time now to make 15 seconds composition
now + 15::second => time later2;
while (now<later2)

{
    //robotic waves
    //play randomised sine wave only for 15 seconds with each note lasting for 0.1sec
    0 => t.gain;
    0.5 => s.gain;
    Math.random2f(30,1000) => s.freq;
    0.1::second => now;

}

//part 4 composition (2 seconds) : something went wrong!
//================================
//add 2 seconds to time now to make 2 seconds composition
now + 2::second => time later3;
while (now<later3)
{
    //play randomised sine wave only for 15 seconds with each note lasting for 0.01sec
    0 => t.gain;
    0.5 => s.gain;
    Math.random2f(30,1000) => s.freq;
    0.01::second => now;
}

//part 5 composition (2 seconds) : malfunctioned!
//================================
//add 2seconds to time now to make 2 seconds composition
now + 2::second => time later4;
while (now<later4)

{
    //set 0 gain to square wave
    0 => t.gain;
    //playing 3 different notes produced by sine wave     
    880 => s.freq;
    1::second => now;    
    440 => s.freq;
    .5::second => now;
    220 => s.freq;
    .5::second => now;
} 

//part 6 composition (0.5 seconds) :died..
//================================
now + 0.5::second => time later5;
while (now<later5)

{
    //produce 0.5 sec of a carpet of sound as an ending!
    0 => t.gain;
    0.5 => s.gain;
    Math.random2f(30,1000) => s.freq;
    0.001::second => now;
}

0 Comments



Leave a Reply.

    Author

    Picture
    View my profile on LinkedIn

    JYISMUSIC

    Call me G  :)
    Hi, my name is Jyi. I am the founder and engineer for JYISMUSIC! I help people produce their favourite songs/covers as well as provide services to companies like Mediacorp! Besides, music, I share things I like, such as food, travel, and some financial/investment tips I read :)
    YOUTUBE CHANNEL
    Follow me 

    Latest Originals


    Do you have music projects you wanna discuss with me?
    ASK ME!
JYISMUSIC

Home
Blog
Follow us

Picture
© 2018 JYISMUSIC ENTERPRISE 
Photo used under Creative Commons from fabian.vervelde
  • Blog
  • WORK WITH US