Skip to content

Commit

Permalink
chore: use package.json instead of .mjs for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ma committed Jan 6, 2025
1 parent c95813c commit c8fa520
Show file tree
Hide file tree
Showing 37 changed files with 12 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import { sleep } from '@ircam/sc-utils';
import { AudioContext, AudioNode } from '../index.mjs';

// Monkeypatching AudioNode.connect to allow for composite nodes.
// https://github.com/GoogleChromeLabs/web-audio-samples/wiki/CompositeAudioNode

class CompositeAudioNode {
class CompositeAudioNode {
get _isCompositeAudioNode() {
return true;
}

constructor(context) {
this.context = context;
this._input = this.context.createGain();
this._output = this.context.createGain();
}

connect() {
this._output.connect.apply(this._output, arguments);
}

disconnect() {
this._output.disconnect.apply(this._output, arguments);
}
Expand All @@ -32,7 +33,7 @@ AudioNode.prototype.connect = function() {
if (args[0]._isCompositeAudioNode) {
args[0] = args[0]._input;
}

this._connect.apply(this, args);
};

Expand Down Expand Up @@ -65,3 +66,6 @@ gainNode.connect(context.destination);

oscNode.start();
oscNode.stop(1.0);

await sleep(1.5);
await context.close();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c8fa520

Please sign in to comment.