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

wae-cli

v0.6.0

Published

web-audio-engine command line

Downloads

9

Readme

wae-cli

NPM Version License

web-audio-engine command line

Installation

$ npm install -g wae-cli

Usage

You can write a code using the Web Audio API via audioContext.

// coin.js
const osc = audioContext.createOscillator();
const amp = audioContext.createGain();

osc.type = "square";
osc.frequency.setValueAtTime(987.7666, 0);
osc.frequency.setValueAtTime(1318.5102, 0.075);
osc.start(0);
osc.stop(2);
osc.connect(amp);
osc.onended = () => {
  process.exit();
};

amp.gain.setValueAtTime(0.25, 0);
amp.gain.setValueAtTime(0.25, 0.075);
amp.gain.linearRampToValueAtTime(0, 2);
amp.connect(audioContext.destination);

simplest playback (using node-speaker)

$ wae coin

playback using ALSA aplay via stdout

$ wae coin -o stdout | aplay -f cd

playback using SoX play via stdout

$ wae coin -o stdout | play -t s16 -r 44100 -c 2 -

render to an audio file

$ wae coin -o coin.wav

other options

$ wae --help
wae [option] script-name [args]

  -h, --help             display help
  -v, --version          display version
  -t, --type String      file type of audio - default: s16
  -r, --rate Number      samplerate of audio - default: 44100
  -c, --channels Number  number of channels of audio: e.g. 2 = stereo - default: 2
  -d, --duration Number  number of duration for rendering
  -o, --out String       write output to <file> - default: speaker
  -V, --verbose          run in verbose mode - default: false

AUDIO FILE FORMAT: s16 s32 u8 raw cd

provide arguments

You can provide arguments from command line using node module style function. The arguments are parsed as JSON.

// beep.js
module.exports = (audioContext, frequency, duration) => {
  const osc = audioContext.createOscillator();
  const amp = audioContext.createGain();

  osc.frequency.value = frequency;
  osc.start(0);
  osc.stop(duration);
  osc.connect(amp);

  amp.gain.setValueAtTime(0.5, 0);
  amp.gain.linearRampToValueAtTime(0, duration);
  amp.connect(audioContext.destination);
};
$ wae beep -- 1760 0.5

asynchronous code

You can run asynchronous code using Promise.

const fs = require("fs");

module.exports = (audioContext) => {
  const buffer = fs.readFileSync("coin.wav");

  return audioContext.decodeAudioData(buffer).then((audioBuffer) => {
    const bufSrc = audioContext.createBufferSource();

    bufSrc.buffer = audioBuffer;
    bufSrc.start(0);

    bufSrc.connect(audioContext.destination);
  });
};

License

MIT