| Subscribe via RSS

New to classical? Want to get started? Visit my beginners guide to classical music! Or start browsing the different composers.

It’s Alive!!

September 11th, 2010 | No Comments | Posted in classical music

My recent post, A Symphony in C++, was featured today at the rather stunningly designed (and rather new) blog Killing Classical Music. The author of the blog, Grant, describes his blog as:

Dedicated to rescuing the world’s best music from a slow, certain death at the hands of tired traditions and oppressively ordinary thought

Quite a mission statement! Check it out here.

Tags: ,

Symphony in C++

August 19th, 2010 | 10 Comments | Posted in classical music

Every now and then I can’t keep my classical music and science nerd parts apart.

Today was one of those days.

I present: A Symphony in C++:

key get_secondary_key(key home_key){
    if (home_key.minor == TRUE){
        secondary_key=relative_major(home_key);
    }else{
        secondary_key=home_key+5;
    }
}
 
void sonata_form(key home_key,tempo base_tempo){
    //Calculate secondary key
    secondary_key=get_secondary_key(home_key);
 
    //First get people in the mood
    intro.play(home_key,base_tempo--);
 
    //start exposition, introduce the two main themes
    theme_1.play(home_key);
    transition.play(home_key,secondary_key);
    theme_2.play(secondary_key);
    codetta.play();
 
    //development, mix the themes up
    for(int i=0;i<development_length;i++){
        combine_themes(theme_1,theme_2,key=rand()).play()
    }
 
    //Recapitulation: repeat the themes but in the home key
    theme_1.play(home_key);
    transition.play(home_key,home_key);
    theme_2.play(home_key);
 
    //Finish up
    if(composer == "beethoven"){
        coda.length_in_min=10
    }else{
        coda.length_in_min=1
    }
    coda.play();
}

Want to learn more about classical music but without the code? Go to getintoclassical.com.

Tags: , ,