startTime
The startTime property defines when a note begins playing, measured in seconds from the start of the composition.
Default Value
0 // Starts at the beginningExpression Examples
Fixed Time
0 // Start immediately
1 // Start at 1 second
(5/2) // Start at 2.5 secondsLegacy JavaScript syntax
javascript
new Fraction(0) // Start immediately
new Fraction(1) // Start at 1 second
new Fraction(5, 2) // Start at 2.5 secondsRelative to BaseNote
// Same start as BaseNote
base.t
// One second after BaseNote
base.t + 1Legacy JavaScript syntax
javascript
// Same start as BaseNote
module.baseNote.getVariable('startTime')
// One second after BaseNote
module.baseNote.getVariable('startTime').add(new Fraction(1))Sequential Notes
The most common pattern chains notes sequentially:
// Start when previous note ends
[prev].t + [prev].dLegacy JavaScript syntax
javascript
// Start when previous note ends
module.getNoteById(prev).getVariable('startTime')
.add(module.getNoteById(prev).getVariable('duration'))Beat-Relative Timing
// Start at beat 2 (tempo-aware)
60 / tempo(base) * 2
// Start at measure 2
measure(base) * 2Legacy JavaScript syntax
javascript
// Start at beat 2 (tempo-aware)
new Fraction(60).div(module.findTempo(module.baseNote))
.mul(new Fraction(2))
// Start at measure 2
module.findMeasureLength(module.baseNote)
.mul(new Fraction(2))Offset from Another Note
// Start 0.5 seconds after Note 3 starts
[3].t + (1/2)
// Start 1 beat after Note 3 starts
[3].t + 60 / tempo(base)Legacy JavaScript syntax
javascript
// Start 0.5 seconds after Note 3 starts
module.getNoteById(3).getVariable('startTime')
.add(new Fraction(1, 2))
// Start 1 beat after Note 3 starts
module.getNoteById(3).getVariable('startTime')
.add(new Fraction(60).div(module.findTempo(module.baseNote)))Simultaneous Notes (Chords)
// Same start time as Note 1 (plays together)
[1].tLegacy JavaScript syntax
javascript
// Same start time as Note 1 (plays together)
module.getNoteById(1).getVariable('startTime')Common Patterns
Building a Melody
// Note 1: starts at 0
0
// Note 2: starts when Note 1 ends
[1].t + [1].d
// Note 3: starts when Note 2 ends
[2].t + [2].dLegacy JavaScript syntax
javascript
// Note 1: starts at 0
new Fraction(0)
// Note 2: starts when Note 1 ends
module.getNoteById(1).getVariable('startTime')
.add(module.getNoteById(1).getVariable('duration'))
// Note 3: starts when Note 2 ends
module.getNoteById(2).getVariable('startTime')
.add(module.getNoteById(2).getVariable('duration'))Building a Chord
// All notes share the same start time
// Notes 2, 3, 4 reference Note 1:
[1].tLegacy JavaScript syntax
javascript
// All notes share the same start time
// Notes 2, 3, 4 reference Note 1:
module.getNoteById(1).getVariable('startTime')Staggered Entry (Arpeggio)
// Each note starts 0.1 seconds after the previous
[prev].t + (1/10)Legacy JavaScript syntax
javascript
// Each note starts 0.1 seconds after the previous
module.getNoteById(prev).getVariable('startTime')
.add(new Fraction(1, 10))Visualization
- Horizontal position on the workspace represents time
- Notes further right start later
- The X-axis scales as:
seconds * 200 * xScaleFactor - The playhead (vertical line) shows current playback position
Dependencies
When startTime references another note, both notes are linked:
// Changing Note 1's timing affects Note 2
[1].t + [1].dLegacy JavaScript syntax
javascript
// Changing Note 1's timing affects Note 2
module.getNoteById(1).getVariable('startTime')
.add(module.getNoteById(1).getVariable('duration'))This creates dependencies on both startTime and duration of Note 1.
See Also
- duration - Note length
- tempo - Speed in BPM
- Creating Notes - Adding notes
- Dependencies - Linking notes