0

Can I play RAW audio bytes (parts of audio stream) in JavaScript continuously? I will be sending the stream in parts to JavaScript to some buffer and then the JavaScript will be playing it.

Here is example of the RAW audio bytes (part of audio stream):

\x98\x99\x9a\x9b\x9e\xe9\xe7\xe0\xe3\xde
Foreen
  • 369
  • 2
  • 17
  • 2
    If you're using streams than you'd be able to play audio through a [`MediaStreamAudioSourceNode`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamAudioSourceNode). It is able to receive a `MediaStream` object and pass it to the speakers. As long as your audio is a supported audio format then it should work. – Emiel Zuurbier Dec 29 '20 at 19:40
  • Thank you a lot, but, to which format I must convert my linear RAW audio? When I want to use "audioContext.decodeAudioData..." it says "Uncaught (in promise) DOMException: The buffer passed to decodeAudioData contains an unknown content type." – Foreen Dec 29 '20 at 20:52
  • 1
    Check this [web audio codec guide](https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs) to learn what codecs and formats are supported on the web. – Emiel Zuurbier Dec 29 '20 at 22:44
  • Thanks! And if I have the supported codec, then how can I play the raw bytes? Is there any proven procedure how to play them? – Foreen Sep 15 '22 at 20:00
  • The node referred in the first comment is the best way to play a stream. But it'll be easier to say if you could include some of your code to the question to see how you're implementing your stream. – Emiel Zuurbier Sep 15 '22 at 20:23
  • Check out [https://stackoverflow.com/questions/74751390/what-is-the-best-way-to-stream-audio-to-the-browser-chunk-by-chunk-with-javacr/74768868#74768868](https://stackoverflow.com/questions/74751390/what-is-the-best-way-to-stream-audio-to-the-browser-chunk-by-chunk-with-javacr/74768868#74768868), the question explores sending raw pcm data, and ends up choosing mp3 as the streaming format – Barak Binyamin Dec 13 '22 at 01:12

0 Answers0