xorg1990
New member
Hi, ich habe noch ein verwirrendes Problem in FF.
Ich möchte einfach nur ein Stero Input in FF haben, in allen anderen Browsern geht das doch auch.
Aktuell ist es so, das ein Elektretmikrofon ja nur mono ist (mono = nur links). Demzufolge dürfte nur Links ein Pegel anliegen tut es aber nicht, die dB's sind rechts genau sol stark wie links. Jetzt könnte man ja annehmen "ok, die machen aus dem mono ein Stereo". Nope, steckt man das Mic in den rechten Kanal ist rechts auch wider links.
Also links ist rechts, rechst ist links. und vice Versa.
Irgendwie das Total durcheinander
Fakt ist: Wenn getUserMedia bzw. createMediaStreamSource() mono wäre, dann dürfte wenn ein Signal auf den rechten Kanal anliegt, das Singal nie die Web audio api erreichen!!
Tut es aber de facto ist der Eingang Stereo aber wie mache ich die Kanäle aus??????
Habe mal was vorbereitet:
Habe auch schon mit den ChannelSplitter und ChannelMerger gearbeitet bringt nix, da kommen nur Fehlermeldungen:
Das kommt aus dem console.log in onRecordFail()
Zu eruieren reicht ein normales Elektretmikrofon aus, wenn alles richtig funktioniert sind auf den linken Kanal mehr Decibel als au den Rechten.
Am ende brauche ich beide Kanäle getrennt ScriptProcessor.
Ich möchte einfach nur ein Stero Input in FF haben, in allen anderen Browsern geht das doch auch.
Aktuell ist es so, das ein Elektretmikrofon ja nur mono ist (mono = nur links). Demzufolge dürfte nur Links ein Pegel anliegen tut es aber nicht, die dB's sind rechts genau sol stark wie links. Jetzt könnte man ja annehmen "ok, die machen aus dem mono ein Stereo". Nope, steckt man das Mic in den rechten Kanal ist rechts auch wider links.
Also links ist rechts, rechst ist links. und vice Versa.
Irgendwie das Total durcheinander
Fakt ist: Wenn getUserMedia bzw. createMediaStreamSource() mono wäre, dann dürfte wenn ein Signal auf den rechten Kanal anliegt, das Singal nie die Web audio api erreichen!!
Tut es aber de facto ist der Eingang Stereo aber wie mache ich die Kanäle aus??????
Habe mal was vorbereitet:
Code:
<!DOCTYPE html>
<html>
<head>
<title>ScriptProcessor_test</title>
<script type="text/javascript">
function run() {
var audioCtx = new(window.AudioContext || window.webkitAudioContext || mozAudioContext || oAudioContext || msAudioContext || null)();
var processor = (audioCtx.createScriptProcessor || audioCtx.createJavaScriptNode).call(audioCtx, 16384, 2, 1);
//making destination to stereo only
audioCtx.destination.channelCount = 2;
audioCtx.destination.channelCountMode = "explicit";
audioCtx.destination.channelInterpretation = "discrete";
var onRecordFail = function(e) {
alert("Media caputure not supportet in this Browser");
console.log(e);
}
function audioProcess(e) {
var inputLe = e.inputBuffer.getChannelData(0); // microphone
var inputRe = e.inputBuffer.getChannelData(1); //right is transceiver
var outputLe = e.outputBuffer.getChannelData(0); // one output;
var len = inputLe.length
var total1 = total2 = 0;
var rms1 = rms2 = 0;
for (var i = 0; i < len; i++) {
total1 += Math.abs(inputLe[i]) //left
total2 += Math.abs(inputRe[i]) //right
}
rms1 = Math.sqrt(total1 / (len / 2)); //left
rms2 = Math.sqrt(total2 / (len / 2)); //right
var decibelLe = 20 * Math.log10(rms1);
var decibelRe = 20 * Math.log10(rms2);
document.getElementById("dBLeft").textContent = Math.round(decibelLe) + " dB";
document.getElementById("dBRight").textContent = Math.round(decibelRe) + " dB";
}
//Process event handler
processor.onaudioprocess = audioProcess;
function gotStream(stream) {
// Create an AudioNode from the stream.
window.source = audioCtx.createMediaStreamSource(stream);
window.source.channelCount = 2;
window.source.channelCountMode = "explicit"
window.source.channelInterpretation = 'discrete';
window.source.connect(processor);
processor.connect(audioCtx.destination);
}
function init() {
if (navigator.mediaDevices.getUserMedia) {
//select constraints
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
var isFirefox = navigator.userAgent.search("Firefox");
var constraints;
if (isChrome) {
constraints = {
audio: {
mandatory: {
echoCancellation: false,
googEchoCancellation: false,
googAutoGainControl: false,
googNoiseSuppression: false,
googHighpassFilter: false
},
optional: []
}
};
} else if (isFirefox > -1) {
constraints = {
audio: {
echoCancellation: false,
mozAutoGainControl: false,
mozNoiseSuppression: false
}
};
} else {
constraints = {
audio: {
echoCancellation: false,
}
};
}
navigator.mediaDevices.getUserMedia(constraints).then(gotStream).catch(onRecordFail);
} else if (navigator.getUserMedia) {
constraints = {
audio: true,
video: false
}
navigator.getUserMedia(constraints, gotStream, onRecordFail);
} else {
alert("Media caputure not supportet in this Browser");
onRecordFail();
}
}
init();
}
</script>
</head>
<body onload="run()">
Left Channel:
<div id="dBLeft"></div>
<br> Right Channel:
<div id="dBRight"></div>
</body>
</html>
Code:
DOMException [IndexSizeError: "Index or size is negative or greater than the allowed amount"
code: 1
nsresult: 0x80530001
Zu eruieren reicht ein normales Elektretmikrofon aus, wenn alles richtig funktioniert sind auf den linken Kanal mehr Decibel als au den Rechten.
Am ende brauche ich beide Kanäle getrennt ScriptProcessor.
Zuletzt bearbeitet: