1.0.2 • Published 9 years ago

note-player-stream v1.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

note-player-stream

Plays different notes with the Web Audio API based on a stream of input

This module expects to be used with web-midi-note-stream, but accepts any stream which outputs objects that look like the following:

{
	pressed: Boolean, // Whether the button has been pressed/released
	note: Number, // Integer between [0-127] which represents a midi note
	frequency: Number, // The frequency to play the oscillator at (note required for custom nodes)
}

Usage

Install:

npm install --save note-player-stream

Require:

var playerStream = require("note-player-stream");
var player = playerStream({type: "square"});

Example

This example will listen for input from a Launchpad and play sound when a button is pressed

var playerStream = require("note-player-stream");
var noteStream = require("web-midi-note-stream");
var webMidi = require("web-midi");

webMidi("Launchpad")
	.pipe(noteStream())
	.pipe(playerStream());

API

playerStream([options])

Returns an object stream which takes in objects representing device input, and plays sound using the Web Audio API.

Options

PropertyDefaultExplanation
gain0.2How loud the output should be
outputctx.destinationWhat node to output to
nodemake oscillatorFunction that takes data and returns an AudioNode
updateno-opFunction that takes data and a node that can be used to update the node on new data
typesineType of oscillator to create