Legacy GM Detect music pitch and change sound pitch.

N

NoFontNL

Guest
Let's say I have game music, and the music hits a low note, can you detect the pitch of that note and change the pitch of a sound effect according to that information.
Is this possible in GameMaker?
 

Relic

Member
I believe you would need an extension. There are no native functions for returning pitch information. GameMaker can adjust and return pitch of a sound resource, but only as a multiplier and not "the pitch of a particular note".
 
N

NoFontNL

Guest
What keywords should I use to find that sort of extension?
 

Binsk

Member
The pitch of a sound, when looking at the raw data, is determined by the length of the periods of its waves.

To alter pitch you need to alter the period. To alter the period is also to alter the speed at which it plays (GM should have this function). If you wish to alter the pitch and NOT the speed then you'll be getting into the non-trivial idea of "pitch shifting" (GM does NOT have this function and it would need to be calculated manually).

I am not positive but you may need the Fourier Transform to determine pitch (which is also used in pitch shifting) since it can help determine individual frequencies.

Use this info if its helpful.
 
Last edited:

Gamebot

Member
Look up OSCILLATOR, meaning you will be using the sine wave (sin function). You will need to know the Amplitude, Period, and wavelength. You should be able to find a list of all frequencies(in Hertz) to notes somewhere also. Generally, higher notes are higher frequencies while lower notes are lower frequencies.

If lower notes by themselves sound slower and higher notes sound faster, this means you may need to look up time stretching .

EDIT: Forgot to put in "music" in front of oscillator. It's all the same.

Found something for you (Brings back the memories):
https://www.khanacademy.org/science...perties-amplitude-period-frequency-wavelength
 
Last edited:
N

NoFontNL

Guest
How do I then check a part of the soundtrack? I'm playing the background music, how would I get the sound of the current track position, and how would I read the frequency of that given position?
 
Top