📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

altnode.alt-audio-node

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

altnode.alt-audio-node

Base class for customized AudioNode

0.2.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

altnode.AltAudioNode

Build Status NPM Version License

Base class for customized AudioNode

Installation

npm install -S altnode.alt-audio-node

API

AltAudioNode

  • constructor(audioContext: AudioContext)

Instance attributes

  • context: AudioContext

Instance methods

These methods are noop that should be overridden by a subclass.

  • connect(...args): void
  • disconnect(...args): void
  • dispose(): void
    • disconnect and dispose all of the internal nodes

These methods are optional for customized AudioNode.

  • __connectFrom(source: global.AudioNode, output = 0, input = 0): void
  • __disconnectFrom(source: global.AudioNode, output = 0): void
    • called when connecting/disconnecting from WebAudioAPI's AudioNode

Example

import AltAudioNode from "altnode.alt-audio-node";

export default class FeedbackDelayNode extends AltAudioNode {
  constructor(audioContext, maxDelayTime = 1) {
    super(audioContext);

    this._delay = audioContext.createDelay(maxDelayTime);
    this._feedback = audioContext.createGain();

    this._delay.connect(this._feedback);
    this._feedback.connect(this._delay);
  }

  get delayTime() {
    return this._delay.delayTime;
  }

  get feedback() {
    return this._feedback.gain;
  }

  connect(...args) {
    this._delay.connect(...args);
  }

  disconnect(...args) {
    this._delay.disconnect(...args);
  }

  dispose() {
    this._delay.disconnect();
    this._feedback.disconnect();
    this._delay = null;
    this._feedback = null;
  }

  __connectFrom(source, ...args) {
    source.connect(this._delay, ...args);
  }

  __disconnectFrom(source, ...args) {
    source.disconnect(this._delay, ...args);
  }
}
import FeedbackDelayNode from "./FeedbackDelayNode";

let audioContext = new AudioContext();
let bufSrc = audioContext.createBufferSource();
let delay = new FeedbackDelayNode(audioContext);

bufSrc.buffer = RhythmLoop;
bufSrc.loop = true;
bufSrc.start();
bufSrc.connect(delay); // call delay.__connectFrom with [ bufSrc ]

delay.delayTime.value = 0.75;
delay.feedback.value = 0.9;
delay.connect(audioContext.destination);

LICENSE

MIT

Keywords

Web Audio API

FAQs

Package last updated on 16 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts