Giter VIP home page Giter VIP logo

baudio's Introduction

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

baudio's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.