SCALE.C
          

Here is my first little Interactive C program.  Pretty simple and cheesy-hence the yellow!

void main()

{

   /* This is just a little test program I wrote to learn how to use the Handyboard.  When loaded and     

    run on the Handyboard,  the program will use the speaker to play an octave scale starting at middle

    C (256 kHz).  To find the successive notes, I used the formula that takes the starting note (in this

    case, middle C - 256 kHz) and counts the steps and half steps from the starting note. For example, it

    is 2 steps from C to D because the scale is C C# D. The formula is 256 * [(12th root of 2)]^number  

    of steps. */

   /* Create floating point variables for pitch frequency and length */

  float frequency = 256.0;

  float length =1.0;

  tone (frequency, length);  /* Play middle C for 1s. */

   frequency = 287.3502844;

  tone (frequency, length);  /* Play D for 1s */

  tone (frequency, length);  /* Play D for 1s */

   frequency = 322.5397883;

  tone (frequency, length); /* Play E for 1s */

   frequency = 341.7190021;

  tone (frequency, length); /* Play F for 1s */

   frequency = 383.5666100;

  tone (frequency, length); /* Play G for 1s */

   frequency = 430.5389633;

  tone (frequency, length); /* Play A for 1s */

  frequency = 483.2636463;

  tone (frequency, length); /* Play B for 1s */

   frequency = 512.0;

  tone (frequency, length); /* Play octave C for 1s */

 /* Interesting fact: Ratio of frequencies between same notes

   that are 1 octave apart is 2:1 */

 }

 

Questions? E-mail me!