Section Durations
Durations utility functions
- Conversions from/to milliseconds, note duration, percentage of note duration, 256th of quarter
Summary
Return type | Function and summary |
---|---|
number | duration_256th_of_quarter_to_ms(int nbOf256th, number tempo) Convert 256ths of quarter to milliseconds, according to tempo. |
int | duration_256th_of_quarter_to_percent_of_note(int nbOf256th, int noteDuration, number tempo) Convert 256ths of quarter to a percentage of a note duration, according to tempo. |
int | duration_ms_to_256th_of_quarter(number milliseconds, int noteDuration, number tempo) Convert at duration in milliseconds to 256th of quarter, according to tempo |
int | duration_ms_to_note(number milliseconds, number tempo) Convert a duration in milliseconds to a note duration according to tempo. |
int | duration_ms_to_percent_of_note(number milliseconds, int noteDuration, number tempo) Convert a duration in milliseconds to a percentage of a note duration, according to tempo. |
number | duration_note_to_ms(int noteDuration, number tempo) Convert a note duration to milliseconds, according to tempo. |
int | duration_percent_of_note_to_256th_of_quarter(int nbOf256th, int noteDuration, number tempo) Convert a percentage of a note duration to 256ths of quarter, according to tempo. |
number | duration_percent_of_note_to_ms(int percent, int noteDuration, number tempo) Convert a percentage of note duration to milliseconds, according to tempo. |
Functions
duration_note_to_ms(int noteDuration, number tempo)
Convert a note duration to milliseconds, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
noteDuration | int | ||
tempo | number |
- Return
- number: Rounded to 3 decimals
- Error
- if noteDuration is nil, if tempo is nil or <= 0
duration_ms_to_note(number milliseconds, number tempo)
Convert a duration in milliseconds to a note duration according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
milliseconds | number | ||
tempo | number |
- Return
- int: A note duration, comparable to DURATION_QUARTER and other constants in MSDefine
- Error
- if milliseconds is nil, or tempo is nil or <= 0
duration_percent_of_note_to_ms(int percent, int noteDuration, number tempo)
Convert a percentage of note duration to milliseconds, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
percent | int | ||
noteDuration | int | ||
tempo | number |
- Return
- number: Rounded to 3 decimals
- Error
- if percent is nil, if noteDuration is nil, if tempo is nil or <= 0
duration_ms_to_percent_of_note(number milliseconds, int noteDuration, number tempo)
Convert a duration in milliseconds to a percentage of a note duration, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
milliseconds | number | ||
noteDuration | int | ||
tempo | number |
- Return
- int: Percent of noteDuration
- Error
- if milliseconds is nil, if noteDuration is nil, if tempo is nil or <= 0
duration_256th_of_quarter_to_ms(int nbOf256th, number tempo)
Convert 256ths of quarter to milliseconds, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
nbOf256th | int | ||
tempo | number |
- Return
- number: Rounded to 3 decimals
- Error
- if nbOf256th is nil, if tempo is nil or <= 0
duration_ms_to_256th_of_quarter(number milliseconds, int noteDuration, number tempo)
Convert at duration in milliseconds to 256th of quarter, according to tempo
Parameter | Type | Default | Description |
---|---|---|---|
milliseconds | number | ||
noteDuration | int | ||
tempo | number |
- Return
- int: 256th of quarter
- Error
- if milliseconds is nil, if noteDuration is nil, if tempo is nil or <= 0
duration_256th_of_quarter_to_percent_of_note(int nbOf256th, int noteDuration, number tempo)
Convert 256ths of quarter to a percentage of a note duration, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
nbOf256th | int | ||
noteDuration | int | ||
tempo | number |
- Return
- int:
- Error
- if nbOf256th is nil, if noteDuration is nil, if tempo is nil or <= 0
duration_percent_of_note_to_256th_of_quarter(int nbOf256th, int noteDuration, number tempo)
Convert a percentage of a note duration to 256ths of quarter, according to tempo.
Parameter | Type | Default | Description |
---|---|---|---|
nbOf256th | int | ||
noteDuration | int | ||
tempo | number |
- Return
- int:
- Error
- if nbOf256th is nil, if noteDuration is nil, if tempo is nil or <= 0