Jump to content

Can you change audio pitch at runtime?


neoRiley
 Share

Recommended Posts

well, just to answer this so no one comes here thinking I abandoned this - I abandoned this idea ;)

 

When I found out that IE doesn't support webaudio, it made it pointless.

 

So, my solution was to take 2 different car engine sounds - one idle, the other rev'd up and I cross fade them together by setting their volumes to the speed of the car.  A slower speed means the idle sound is louder, and when as you accelerate, the rev'd sound becomes louder

 

Anyway, hope that helps someone else

Link to comment
Share on other sites

  • 4 months later...

(resurrecting an old thread)

 

Seems like it would be neat to be able to programmatically alter pitch/playing speed.

Even though it seems IE and Android doesnt support WebAudio, has anyone got this working in Phaser?

I read WebAudio supports it, but wasnt able to get it to work in Phaser.

 

http://updates.html5rocks.com/2012/01/Web-Audio-FAQ

 

Q: How can I change the pitch of a sound using the Web Audio API?

A: Change the playbackRate on the source node.

 

 

I tried this, but to no effect:

//mySound = a Phaser.Sound objectvar pbr =  { value: 2, defaultValue: 2};this.mySound._sound.playbackRate = pbr;this.mySound.play();
Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...

This is like the first thing that comes up on google for how to change pitch.  The last comment doesn't quite do it.  After some playing around, I found that I actually had to play the sound before altering it immediately after:

this.mySound.play();
this.mySound._sound.playbackRate.value = 1.2;

This worked for me

Link to comment
Share on other sites

  • 1 year later...
On 6/13/2016 at 10:43 PM, ritherz said:

This is like the first thing that comes up on google for how to change pitch.  The last comment doesn't quite do it.  After some playing around, I found that I actually had to play the sound before altering it immediately after:


this.mySound.play();
this.mySound._sound.playbackRate.value = 1.2;

This worked for me

This works great, but not on iOS. Anyone know how to change the pitch on iOS devices?

 

Thanks.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...