Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenAl pitch values for particular musical notes in an octave

I have an OpenAl sound engine on my iPhone app. When I play a sound that I have loaded, I can control it's pitch.

In OpenAl a pitch set to 1.0 has no effect. If you double it to 2.0, it plays the note 1 octave higher(12 semitones). If you halve it, to 0.5, it will be an octave lower (12 semitones).

So, my original sample is playing a C. I assumed that if I divide 1 by 12 (semitones) I could get the pitch for the individual notes in that octave. But this does not seem to be the case. Which makes we think that semitones are not equal values. Is that true?

Does anyone know how I can work out the openAl pitch value for individual notes in an octave?

Thank you

like image 972
Jonathan Avatar asked Feb 09 '10 02:02

Jonathan


Video Answer


1 Answers

Semitones are equal ratios. So, if your sample is C, C# will be the 12th root of two. If you count semitones C=0, C#=1 etc, the ratio is pow(2.0, n*1.0/12.0)

Works for negative numbers, too.

I should note, this is not strictly true in every tuning scheme... but this is a good start. If you really care about the full complexities of musical tuning, I can find you some references.

like image 168
Andrew McGregor Avatar answered Sep 18 '22 02:09

Andrew McGregor