1

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 ?

Filburt
  • 17,626
  • 12
  • 64
  • 115
  • I know I'm a bit late, but you should probably read up music notation and playing basics. 120bpm equals 120 quarters per minute, so an eight would be a forth of a second. – user2610529 Feb 20 '16 at 14:12

1 Answers1

0

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.

Matthew James Briggs
  • 2,085
  • 2
  • 28
  • 58