This module is a IIFE (Immediately Invoked Function Expression) and
it returns a var with the name of Rhythm. This document contains its public API.
The Rhythm module contains functions used to manipulate and translate
Rhythms into different formats used with Tone.js
It will merge parallel arrays of notes, durations and velocities into an array of objects
for use with the Tone.js
Also adds some support functions for the PlayRhythm page in the PracticeRoom app
use the script tag to add this file
<script src="path/to/Rhythm.js"></script>
this stores the duration and noteNames on the Rhythm object
this stores the duration on the Rhythm object
this function merges two arrays into a single array of objects used by Tone.js
object
:
the merged data
this function takes an array of duration notation and creates an array of cummlative values used by Tone.js
object
:
the array of cummlative values in seconds
this function merges two arrays into a single array of objects used by Tone.js
(object)
(array of strings)
(object)
(array of strings)
(string)
(optional)
object
:
the merged data
parameters: durations, ptiches
var durations = ['4n','8n','8n','4n+8n','8n'];
var pitches = ['A4','C5','C#5','E5','G#4'];
var noteObjects = mergeDurationsAndPitch(durations, pitches, '0');
// array of noteObjects (with three attributes) used in Tone.Part(function(time, value){ }, noteObjects );
time = t_array[i] - returned from processDurations(durations)
note = pitches[i]
duration = durations[i]
NOTE: The note and duration are unpacked in the callback function as value.note and value.duration
and are used as parameter to the function
synth.triggerAttackRelease(value.note, value.duration, time)
this function merges three arrays into a single array of objects used by Tone.js
(object)
(array of strings)
(object)
(array of strings)
(object)
(optional) default = 0.7 (1.0 max) (array of numbers)
(string)
(optional)
object
:
the merged data
this function return the total time of the currently stored durations
string
:
totalTime