rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.89k stars 160 forks source link

Changing the Rate of a Sound #83

Closed frastlin closed 6 years ago

frastlin commented 6 years ago

Is there any way of changing the speed and or pitch of a recorded sound? Something along the lines of: sound.rate(1.5) or sound.speed(1.5) or sound.pitch(1.5)

I know you can change the speed and pitch of oscillators, but I would like to change the pitch of a recorded sound. Howler does this with sound.rate(1.5).

rserota commented 6 years ago

Wads do have a setSpeed method, but they didn't have speed available as an argument on the constructor, or on play. I just added speed as an argument, so now you should be able to play audio clips at different speeds.

var audioClip = new Wad({source:'/audio-clip.mp3'}) audioClip.play({speed: 0.5}) audioClip.play({speed: 2.0})

frastlin commented 6 years ago

Thank you, it works perfectly! I would personally hesitate at calling it "speed" because it is both speed and pitch, and instead call it rate, but it's not a big deal.