Skip to content

Musical Time

A musicalTime is a data type for storing a duration of time that can be used within a musical composition. They can be expressed using one of a several units of measurement:

  • bars are the unit of measurement for a whole composition
  • beats are the unit of measurement for a single drum hit. The length of a beat can be modified by changing the beatsPerBar property of a drumRiff or melody. For example, the default is to have 16 beatsPerBar which means a beat typically equals 6 ticks. But if you change the beatsPerBar to 12, then a beat will equal 8 ticks.
  • ticks are the smallest unit of measurement. There are always 96 ticks in a bar

Modulo1 also accepts traditional units of measurement. Their actual length (relative to bars, beats and ticks) changes depending on the beatsPerBar property.

  • wholeNotes are equal to 16 beats
  • halfNotes are half the length of wholeNotes
  • quarterNotes are half the length of halfNotes
  • eightNotes are half the length of quarterNotes
  • sixteenthNotes are half the length of eighthNotes
  • thirtySecondNotes are half the length of sixteenthNotes

Syntax

To create a new musicalTime:

1
var d1 = 1 bar;

To add various types of musicalTime units:

1
var d1 = 1 bar + 2 beats;

To subtract various types of musicalTime units:

1
var d1 = 1 wholeNote - 3 ticks;

To create a duplicate of a musicalTime:

1
var copyOfD1 = d1;

To delete a musicalTime:

1
delete d1;

Properties

A property is a special feature of a variable that can be used to get and/or set some aspect of that variable.

timeInBars

The timeInBars property can be used to find out the value of a musicalTime variable, measured in bars

1
var result = d1.timeInBars;

timeInBeats

The timeInBeats property can be used to find out the value of a musicalTime variable, measured in beats

1
var result = d1.timeInBeats;

timeInEighthNotes

The timeInEighthNotes property can be used to find out the value of a musicalTime variable, measured in eighthNotes

1
var result = d1.timeInEighthNotes;

timeInHalfNotes

The timeInHalfNotes property can be used to find out the value of a musicalTime variable, measured in halfNotes

1
var result = d1.timeInHalfNotes;

timeInQuarterNotes

The timeInQuarterNotes property can be used to find out the value of a musicalTime variable, measured in quarterNotes

1
var result = d1.timeInQuarterNotes;

timeInSixteenthNotes

The timeInSixteenthNotes property can be used to find out the value of a musicalTime variable, measured in sixteenthNotes

1
var result = d1.timeInSixteenthNotes;

timeInThirtySecondNotes

The timeInThirtySecondNotes property can be used to find out the value of a musicalTime variable, measured in thirtySecondNotes

1
var result = d1.timeInThirtySecondNotes;

timeInTicks

The timeInTicks property can be used to find out the value of a musicalTime variable, measured in ticks

1
var result = d1.timeInTicks;

type

The type property can be used to find out the data-type of a particular musicalTime variable. The result will always be "musicalTime"

1
var result = d1.type;

timeInWholeNotes

The timeInWholeNotes property can be used to find out the value of a musicalTime variable, measured in wholeNotes

1
var result = d1.timeInWholeNotes;

Functions

There are no functions specific to musicalTime