Skip to content

Issue: Electron14.1.0 can't record truly stereo audio #216

@hongdyu

Description

@hongdyu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions