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

baudio

v2.1.4

Published

generate audio streams with functions

Downloads

162

Readme

baudio

generate audio streams with functions

oscilloscope

videos

the science and mathematics of music

making algorithmic music with baudio

example

var baudio = require('baudio');

var n = 0;
var b = baudio(function (t) {
    var x = Math.sin(t * 262 + Math.sin(n));
    n += Math.sin(t);
    return x;
});
b.play();

methods

var baudio = require('baudio')

var b = baudio(opts={}, fn)

Return a readable stream of raw audio data based on the function fn(t,i).

fn(t,i) is given the time in seconds t and the step counter i. fn(t,i) should return an amplitude value between -1 and 1, inclusive. Values outside that range will be clipped.

The opts.rate is the rate of the output stream in Hz, default 44000.

b.play(opts)

Play the audio demo with the play command.

You can also call b.pipe() to handle the output stream yourself.

opts are passed directly through to sox.

b.record(file, opts)

Save the audio stream to file using the sox command.

You can also call b.pipe() to handle the output stream yourself.

opts are passed directly through to sox.

usage

usage: baudio FILE {-o OUTFILE} OPTIONS

  Play a javascript music FILE. FILE should export a method signature of:

    return function (t) {
        return Math.sin(2 * Math.PI * t * 441);
    };
  
  where the return value is between -1 and 1, inclusive. Values outside of the
  domain -1 through 1 will be clipped.
  
  If -o is given, output will be written to OUTFILE instead. OUTFILE can be any
  media file that sox supports for output: .mp3, .wav, .ogg, whatever.
  
  You can also use "-" for -o to write to stdout.

  Extra OPTIONS include:

    -d, --duration   How long the song should play as a human-parseable string.

    -t, --offset     Jump to this time offset as a human-parseable string.

    -f, --fade       Length of a trailing fade as a human-parseable string.
 
    -r, --rate       Bitrate to use. Default: 44k.
 
  Example usage:

    Play a song:

      baudio beepboop.js

    Play a song for 30 seconds:

      baudio beepboop.js -d 30s

    Record 3 minutes of audio to beepboop.mp3 starting at 20 seconds:

      baudio beepboop.js -d 3m -t 20s -o beepboop.mp3

install

With npm, to get the library do:

npm install baudio

and to get the command, do:

npm install -g baudio

license

MIT