Changing pitch to play notes of an octave

BlitzMax Forums/BlitzMax Programming/Changing pitch to play notes of an octave

Grey Alien(Posted 2007) [#1]
Hiya, Anyone know how much I should change the pitch that I play a channel in order to play the notes of an octave.

For example, let's say middle C is when the sample is played at 1.0 (normal), how much should I play at to get C#, D, etc all they way up to the nextg C (2.0). Thanks!


CoderLaureate(Posted 2007) [#2]
An excellent page describing 12 note entonation can be found here http://thinkzone.wlonk.com/Music/12Tone.htm


Grey Alien(Posted 2007) [#3]
Excellent thanks, just what I needed! :-)


REDi(Posted 2007) [#4]

Note is 0 for middle C, 1=C#, 2=D, 3=D#.. 12=C (+1 octave)
negative numbers also work.
you can even slide between notes by using a float value.

hope that helps

*EDIT* damn, didnt notice the math on that page til now. lol


Damien Sturdy(Posted 2007) [#5]
Nice post.

Grey, you could have checked my sound system out. Working code in there to do it :-D


Grey Alien(Posted 2007) [#6]
Cool, thanks Redi, I've used that 2^(Note/12) formula.

Cyg: Could've but I forgot ;-)


Grey Alien(Posted 2007) [#7]
Is there an easy way to only play the notes of C major based on a Note sent in which is in the range 0-7? The only way I can think is to prefill an array and use Note to reference that. But that's a pain so I wondered if it was possible with a formula and a couple of IF ELSEIFs etc ?


Damien Sturdy(Posted 2007) [#8]
Yes, i'd do it by an array,

One per chord. instead of using absolute values, use offsets. Any major chord would in this instance be [0,4,7]

You could probably cut it down to 2 notes in the array of each chord because obviously the first note of a C chord is going to be C. Since you pass this to the func anyway, you dont need to read it out of an array :-)

What are you up to Grey? I wouldnt mind a nose!


Grey Alien(Posted 2007) [#9]
thanks. I'm making a gauge rise every time the user performs a certain action and I want it to play notes in a scale of C major so they don't go out of tune or key with the music.


Damien Sturdy(Posted 2007) [#10]
Great idea. That should work well. Let me know if you get any problems. (I'll sign back up to Skype when I get home, but you shouldn't have any problems anyway.)