SmartMusic Finale Garritan MusicXML

Calculating note start times

Moderator: Michael Good

Calculating note start times

Postby DrJohn » Fri Jul 03, 2015 9:34 am

I'm writing an application where I need to calculate the start times for each note in a piece. Is there a straightforward algorithm I can use to compute the start time as I parse the musicXML file. The application is to create a semantic description of the piece for further musicological analysis.
Thanks in advance
Posts: 2
Joined: July, 2015
Reputation: 0

Re: Calculating note start times

Postby Hans Vereyken » Tue Jul 07, 2015 7:04 am

That's not an easy task.
Start here:


To do this you need to understand the <divisions>, <duration> element and it's meaning inside <backup>, <forward> and <note> elements. Be aware of the <chord> and <grace> elements.

Documentation can be found here: ... sicXML.htm
Hans Vereyken
Posts: 36
Joined: March, 2014
Reputation: 0

Re: Calculating note start times

Postby DrJohn » Thu Jul 09, 2015 6:44 am

Thanks Hans. Am I correct in assuming parts are in parallel and therefore each part starts at time 0 ?
Posts: 2
Joined: July, 2015
Reputation: 0

Re: Calculating note start times

Postby Mogens Lundholm » Fri Jul 10, 2015 12:39 pm

Hello Dr John

What are your needs? Do you want to write your own program or do you just
need to create the data and use your time for further processing?

I made a program that can save all start times for the notes. This of cause done
for my own tests. Here is what my program generates in test mode activated by the

MidiAndMusicXmlPlayer.exe MusicFile.xml -T

The time division index is shown before the colon. After the colon the note
changes are written, separated by space.

1:-C +E
2:-E +G
3:-G +C

Explanation: +C means start of C-note at time division 0, -C means stop of
C-note at time division 1. Sharp and flat notes are indicated with +/- after
the note, e.g. +C+ (start C-sharp). The data is saved in files for each part.

If you want to you use your time with the further processing, you can use my
program which can be downloaded from

You may need to have the octave shown, f.x. as +5C and also the value of
divisions. If you are interested, I can change that easily.

Other people has written about this in this forum with the same problem. They
made their own programs and scripts and I think they all did it free and open.
Maybe you can find some help there.

The basic algorithm in my program is explained below - placing all data in an
array suited for conversion to midi. The above data is a dump of the data
in this array.

Kind regards


My basic principle is:
The MusicXML file is divided in parts. The Midi-file is divided in tracks
(format 1). Each part in MusicXML becomes a Midi track.
My program has a state machine, which reads the MusicXML file and saves data
in a array with an element for every time division. This array is called NoteInfo.
Each element in NoteInfo is a record/structure of three sets. One set of notes
to start at this time division (NoteOn), one set of notes to stop at this time
division (NoteOff) and one set for notes to continue (NoteContinue). All notes
has a duration value in time divisions (command <duration>), but can be
tied - then the note is added to the continue-set and prolonged later when the
tied note continues.
The index to the NoteInfo-array is stepped forward with the value of duration
of each note, but the previous index if saved - for chord-notes. The index
may be changed backward and forward by the commands <backup> and <forward>.
(Simplified - a lot of things makes it more complicated but ...)
(4.17 KB) Downloaded 558 times
TilMusicXML.jpg (5.26 KB) Viewed 6421 times
Mogens Lundholm
Posts: 60
Joined: March, 2014
Reputation: 0

Who is online

Users browsing this forum: No registered users and 1 guest