OpenAl pitch values for particular musical notes in an octave
Asked Answered
L

1

6

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

Lacteous answered 9/2, 2010 at 2:58 Comment(0)
R
12

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.

Rockwell answered 9/2, 2010 at 4:14 Comment(3)
Thank you Andrew! this is perfect!... exactly what I was after! And yes references would be great. In particular the relationship between pitch and length of sample. Thanks again.Lacteous
Oh, well, the length just gets shorter by the same ratio. I'll find a good introduction to scales and tuning.Rockwell
en.wikipedia.org/wiki/Mathematics_of_musical_scales and en.wikipedia.org/wiki/Equal_temperament will get you into the thicket of wikipedia articles about this topic. It gets hugely complicated after a while, but it's also very important to practical music, especially if you're working with string or wind instruments.Rockwell

© 2022 - 2024 — McMap. All rights reserved.