How do I create Doppler Effects for Sound

0 favourites
  • 8 posts
From the Asset Store
Grenade Sound Library contains: 135 sounds 50 grenade sounds and 85 surface sounds
  • Hey guys,

    I've been reading on the forum and the whole internet about how easy it was to implement Doppler effects with sound. Then I read it was removed due to some google update (thanks so much for making life hard, google!) Even though this feature is no longer something that can be done using a pre-made construct 2 feature, is it possible to create a doppler sound and how can this be accomplished?

    Reason I am asking is because my game is going to rely on this effect to help make it reeaaaaaaallly cool with sound.

    Thanks for your help!

  • Wikipedia gives the equation for the doppler effect. Basically it's to change the frequency of the sound based on the speeds of the source and the listener.

    The speeds need to be relative between the objects. For the source for example:

    ang = angle(source.x,source.y,listener.x,listener.y)

    speedsource = source.velocityX*cos(ang) + source.velocityY*sin(ang)

    The listener speed is about the same but uses it's speed instead and the ang is from the listener to the source.

    The frequency is calculated with:

    (speedofsound + listenerspeed)/(speedofsound + sourcespeed)

    "speedofsound" is something you can tweak, I used something like 3400 to make the effect more subtle.

    Use the frequency to set the playback speed.

    Here's an experiment of it. In it I used positional sound and some volume fade off.

    examples31/doppler.capx

    https://www.dropbox.com/s/sfs9uqb7vy9bo ... .capx?dl=1

  • Hello R0j0hound,

    I apologise for taking so long to respond. I have had to work on other problems first before coming back to this.

    I am trying to iron out some issues, but you really helped put me in the right direction. Thank you so much for your help, I could not have implemented this appropriately for my game without your help!

  • No problem. It was fun to make.

  • Wouldn't still have that source around would you? It would save a bit of time...

  • Paradox

    Updated link in post

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Since this post is about audio effects, is there any way to do Pitch?

    I want to add a bit of variation to repeating sounds in my game.

    I know I can create and upload different versions of the same sound, but I hope there is an easier solution.

    The closest effect I could find that does something similar is "Ring modulator", but it doesn't work well with some sounds.

    Changing playback rate is also not a good option.

  • Changing the playback rate works to change pitch. I've used it to make a piano from one sound. I guess a drawback is the length of the sound changes too, but there isn't another way to change pitch.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)