GM:S 1.4 Detect music pitch and change sound pitch.

Discussion in 'Programming' started by NoFontNL, Jun 8, 2019.

  1. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    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?
     
  2. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    627
    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".
     
  3. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    What keywords should I use to find that sort of extension?
     
  4. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    542
    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: Jun 8, 2019
  5. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
  6. Gamebot

    Gamebot Member

    Joined:
    Jul 3, 2016
    Posts:
    173
    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: Jun 9, 2019
  7. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice