1

I am using Tone.js to modify sounds:

audio_url = "/sounds/damncoolbeats.m4a"
player = new Tone.Player(audio_url)
modified_player = <some Tone.js modifications to player>

To play the modified sound I would like to use a web audio element so that I can make use of audio.currentTime and eventlisteners to 'play' 'pause' and 'timeupdate' (which I can't seem to do with Tone.js).

The only way I managed to create an audio element so far is by loading from an url:

audio = new Audio(audio_url)

My current hacky solution is to load the original url twice, once in Tone.js and once as web audio, then I play both players simultaneously while keeping the web audio volume at zero. Loading the same http resource twice really messes with my website speed though...

Is there a way to create the web audio element from a Tone.js object?

audio = new Audio(modified_player) //does not work
audio = new Audio(modified_player.buffer) //does not work
audio = new Audio(URL.createObjectURL(modified_player.buffer)) //does not work
Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
mandmeier
  • 355
  • 5
  • 16

0 Answers0