soundbank-chunk
A group of triggerable sound descriptors to be positioned on a loop-grid and played with soundbank.
Implements observ for easy data-binding to your views.
npm
Install via$ npm install loop-grid
API
var Chunk =
var chunk = Chunk(opts)
opts
soundbank
: (required) Specify the instance ofsoundbank
you wish to wrap. This chunk will be immediately added to the soundbank, with the IDs by default namespaced with the chunk id.getGlobalId
: Override the internal id resolver withfunction(chunkId, soundId)
.
Returns an observable/bindable chunk.
// set up a soundbankvar audioContext = // web audio apivar Soundbank = audioContextsources = sample: audioContextprocessors = overdrive: audioContext{ // callback with AudioBuffer resolved from src}var soundbank = // create instance wrapping soundbank abovevar chunk = // put this chunk on a launchpadvar launchpad = midi: player: player recorder: recorder launchpad // place starting at top-left corner
chunk.set(descriptor)
Update all properties to reflect the new descriptor.
chunk()
Returns the current descriptor value as set
.
chunk(function callback(descriptor){ ... })
The callback
is called with the new descriptor
value on every change.
chunk.grid
Observ(ArrayGrid)
Get the resolved trigger IDs mapped to an ArrayGrid using shape
and stride
values.
Returns an ArrayGrid wrapped by an Observ instance that notifies on change.
Observable Properties
chunk.title
(Observ)
A display title for this chunk.
chunk.slots
(ObservArray)
The soundbank slot descriptors used by this chunk. Update sounds by modifying this array.
chunk.triggers
(ObservArray)
The slot ids to include on the grid. They will be shaped by chunk.shape
and chunk.stride
.
chunk.shape
(Observ)
chunk.stride
(Observ)
chunk.routes
(ObservVarhash)
Route the output from slots in this chunk to IDs in other chunks.
chunk.inputs
(Observ)
List of slot ids to accept input routing from chunks.
chunk.outputs
(Observ)
List of slot ids to suggest output routing to other chunks.