Package Exports
- partch
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (partch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Partch
A lightweight Web Audio API patching library.
Installation
yarn add partch or npm install partch --save
Example
import Partch from 'partch'
let P = Partch()
P.Synth((frequency) => P({
osc: P.Osc({ frequency, type: 'sawtooth' }),
vcf: P.Filter(20),
vca: P.Gain(0),
env: P.Adsr({ attack: 0.01, decay: 0.1, sustain: 0.6, release: 5 })
},
'osc > vcf > vca > out',
'env > vcf.frequencyCv',
'env > vca.gainCv'
)).monitor().play(60).releaseAfter(0.5)API
Partch([audioContext])
audioContextDefaults to a new AudioContext.
Returns a Patch function with a number of attached Node Factory functions.
Patch(nodes, [...connections])
nodesconnections<Array(String)> Strings representing connections between nodes.
Connection strings take the form of a list of nodes separated by a > character. Each node may be either a node name specified in the nodes object, or a dot-separated node path, e.g. synth.filter.frequencyCv. When using a node path, any onward connections after the node will be from the top-level node, i.e. the node whose name comes first in the path.
Returns a patch object with the following members:
patch.connect(destination)
destination<AudioDestinationNode | AudioParam> The destination to connect to.
Works exactly like the AudioNode connect method. Returns the destination.
patch.input
An alias for patch.nodes.in. When connecting from a native Web Audio API node to a patch, this should be the connection destination.
patch.monitor()
Connects the patch to the audioContext.destination. Returns the patch.
patch.nodes
The nodes object used to instantiate the patch, plus the in and out nodes (if present).
patch.release([time])
timeThe audioContext time at which to release. Defaults to immediately.
Triggers the release portion of any envelopes in the patch at time, then stops the patch. Returns the patch.
patch.releaseAfter(interval)
intervalThe time from now at which to release.
Waits interval seconds from now, then calls release above. Returns the patch.
patch.start([time])
timeThe audioContext time at which to start. Defaults to immediately.
Starts any nodes in the patch which have a start method at time (this will also trigger the attack portion of any envelopes). Returns the patch.
patch.stop([time])
timeThe audioContext time at which to stop. Defaults to immediately.
Stops any nodes in the patch which have a stop method at time (this will cut off sound immediately without triggering the release portion of any envelopes). Returns the patch.
patch.stopAfter(interval)
intervalThe time from now at which to stop.
Waits interval seconds from now, then calls stop above. Returns the patch.