On Sun, Oct 19, 2008 at 08:00:26PM +0300, Arda Eden wrote:
> 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.
Midi note numbers are just a count in semitones.
There are twelve semitones in an octave, which
is a frequency ratio of 2:1.
So given two note numbers that are N semitones apart,
the ratio of their frequencies is
2 ^ (N / 12), or in C: pow (2.0, N / 12.0)
Now MIDI note number 9 (an 'A', note number 0 is the 'C'
below that) has the frequency 880 / 32 Hz, five octaves
below the 880 Hz 'A'.
So to get the scale right we use
F = 880.0 / 32 * pow (2.0, (i - 9) / 12.0)
For i = 9 this becomes
F = 880.0 / 32 * pow (2.0, 0)
= 880.0 / 32 * 1
= 880.0 / 32
as required.
Ciao,
-- FA Laboratorio di Acustica ed Elettroacustica Parma, Italia Lascia la spina, cogli la rosa. _______________________________________________ Linux-audio-user mailing list Linux-audio-user@email-addr-hidden http://lists.linuxaudio.org/mailman/listinfo/linux-audio-userReceived on Mon Oct 20 00:15:02 2008
This archive was generated by hypermail 2.1.8 : Mon Oct 20 2008 - 00:15:03 EEST