简体   繁体   中英

Find what time (in second) spend to play note in musicxml file

I have note like

<note default-x="106.96" default-y="-25.00">
    <pitch>
      <step>A</step>
      <octave>3</octave>
    </pitch>
    <duration>2</duration>
    <voice>1</voice>
    <type>eighth</type>
    <stem>up</stem>
    <staff>1</staff>
    <beam number="1">begin</beam>
</note>

How can i find what time spend to play it (in second) if tempo = 120bpm ?

Create a table like this:

durationHashTable = {
{ "whole", 4.0 },
{ "half", 2.0 },
{ "quarter", 1.0 },
{ "eighth", 0.5 },
{ "16th", 0.25 } }

Then, the formula is:

noteDurationSeconds = ( 60.0 / beatsPerMinute ) * durationHashTable["eighth"];

This is for the special, simple case where

  • notes are not dotted
  • the time signature has <beat-type>4</beat-type>
  • you are not required to support tuplets.

Things can become significantly more complex, but I would recommend working with this special case first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM