neoRiley

Can you change audio pitch at runtime?

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

Share this post


Link to post
Share on other sites

(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();

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.