Skip to content

Commit

Permalink
Finish AudioSourceNode implementation
Browse files Browse the repository at this point in the history
- Implement volume and pan methods
  • Loading branch information
almic committed Apr 20, 2024
1 parent 8836dc9 commit 54c549f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/AudioSourceNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AudioAdjustmentOptions } from './automation.js';
import automation, { AudioAdjustmentOptions } from './automation.js';
import buildOptions, * as defaults from './defaults.js';

class AudioSourceNodeEvent {
#propagationStopped = false;
Expand Down Expand Up @@ -238,13 +239,23 @@ class AudioSourceNode {

volume(volume: number, options?: AudioAdjustmentOptions): AudioSourceNode {
this.throwIfDestroyed();
console.log(`stub volume ${volume} with options ${options}`);
automation(
this.audioContext,
this.gainNode.gain,
volume,
buildOptions(options, defaults.automationDefault),
);
return this;
}

pan(pan: number, options?: AudioAdjustmentOptions): AudioSourceNode {
this.throwIfDestroyed();
console.log(`stub pan ${pan} with options ${options}`);
automation(
this.audioContext,
this.stereoPannerNode.pan,
pan,
buildOptions(options, defaults.automationDefault),
);
return this;
}

Expand Down

0 comments on commit 54c549f

Please sign in to comment.