Is there a command for....

Blitz3D Forums/Blitz3D Beginners Area/Is there a command for....

po(Posted 2004) [#1]
Is there a command that tells you what the pitch of your sound is? I already know how to change the pitch, but is there a way to find out the original pitch of the sound?


Perturbatio(Posted 2004) [#2]
There isn't a command to do it, so if you really need it, you'll need to write your own or find a dll that will do it.

Try searching on google for pitch detection or frequency analysis algorithms.


Graythe(Posted 2004) [#3]
An easy way to do that is to use a guitar tuner and adjust the frequency until it's at concert A or whatever you want. Once your there double the frequency increase pitch by one octave and halve the frequency to lower pitch by one octave etc.


eBusiness(Posted 2004) [#4]
I think you need to read it from the file. And we talk about the playback rate, not the tone, right?


GfK(Posted 2004) [#5]
An easy way to do that is to use a guitar tuner and adjust the frequency until it's at concert A or whatever you want. Once your there double the frequency increase pitch by one octave and halve the frequency to lower pitch by one octave etc.
??!

I think he meant a command like GetChannelPitch(channel) or GetSoundPitch(sound)...?


Graythe(Posted 2004) [#6]
<<I think he meant a command like GetChannelPitch(channel) or GetSoundPitch(sound)...?>>

Sure Gfk, but Blitz doesn't have on of those. It should be possible to scrounge a guitar tuner from somewhere. Place it close to the speaker, play the sound that you want to know the pitch of and it will measure the pitch. Some tuners will return the frequency, others the name of the note. A at concert pitch is 440hz


jhocking(Posted 2004) [#7]
While he didn't specify, I assume he wants to know the pitch in code, while his game is running. Surely you aren't suggesting that he pop up a dialog box and tell the player to use a guitar tuner?


Graythe(Posted 2004) [#8]
No. Once the pitch of a sample is identified there should be no need to repeat the process.


_PJ_(Posted 2004) [#9]
perhaps the sample is from PlayCDTrack other than a specific file


eBusiness(Posted 2004) [#10]
If it is a common wav-file, then try this:
musicfile=readfile("yourfile.wav")
seekfile musicfile,24
pitch=readshort(musicfile)
closefile musicfile
I'm afraid wav-files can be formatted differently, but I think it is most common to have the pitch on that place. Hope it will help :)