SUCH a hard and frustrating day today. As often happens with programming I've worked non-stop to end up close to where I started. A small MIDI bug in Prometheus meant a slight change to the program. I thought I'd add a feature to calculate the time from a section near the start of the song, rather than at the start, to the cursor. This can be very useful, as sometimes the first beat or so isn't rendered, it's a blank 'pre-intro' before the song proper. When rendering from anywhere but the very start makes any timing calculations for frames, exact locations of notes etc. wrong. I thought it would be easy to calculate because I can calculate the exact sample of any note, even when the tempo is wildly modulating. All I needed to do was calculate the initial start (say, the second beat) and subtract that...
But NO! This doesn't work because rendering itself from the second beat involves a different set-up. The results were a frustrating 64 samples (about 1ms) out at times, and sometimes wildly inaccurate when modulating the tempo; yet at other times worked correctly. I needed to mimic exactly the set-up and running process used during rendering. It's taken all day so far, over six hours to track down the process, when 99% of the code was there already. I expected this trivial job to take 5 or 10 minutes. I think, now, that it's working, but it's been an exhausting battle.
Hopefully I can actually make some music or have something to show for this day.