I want to take audio input from a browser and pass it to multiple listeners. The intended use is for music, so the quality should conform to the mp3 standard or so.
I tried to make two paths, both giving unsuccessful results:
WebRTC
- Audio streaming between browsers works fine, but the sound quality doesn't seem to be customizable, although what I saw. (I saw that it uses the Opus sound codec, but does not seem to provide any controls).
- Does anyone know how to improve sound quality in WebRTC streams?
Web sites
The problem is transportation from the browser to the server. The PCM audio data that I can get using the method below turned out to be too large to transmit to the server many times over web ports. Stream works fine in high-speed Internet environments, but on slower Wi-Fi it is unsuitable.
var context = new webkitAudioContext() navigator.webkitGetUserMedia({audio:true}, gotStream) function gotStream (stream) { var source = context.createMediaStreamSource(stream) var proc = context.createScriptProcessor(2048, 2, 2) source.connect(proc) proc.connect(context.destination) proc.onaudioprocess = function(event) { var audio_data = event.inputBuffer.getChannelData(0)|| new Float32Array(2048) console.log(audio_data)
So, the main question is, is there a way to compress PCM data in order to simplify the flow to the server? Or maybe there is an easier way to do this?
html5 websocket webrtc getusermedia web-audio
IyadAssaf
source share