dariustb / VibeBeyond

C++ desktop app to generate & host lo-fi hip hop music
https://dariustb.github.io/VibeBeyond/
0 stars 0 forks source link

Fix Timing Issue with the MIDI #104

Closed dariustb closed 1 year ago

dariustb commented 1 year ago

At this point, when you play the chords with the drums, the chords will slowly lag to the downbeat, and eventually fall out of sync with the drum loop. I think it's a math issue, adding 1 millisecond somewhere instead of subtracting. Getting the song to make it to the end without the lag would be very necessary to the listening experience.

dariustb commented 1 year ago

Found the issue. The constants for QTR_NOTE, HALF_NOTE, etc. were using the math of

BASE_NOTE = 480 # note length in ticks (480 ticks per beat)
QTR_NOTE = BASE_NOTE  - 1
HALF_NOTE = BASE_NOTE * 2 - 1
.
.
.

The idea was to subtract 1 so that the following note lands on the downbeat. 479 ticks allow the next beat to land cleanly and that was the basis for timing each beat per measure. The issue was that since there's 480 ticks per beat, the subtraction should be removed at every beat instead of after every note. Subtracting 1 from the BASE_NOTE only had fixed the issue.