Duration Reference

This document describes how note/rest durations are represented in MuseScore, including tick values and the setDuration() method.

Source File

docs/ticklength.md

Duration Basics

Durations in MuseScore are expressed as fractions of a whole note. The Cursor's setDuration(z, n) method takes a fraction z/n.

Common Duration Values

Standard Note Values

DurationFractionsetDuration()
Double whole (breve)2/1setDuration(2, 1)
Whole (semibreve)1/1setDuration(1, 1)
Half (minim)1/2setDuration(1, 2)
Quarter (crotchet)1/4setDuration(1, 4)
Eighth (quaver)1/8setDuration(1, 8)
16th (semiquaver)1/16setDuration(1, 16)
32nd (demisemiquaver)1/32setDuration(1, 32)
64th (hemidemisemiquaver)1/64setDuration(1, 64)
128th1/128setDuration(1, 128)
256th1/256setDuration(1, 256)

Dotted Note Values

A dot adds half the value. The formula is: duration * 3/2

DurationFractionsetDuration()
Dotted whole3/2setDuration(3, 2)
Dotted half3/4setDuration(3, 4)
Dotted quarter3/8setDuration(3, 8)
Dotted eighth3/16setDuration(3, 16)
Dotted 16th3/32setDuration(3, 32)
Dotted 32nd3/64setDuration(3, 64)

Double-Dotted Note Values

Double dot adds 3/4 of the original value. Formula: duration * 7/4

DurationFractionsetDuration()
Double-dotted whole7/4setDuration(7, 4)
Double-dotted half7/8setDuration(7, 8)
Double-dotted quarter7/16setDuration(7, 16)
Double-dotted eighth7/32setDuration(7, 32)

Tick Values

Internally, MuseScore uses "ticks" to measure time. The number of ticks per quarter note is defined by the division property (typically 480).

Tick Length Table

DurationTicks (division=480)Formula
Whole note19204 * division
Double-dotted half16803.5 * division
Dotted half14403 * division
Triplet whole (1/3 breve)12808 * division / 3
Half note9602 * division
Double-dotted quarter8401.75 * division
Dotted quarter7201.5 * division
Triplet half (1/3 whole)6404 * division / 3
Quarter note480division
Double-dotted eighth4200.875 * division
Dotted eighth3600.75 * division
Triplet quarter (1/3 half)3202 * division / 3
Eighth note240division / 2
Double-dotted 16th2100.4375 * division
Dotted 16th1800.375 * division
Triplet eighth (1/3 quarter)160division / 3
16th note120division / 4
Double-dotted 32nd1050.21875 * division
Dotted 32nd900.1875 * division
Triplet 16th (1/3 eighth)80division / 6
32nd note60division / 8
Dotted 64th450.09375 * division
Triplet 32nd (1/3 16th)40division / 12
64th note30division / 16

Working with Duration

Setting Duration via Cursor

var cursor = curScore.newCursor(); cursor.rewind(Cursor.SCORE_START); // Standard durations cursor.setDuration(1, 4); // Quarter note cursor.addNote(60); cursor.setDuration(1, 8); // Eighth note cursor.addNote(62); // Dotted duration cursor.setDuration(3, 8); // Dotted quarter cursor.addNote(64);

Duration via Pad Actions

You can also set duration using pad actions:

cmd("pad-note-4"); // Set quarter note duration cmd("note-c"); // Enter C with quarter duration cmd("pad-note-8"); // Set eighth note duration cmd("pad-dot"); // Add dot (now dotted eighth) cmd("note-d"); // Enter D with dotted eighth duration

Reading Duration from Elements

if (cursor.element && cursor.element.type == Element.CHORD) { var chord = cursor.element; var duration = chord.duration; // Fraction object console.log("Duration: " + duration.numerator + "/" + duration.denominator); }

Tuplets

Tuplets allow non-standard divisions of time.

Common Tuplet Ratios

TupletRatioDescription
Duplet2:32 notes in time of 3
Triplet3:23 notes in time of 2
Quadruplet4:34 notes in time of 3
Quintuplet5:45 notes in time of 4
Sextuplet6:46 notes in time of 4
Septuplet7:47 notes in time of 4
Octuplet8:68 notes in time of 6
Nonuplet9:89 notes in time of 8

Creating Tuplets via Action

// Enter triplet mode and add notes cmd("triplet"); // Start triplet cmd("note-c"); // First triplet note cmd("note-d"); // Second triplet note cmd("note-e"); // Third triplet note (completes triplet)

Creating Tuplets via Cursor

cursor.setDuration(1, 4); // Quarter note base duration var ratio = fraction(3, 2); // 3:2 ratio (triplet) var duration = fraction(1, 4); // Total duration of tuplet curScore.startCmd("Add Triplet"); cursor.addTuplet(ratio, duration); // Now add the notes inside the tuplet cursor.setDuration(1, 8); // Eighth notes inside triplet cursor.addNote(60); cursor.addNote(62); cursor.addNote(64); curScore.endCmd();

Duration Types (DurationType.*)

TypeDescription
DurationType.V_LONGLonga
DurationType.V_BREVEBreve (double whole)
DurationType.V_WHOLEWhole note
DurationType.V_HALFHalf note
DurationType.V_QUARTERQuarter note
DurationType.V_EIGHTHEighth note
DurationType.V_16TH16th note
DurationType.V_32ND32nd note
DurationType.V_64TH64th note
DurationType.V_128TH128th note
DurationType.V_256TH256th note
DurationType.V_512TH512th note
DurationType.V_1024TH1024th note

Time Signatures

Time signatures affect how durations are grouped and beamed.

Common Time Signatures

Time SigBeatsBeat UnitBar Duration
4/44Quarter1 whole note
3/43Quarter3/4 whole note
2/42Quarter1/2 whole note
6/86Eighth3/4 whole note
2/22Half1 whole note
3/83Eighth3/8 whole note
9/89Eighth9/8 whole note
12/812Eighth3/2 whole note

Working with Time Signatures

// Get time signature at cursor var measure = cursor.measure; var timeSig = measure.timesig; console.log("Time signature: " + timeSig.numerator + "/" + timeSig.denominator);

Practical Examples

Creating a Rhythm Pattern

function addRhythm(cursor) { curScore.startCmd("Add Rhythm"); // Quarter note cursor.setDuration(1, 4); cursor.addNote(60); // Two eighth notes cursor.setDuration(1, 8); cursor.addNote(62); cursor.addNote(64); // Dotted quarter + eighth cursor.setDuration(3, 8); cursor.addNote(65); cursor.setDuration(1, 8); cursor.addNote(67); curScore.endCmd(); }

Creating a Compound Meter Pattern

function add6_8Pattern(cursor) { curScore.startCmd("Add 6/8 Pattern"); cursor.setDuration(1, 8); // First beat group (3 eighths) cursor.addNote(60); cursor.addNote(62); cursor.addNote(64); // Second beat group (3 eighths) cursor.addNote(65); cursor.addNote(67); cursor.addNote(69); curScore.endCmd(); }

Filling a Measure with Rests

function fillWithRests(cursor, timeSigNumerator, timeSigDenominator) { curScore.startCmd("Fill with Rests"); // Calculate number of rest units needed cursor.setDuration(1, timeSigDenominator); for (var i = 0; i < timeSigNumerator; i++) { cursor.addRest(); } curScore.endCmd(); } // Fill a 4/4 measure fillWithRests(cursor, 4, 4);

Helper Functions

// Convert BPM and duration to seconds function durationToSeconds(durationFraction, bpm) { var beatsPerSecond = bpm / 60; var quarterNotesPerSecond = beatsPerSecond; // Assuming quarter = beat var wholeNotesPerSecond = quarterNotesPerSecond / 4; var duration = durationFraction.numerator / durationFraction.denominator; return duration / wholeNotesPerSecond; } // Get note duration as string description function durationToString(z, n) { var durations = { '2/1': 'breve', '1/1': 'whole', '1/2': 'half', '1/4': 'quarter', '1/8': 'eighth', '1/16': '16th', '1/32': '32nd', '1/64': '64th', '3/2': 'dotted whole', '3/4': 'dotted half', '3/8': 'dotted quarter', '3/16': 'dotted eighth', '3/32': 'dotted 16th' }; var key = z + '/' + n; return durations[key] || (z + '/' + n); }