With regular WebAudio, I can connect a bufferSource to destination like so:
const audioCtx = new AudioContext()
const bufferSource = audioCtx.createBufferSource()
bufferSource.connect(audioCtx.destination)
I thought I could do the same with Tone.js, but this:
const audioCtxTone = Tone.context
const bufferSource = audioCtxTone.createBufferSource()
bufferSource.connect(audioCtxTone.destination)
give the error Argument of type 'Destination' is not assignable to parameter of type 'AudioNode'.
What am I doing/thinking wrong here?
I can't exactly explain why your code doesn't work. Tone.js uses standardized-audio-context which provides a wrapper around the Web Audio API to make it more compatible across different browsers. Tone.js has it's own very thin wrapper on top of standardized-audio-context. I assume something is going wrong along the way.
But it should work if you use the
contextproperty of theAudioBufferSourceNodeinstead. It should point to the rightAudioContext.