Instruments provide a OOP style interface to the synths. Something with
start and stop methods, than can be called several times and know about
note frequencies and midi connections.
- Source:
 
Example
var simple = inst((fq) => conn(sine(fq), adsr()))
simple.start('C4')
simple.start('G5')
simple.stop() // => stop all notes
        
    
    Members
(static) master
A master output instrument. You can use it to start and stop nodes. All started nodes will be connected to the AudioContext destination.
- Source:
 
Example
master.start(sine(300)) // connect to destination and start
master.start(sine(600), 0, 1) // connect to destination and start after 1 second
master.stop() // stop all
        
    
    
        Methods
(static) inst(synth, destination, options) → {Player}
Create an object-oriented-style instrument player. It wraps a synth function (a function that create nodes) into in a convenient player API. It can be used to limit the polyphony.
The player object have the following methods:
start(node, when, delay, duration): start a nodestop: stop all nodeson(name, callback): add an event callbackevent(name, ...values): fire an event
Parameters:
| Name | Type | Description | 
|---|---|---|
synth | 
            
            function | the synth function (a function that returns a node graph)  | 
        
destination | 
            
            AudioNode | if present, all nodes will be connected to this destination  | 
        
options | 
            
            Object | (Optional) the options may include: 
  | 
        
- Source:
 
Returns:
a player object
- Type
 - Player
 
Examples
// an instrument with destination
var synth = inst((fq) => sine(fq), dest())
synth.start('A4')
synth.stopAll()
    // only the destination
var master = inst(null, conn(mix(0.2), reverb(), dest()))
master.start(sine(300))
master.start(sine(400))
master.stopAll()