An observable collection of looped event sequences shaped to a grid.
Install via npm
$ npm install loop-grid
var LoopGrid = require('loop-grid')
Returns an observable instance of LoopGrid.
- scheduler: (required) instance of Bopper
- triggerEvent: (required)
function(event)
called for every event to be triggered - audio: (required) instance of AudioContext
Return the current object descriptor (state).
Set the current object descriptor (state).
Included in state.
Included in state.
Mapping of grid loops to ids.
Included in state.
Included in state.
var event = {
id: String,
event: 'start' | 'stop',
position: Number, // beat
time: Number, // based on
args: Array
}
Returns ArrayGrid based on loopGrid.targets
and loopGrid.shape
.
Returns ArrayGrid of true
values where target is currently being triggered.
Returns ArrayGrid of true
values where target has a current loop.
var Looper = require('loop-grid/looper')
Pass in a function to add to transform stack. input
is an instance of ArrayGrid and should return either the modified input
or a new instance of ArrayGrid
.
var computeFlags = require('loop-grid/compute-flags')
var computeTargets = require('loop-grid/compute-targets')
Range selector for loop-grid.
var Selector = require('loop-grid/selector')
Returns an extended instance of ObservGrid with shape
specified.
Pass in an observable ArrayGrid. done
will be called on stop
or before subsequent start
.
Any truthy values will trigger a selection. Simultaneous true values will trigger range selection. selection
will have .set(selectedIndexes)
called on every change.
Sets selection
to an empty array.
Release watch of inputGrid
and call done
.
Beat stutter/looper
var Holder = require('loop-grid/transforms/holder')
Pass loopGrid.transform
to this constructor.
Choose the length (in beat decimal) of the stutter effect.
Loop events in specified indexes
(or all if not specified) from position
to position + length
. Ensure each event length is no longer than specified length
(truncating if necessary).
Automatically calls holder.stop()
first if there is a current hold in progress.
Release transform
and call done
if specified.
Move selected ranges of loops to new origin.
var Mover = require('loop-grid/transforms/mover')
Pass loopGrid.transform
to this constructor.
Finds the top-left most coordinates in selectedIndexes
, and uses this as the start origin. Any true values in inputGrid
will call transform
with a function that moves the values from selectedIndexes to the new origin. Multiple true values will cause the selectedIndexes to be duplicated.
Release any pending transform
and stop watching inputGrid
.
var Repeater = require('loop-grid/transforms/repeater')
Pass loopGrid.transform
to this constructor.
Held notes will call transform
with a function that creates a repeating note with length length / 2
at the rate of specified length
.
Release the inputGrid
.
Suppress selected loops
var Suppressor = require('loop-grid/transforms/suppressor')
Pass loopGrid.transform
to this constructor.
Returns an extended observ instance containing instances of array-grid with true
values at coords where currently suppressed.
Calls transform
with a function that suppresses all indexes
specified.
Release suppression transform
.