Calculating the sine wave frequencies from the midi key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,
There's a line in the midisine.c code at jack's example client directory.
In this code, Ian Esten has calculated note frequencies in the function below:

void calc_note_frqs(jack_default_audio_sample_t srate)
{
    int i;
    for(i=0; i<128; i++)
    {
        note_frqs[i] = (2.0 * 440.0 / 32.0) * pow(2, (((jack_default_audio_sample_t)i - 9.0) / 12.0)) / srate;
    }
}

after that, a variable called ramp is used to form the sine wave samples in the function process:

ramp += note_frqs[note];
        ramp = (ramp > 1.0) ? ramp - 2.0 : ramp;
        out[i] = note_on*sin(2*M_PI*ramp);

I actually understood what the code does. But can someone show me a place to read information about the equation:

note_frqs[i] = (2.0 * 440.0 / 32.0) * pow(2, (((jack_default_audio_sample_t)i - 9.0) / 12.0)) / srate;

I couldn't catch the relationship in the calculation above.
Thanks.





--
Arda EDEN
Cumhuriyet University
Faculty of Fine Arts
Department of Music Technology
Sivas/TURKEY
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux