1
votes

I'm using javascript getUserMedia() to get access to the users microphone and record the audio with recorder.js

Everything is working fine except that the sound level is very low on mobile (Tested safari and chrome on IOS) but perfect on desktop (Chrome, FF, Safari).

I have tried to adjust the gain with gainNode = audioContext.createGain(); and that will effect the level from 0.0 (no sound) to 1.0 (normal sound) or higher (distorted sound). Problem is that 1.0 i perfect on desktop but very very low on mobile. If i go to e.g. gain=25 then the volume is much higher but also very distorted and therefore not useable.

Is it possible to get good and quality sound level on IOS and how?

Here is my script so fare:

var constraints = { audio: true, video:false }

navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
        
        //Get mic input     
        audioContext = new AudioContext();
        gumStream = stream;
        input = audioContext.createMediaStreamSource(stream);

        //Set gain level
        gainNode = audioContext.createGain();
        gainNode.gain.value = 1.0;
        input.connect(gainNode);

        //Handle recording
        rec = new Recorder(gainNode,{numChannels:1});
        rec.record();

        //Audio visualizer
        analyser = audioContext.createAnalyser();
        freqs = new Uint8Array(analyser.frequencyBinCount);
        input.connect(analyser);
        requestAnimationFrame(visualize);

}).catch(function(err) {

});