Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel Count always 2? #70

Open
dalisalvador opened this issue Dec 8, 2022 · 1 comment
Open

Channel Count always 2? #70

dalisalvador opened this issue Dec 8, 2022 · 1 comment

Comments

@dalisalvador
Copy link

The number of channels on dataavailable ALWAYS seems to be 2(stereo).
No matter the source stream, the output stream always has 2 channels.

I need to get a mono output but I can't accomplish this.

Is there any way to achieve this?

Thanks

                        
recorder = new OpusMediaRecorder(dest.stream <<=== MONO, { mimeType: 'audio/ogg; codecs=opus' }, workerOptions)
recorder.addEventListener('dataavailable', async function (e) {
	if (e.data.size > 0) {
		const offlineAudioContext = new OfflineAudioContext({
			length: 1,
			sampleRate: 48000
		})
		const audioBuffer = await offlineAudioContext.decodeAudioData(await e.data.arrayBuffer())
		console.log(audioBuffer.numberOfChannels) <<< 2!!!				}
	})
@dalisalvador
Copy link
Author

dalisalvador commented Dec 8, 2022

I think I found the problem.

The source stream is actually a stereo stream that is processed, converted to mono, and then sent to a destination.

For some reason, only happening in chrome (I think there's an open issue/bug) the getSettings().channelCount will always return 2 even though it was previously changed to 1. This will ultimately affect the line below (see OpusMediaRecorder.js)

this.channelCount = tracks[0].getSettings().channelCount || 1;

I think that the constructor should have the optional channelCount... if it's ok I could create a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant