I'm currently working on a project that use HTML5 audio and we have problems with the limitations on iOS devices (mostly multiple audio channels limitation).
I was thinking that it may be possible to control the sounds server-side using node.js. The client would connect to a single audio url and the node server will stream live sounds trough this single channel doing all the mixing and transitions live on the server.
Is it technically possible? Can you parse audio on node.js and do some live mixing? Do you think the server will explode with more than 5 simultaneous clients?
Thanks
HTML5 defines a new element which specifies a standard way to embed an audio file on a web page using the <audio> element. Your browser does not support the audio tag.
HTML5 defines a new element which specifies a standard way to embed an audio file on a web page using the <audio> element. Your browser does not support the audio tag. The above <audio> element adds audio controls like play, pause and volume automatically on the web page.
First add the BinaryJS library. Now start a connection. When ready, create a write stream. Going back to our custom node let's send the audio to the stream. Everything should be ready on the client side now. Our recorderProcess function is called for each audio chunk, and each is sent to the server. But we aren't ready yet!
Look at the HTML Markup and its output in a browser. Type sample audio url having .mp3 exetension and click on play button. Audio Tag not Supported. Now to apply the action in the above HTML Markup, we need to write some JavaScript. Find the JavaScript methods below: // Global variable to track current file name. // Check for audio element support.
Yes, this is entirely possible, but as Sam pointed out, buffering is an issue. There is significant delay that builds up over several points:
Add this all up, and even if you get it working very quickly, you're still looking at a couple seconds delay.
If you do decide to go this route, you'll need an external application (or write your own Node extension) to do the mixing and encoding for you. Sox is probably a decent choice, and FFMPEG includes many codecs for your use. You can use both over STDIO.
Regarding server load... this is not a light-weight kind of process, but you would have to profile it to see how bad it really is. I suggest you make other attempts at playing multiple audio streams at once client-side before attempting something like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With