npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

audio-pipeline

v0.0.4

Published

Simple audio pipeline build upon Web Audio API

Downloads

4

Readme

AudioPipeline

AudioPipeline is a simple class that wraps basic Web Audio APIs, making connect and modify AudioNodes more easily.

Install

install using npm or yarn

npm i audio-pipeline

yarn add audio-pipeline

Basic Usage

// init AudioPipeline
import AudioPipeline from 'audio-pipeline';
const AP = new AudioPipeline();

// pass ArrayBuffer to loadArrayBuffer to init AudioContext
await AP.loadArrayBuffer(buffer);

// then, we can build up our pipeline by using addNode
// first, we should get the source as the starting point.
AP.addNode(AP.getSourceNode());
// then we add effects that we want
AP.addNode(AP.getBiquadFilterNode('lowpass'));
// .... some more awesome effects
// and finally, we put it into the destination
AP.addNode(AP.getDestinationNode());
// after that, we connect those nodes
AP.fullConnect();
// and we play it
AP.control('start', 0);

Add effects while playing

By passing true to the addNode() method, you can add new audio effects to the current pipeline.

AP.addNode(AP.getBiquadFilterNode('highpass'), 2, true);

Modify effects while playing

Using getNode() method, you can get AudioNode instant in specific position, previously, we constructed a pipeline in following order :

Audio Source => lowpass => highpass=>Audio Destination

now we want to change the cut-off frequency of the lowpass filter, which is on position 1.

AP.getNode(1).frequency.value = 200;

APIs

loadArrayBuffer(buffer: ArrayBuffer): Promise

this function initialize the AudioContext with ArrayBuffer

control(action: String, params: Any)

call methods on source object

fullConnect()

connect all nodes added using addNode method

fullDisconnect()

disconnect all nodes

addNode(node: AudioNode [, position: Number, reconnect: Boolean]): AudioNode

add a AudioNode into pipeline, if position not set, the AudioNode will add to the last.

if reconnect is set to true, will reconnect the AudioNodes between the new one, this is useful when you want to add AudioNode dynamically while playing audio.

deleteNode(position: Number [, reconnect: Boolean]): AudioNode

delete specify AudioNode in the pipeline, if reconnect is set to true, will reconnect AudioNodes between the deleted one, this is useful when you want to delete AudioNode dynamically while playing audio.

switchNodes(from: Number, to: Number, [, reconnect: Boolean]): Boolean

Switch two AudioNodes in the pipeline, if reconnect is set to true, will reconnect AudioNodes between the switched AudioNodes, this is useful when you want to switch AudioNodes order dynamically while playing audio.

getNode(position: Number): AudioNode

get specific AudioNode reference in pipeline

clearNodes()

empty pipeline, this method will not disconnect AudioNodes, make sure to call fullDisconnect() before clearNodes()

getBiquadFilterNode(type: String): BiquadFilterNode

Create a new BiquadFilterNode with given type

getOscillatorNode(type: String): OscillatorNode

Create a new OscillatorNode with given type

getGainNode(gain: Number): GainNode

Create a new GainNode with given gain value

getDelayNode(delay: Number): DelayNode

Create a new DelayNode with given delay time

getPannerNode(): PannerNode

Create a new PannerNode

getPeriodicWave(real: Float32Array, imag: Float32Array, constraints; Object): OscillatorNode

Create a new OscillatorNode with given PeriodicWave settings

getDestinationNode()

Get the audio destination

getSourceNode()

Get the audio source

getContext()

Get the AudioContext

How to build

install dependencies first

yarn install

run build

yarn build