Factory to get tone-rhythm methods
Kind: global function
Returns: Object
- - tone-rhythm methods {
getBarsBeats,
addTimes,
getTransportTimes,
mergeMusicDataPart
}
Throws:
- Error if ToneTime dependency isn't valid
Version: tone-rhythm 2.0.0
Author: https://github.com/scraggo/tone-rhythm
Param | Type | Description |
---|---|---|
ToneTime | Object |
import of Tone.Time. example: const ToneTime = require('tone/Tone/type/Time'); |
- toneRhythm(ToneTime) ⇒
Object
- ~getBarsBeats(value) ⇒
string
- ~addTimes(item) ⇒
string
- ~getTransportTimes(arrOfDurations, [startTime]) ⇒
Array
- ~mergeMusicDataPart(config) ⇒
Array
- ~getBarsBeats(value) ⇒
Kind: inner method of toneRhythm
Returns: string
- - rhythm value converted to Tone's bars/beats format.
Throws:
- TypeError if value isn't valid type
Param | Type | Description |
---|---|---|
value | string | number |
a rhythm value Tone recognizes |
Example
getBarsBeats('4n') -> '0:1:0'
Kind: inner method of toneRhythm
Returns: string
- - if item is an array, returns
rhythm value converted to Tone's bars/beats format.
If item was a string, it gets returned as is.
Param | Type | Description |
---|---|---|
item | Array.<string> | string |
if item is array, return summation of items in Tone's bars/beats format. Note: The first item of the array may be 'r' (rest) |
Example
addTimes('4n.') -> '4n.'
Example
addTimes(['8n', '4t', '4t', '4t', '4t', '4t', '4t', '8n']) -> '1:1:0'
Given an array of durations (see API), return transport times. see README.md for examples
Kind: inner method of toneRhythm
Returns: Array
- of start times in Tone's bars/beats format.
Param | Type | Default | Description |
---|---|---|---|
arrOfDurations | Array.<string> |
see README.md API | |
[startTime] | number | string |
0 |
a start time in Tone's Time format. |
see README.md for examples and return values.
Kind: inner method of toneRhythm
Returns: Array
- of objects for consumption by Tone.Part.
Object properties always include time
(number|string), array index idx
(number - integer) and duration
(string). May also include notes
and velocities
. (see readme)
Throws:
- TypeError if value isn't valid type
Param | Type | Description |
---|---|---|
config | Object |
(see properties below) |
config.rhythms | Array |
see API |
[config.notes] | Array.<string> |
ex: ['C4', 'D4', 'E4'] |
[config.times] | Array |
see return of getTransportTimes |
[config.startTime] | string | number |
see startTime of getTransportTimes |