-
Notifications
You must be signed in to change notification settings - Fork 53
Description
I'm using the Web Audio API ScriptProcessorNode and AudioWorkletNode to record the stereo audio. But the final audio recording is not truly stereo since the left and right channel data is the same.
This issue occurred on upgrading Electron version from v6 to v14 and add the dependency '@electron/remote'. The same code for recording audio, but previously it output the correct stereo audio.
Can anyone help to give some suggestions or point out what go wrong? Appreciate in advance.
Below are some examples for getting microphone setting:
//The job of audio recording running in the renderer process
let win = new BrowserWindow({
show: false,
parent: remote.getCurrentWindow(),
modal: true,
webPreferences: { plugins: true, webSecurity: false, nodeIntegration: true, contextIsolation: false },
width: 800,
height: 600,
});
// microphone setting
let config = {
audio: {
deviceId: {exact: deviceId},
channelCount: {exact: 2},
}
navigator.mediaDevices.getUserMedia(config).then((stream) => {
try {
let audioTrackSettings = stream.getAudioTracks()[0].getSettings();
log.info(AudioStream audioTrack->settings: , audioTrackSettings.channelCount); // It shows the channelCount is 2
let mediaNode = this.context.createMediaStreamSource(stream);
let node = this.context.createScriptProcessor.call(this.context, 4096, 2, 2);
}catch(err){}
).catch(e => {});
Platform
OS: Windows 11
electron: v14.1.0
Nodejs: v16.20
@electron/remote: v2.0.0
vue: v2