0

I use Web Audio API in my website. Lets say I have this code:

var audioContext = new Audiocontext()
var audio = new Audio()
audio.src = "someaudiofile.wav"
var mediaSourceNode = audioContext.CreateMediaElementSource(audio)
mediaSourceNode.connect(audioContext.destination)

audio.playbackRate = 0.5

When I set the 0.5 playbackRate, the audio becomes a little robotic/distorted.

We also have an old .Net based audio player based on Bass .Net library, which fix this issue by setting the property Bass_attrib_tempo_option_sequence_ms according to the new tempo, but I didnt find a corresponding property in Web Audio api.

Does someone have any experience with this? Thank you!

Alon Dayan
  • 101
  • 1
  • 6

1 Answers1

0

As you already found out the AudioBufferSourceNode just resamples the audio to slow it down or to speed it up. This behavior is defined by the spec.

I'm not familiar with the source code of the Bass .Net library but from looking at the options it exposes I would guess it uses an implementation of the SOLA algorithm under the hood. Luckily there is also an implementation in JavaScript (soundtouchjs) which will hopefully give you similar results as the aforementioned .Net library.

chrisguttandin
  • 7,025
  • 15
  • 21