addon/classes/beat-track.js:19
BeatTrack
Extends:
An instance of this class has a single "sound" (comprised of one or multiple audio sources) but provides methods to play that sound repeatedly, mixed with "rests," in a rhythmic way. An instance of this class behaves very similarly to a "lane" on a drum machine.
Property Summary
Public Properties | |
---|---|
public |
Computed property. An array of Beat instances. The number of Beat instances in the array is always the same as the |
public |
If specified, Determines length of time, in milliseconds, before isPlaying and currentTimeIsPlaying are automatically switched back to false after having been switched to true for each beat. 100ms is used by default. |
public |
|
public |
Determines the number of beats in a BeatTrack instance. |
public |
|
public |
|
Private Properties | |
---|---|
private |
|
Method Summary
Public Methods | |
---|---|
public |
play( )
|
public |
playActiveBeats(bpm, noteType)
Calls play on |
public |
playAt(time)
|
public |
playBeats(bpm, noteType)
Calls play on all Beat instances in the beats array. |
public |
playIn(seconds)
|
Private Methods | |
---|---|
private |
_callPlayMethodOnBeats(method, bpm, noteType)
The underlying method behind playBeats and playActiveBeats. |
private |
_getNextSound( ): Sound
|
private |
_initSounds( )
|
private |
_setGainAndPan( ): Sound
|
Public Properties
addon/classes/beat-track.js:56
public beats: Array | Beat
Computed property. An array of Beat instances. The number of Beat instances
in the array is always the same as the numBeats
property. If 'numBeats'
or duration changes. This property will be recomputed, but any beats that
previously existed are reused so that they will maintain their active
state.
addon/classes/beat-track.js:44
public duration: Number
If specified, Determines length of time, in milliseconds, before isPlaying and currentTimeIsPlaying are automatically switched back to false after having been switched to true for each beat. 100ms is used by default.
addon/classes/sampler.js:30
public gain: Number
addon/classes/beat-track.js:35
public numBeats: Number
Determines the number of beats in a BeatTrack instance.
addon/classes/sampler.js:40
public pan: Number
addon/classes/sampler.js:62
public sounds: Set
new Set()
via _initSounds
.Private Properties
addon/classes/sampler.js:50
private _soundIterator: Iterator
Public Methods
addon/classes/sampler.js:73
public play( )
addon/classes/beat-track.js:112
public playActiveBeats(bpm, noteType)
Calls play on active
Beat instances in the beats array. Any beat that
is not marked active is effectively a "rest".
addon/classes/sampler.js:96
public playAt(time)
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
time | Number |
|
The moment in time (in seconds, relative to the {{#crossLink "AudioContext"}}AudioContext's{{/crossLink}} "beginning of time") when the next Sound should be played. |
addon/classes/beat-track.js:96
public playBeats(bpm, noteType)
Calls play on all Beat instances in the beats array.
addon/classes/sampler.js:83
public playIn(seconds)
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
seconds | Number |
|
Number of seconds from "now" that the next Sound should be played. |
Private Methods
addon/classes/beat-track.js:129
private _callPlayMethodOnBeats(method, bpm, noteType)
The underlying method behind playBeats and playActiveBeats.
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
method | String |
|
The method that should be called on each beat. |
bpm | Number |
|
The tempo that should be used to calculate the length of a beat/rest. |
noteType | Number |
|
The (rhythmic) length of each beat/rest that should be used to calculate the length of a beat/rest in seconds. |
addon/classes/sampler.js:112
private _getNextSound( ): Sound
Return:
addon/classes/sampler.js:156
private _initSounds( )
sounds
to new Set()
if null on instantiation.addon/classes/sampler.js:141
private _setGainAndPan( ): Sound
gain
and pan
properties from the Sampler instance to a
Sound instance and returns the Sound instance.