[LAU] Calculating the sine wave frequencies from the midi key

Arda Eden ardaeden at gmail.com
Sun Oct 19 13:00:26 EDT 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linuxaudio.org/pipermail/linux-audio-user/attachments/20081019/17764505/attachment.htm 


More information about the Linux-audio-user mailing list