nephitejnf / muse2pokecrystal

GNU Affero General Public License v3.0
6 stars 2 forks source link

Account for musicxml note length behavior better #13

Closed hyperdriveguy closed 4 years ago

hyperdriveguy commented 4 years ago

The Issue

The tempo formula (19200 / bpm) assumes that a note size of 1 in the note macro is equivalent to a 1/16 note. However, this is note always the case. Let's take a look at a part of the Template.musicxml in the repo:

    <measure number="7" width="57.54">
      <note>
        <rest/>
        <duration>4</duration>
        <voice>1</voice>
        </note>
      </measure>

The most important thing to notice here is the <duration> tag. We can see that the rest spans the entire measure; this is proven both by the fact of it being the only child <note> and when opening the file in Musescore.

Currently, Muse2pokecrystal just takes the listed bpm, applies it to the set tempo formula and assumes that <duration>4</duration> is not a whole note.

The Fix

There is an xml tag called <divisions>, a child of the <attributes> tag. By default, this tag holds a value of 1. As I understand it, we can find the smallest note in a score by doing (1/4) / divisions. A value of 1 indicates that a quarter note is the smallest note in the entire score. A value of 4 means the smallest note is a sixteenth note. A modified formula that takes this into account though you may want to check my algebra:

(19200 / bpm) * (4 / divisions)

Other Implications

While this slightly increases complexity of the tempo formula (it's getting it's own function in the refactor anyway), properly implementing this and pairing it with #12 will allow more complex songs with a much wider note length range.

nephitejnf commented 4 years ago

Math checks out in my head... I think

hyperdriveguy commented 4 years ago

Fixed in #14