Skip to content

Commit

Permalink
Ensure that Amazon Voice Focus only receives downmixed mono input. (#…
Browse files Browse the repository at this point in the history
…1458)

When the SDK requests an audio input, it specifies _ideal_
single-channel input. The browser is not guaranteed to return a mono
stream, and indeed builders can supply a stereo stream from their own
audio sources.

This change ensures that the Web Audio graph will provide a
single-channel mixed input to the node, and thus the processor will
receive only a single array of samples.

Co-authored-by: Trung Le <58827450+ltrung@users.noreply.github.com>
  • Loading branch information
richnew10 and ltrung authored Jul 23, 2021
1 parent 4e6016a commit d7f8e34
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve the meeting event guide.
- Fixed Project Board guide with correct community template link.
- Updated Amazon Voice Focus integration guide to reflect recent Safari versions.
- Import current Amazon Voice Focus code, which ensures that stereo inputs are downmixed to mono.

## [2.13.0] - 2021-06-29

Expand Down
2 changes: 2 additions & 0 deletions libs/voicefocus/worklet-inline-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const types_js_1 = require("./types.js");
class VoiceFocusInlineNode extends types_js_1.VoiceFocusAudioWorkletNode {
constructor(context, options) {
super(context, options.processor, options);
this.channelCountMode = 'explicit';
this.channelCount = 1;
const { modelURL, worker, fetchBehavior, logger, } = options;
this.logger = logger;
this.port.onmessage = this.onProcessorMessage.bind(this);
Expand Down
2 changes: 2 additions & 0 deletions libs/voicefocus/worklet-worker-postMessage-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const types_js_1 = require("./types.js");
class VoiceFocusWorkerPostMessageNode extends types_js_1.VoiceFocusAudioWorkletNode {
constructor(context, options) {
super(context, options.processor, options);
this.channelCountMode = 'explicit';
this.channelCount = 1;
const { modelURL, audioBufferURL, worker, fetchBehavior, delegate, } = options;
this.delegate = delegate;
this.worker = worker;
Expand Down
2 changes: 2 additions & 0 deletions libs/voicefocus/worklet-worker-sab-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const STATES = {
class VoiceFocusWorkerBufferNode extends types_js_1.VoiceFocusAudioWorkletNode {
constructor(context, options) {
super(context, options.processor, options);
this.channelCountMode = 'explicit';
this.channelCount = 1;
const { modelURL, resamplerURL, worker, fetchBehavior, delegate, } = options;
this.delegate = delegate;
this.worker = worker;
Expand Down

0 comments on commit d7f8e34

Please sign in to comment.