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/releasednote: Number // Integer between [0-127] which represents a midi notefrequency: 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 = ;var noteStream = ;var webMidi = ;;
API
playerStream([options])
Returns an object stream which takes in objects representing device input, and plays sound using the Web Audio API.
Options
Property | Default | Explanation |
---|---|---|
gain | 0.2 | How loud the output should be |
output | ctx.destination | What node to output to |
node | make oscillator | Function that takes data and returns an AudioNode |
update | no-op | Function that takes data and a node that can be used to update the node on new data |
type | sine | Type of oscillator to create |