JSPM

  • Created
  • Published
  • Downloads 1619
  • Score
    100M100P100Q112102F
  • License BSD-3-Clause

Node.js bindings for web-audio-api-rs using napi-rs

Package Exports

  • node-web-audio-api
  • node-web-audio-api/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-web-audio-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-web-audio-api

Nodejs bindings for orottier/web-audio-api-rs using napi-rs

Install

npm install [--save] node-web-audio-api

Example

import { AudioContext, OscillatorNode, GainNode } from 'node-web-audio-api';

const audioContext = new AudioContext();

setInterval(() => {
  const now = audioContext.currentTime;

  const env = new GainNode(audioContext);
  env.connect(audioContext.destination);
  env.gain.value = 0;
  env.gain.setValueAtTime(0, now);
  env.gain.linearRampToValueAtTime(1, now + 0.02);
  env.gain.exponentialRampToValueAtTime(0.0001, now + 1);

  const osc = new OscillatorNode(audioContext);
  osc.frequency.value = 200 + Math.random() * 2800;
  osc.connect(env);
  osc.start(now);
  osc.stop(now + 1);
}, 50);

Build manually

If prebuilt binaries are not shippped for your platform, you will need to install the rust toolchain and install and build the package from github.

  1. Install rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Install from github
npm install --save git+https://github.com/b-ma/node-web-audio-api.git

Note that the package will be built on your machine, so the install process might be a bit long

Roadmap

License

This project is licensed under the BSD-3-Clause license.