I aim to capture sound via microphone and then process it. To do that I need to obtain the number of channels, sampling rate and sampling size of the audio.
For recording I use MediaRecorder, which works just fine:
navigator.mediaDevices.getUserMedia (
{
audio: true
})
.then(function(stream) {
const mediaRecorder = new MediaRecorder(stream);
set_record(mediaRecorder)
set_stop(mediaRecorder)
});
After being done recording I create blob of type 'audio/flac' as follows:
let chunks = [];
mediaRecorder.ondataavailable = function(e){
chunks.push(e.data);
}
mediaRecorder.onstop = function(e){
const blob = new Blob(chunks, { 'type' : 'audio/flac;' });
chunks = [];
}
Now the problem is that if I download the blob and try to read it, its metadata are weird. I haven't found any documentation as to how should I read it. The closest is this StackOverflow question that is left unanswered link.
I have tried different codecs each giving me the same metadata part with slight nuances on different browsers.
Is there a way to set the parameters to get an audio file with a given sampling rate/channel count/sampling size? If so, can I rely on it to be the same across different browsers? Or is there a way to read the metadata or tell it to write desired parameters into them?