Open different55 opened 4 years ago
Basically it adds a "isTied" boolean to notes. It's set when a note is tied or if it's a rest, because they can all be tied together. I don't know if this is MusicXML spec or MuseScore convention, but even ties that stretch from note to note are marked as starting and stopping on each note, so we only have to pay attention to starting tie tags.
Then when we make our optimization pass, we step backwards through a concatenated list of notes, combining each tied note with the following one as long as the pitch matches.
Trailing rests get removed, and if there is leading silence that's trimmed, too. From either or both channels if possible.
@different55 Just wanted to say thanks for the pull request and let you know that I am looking at it (sorry for delay and silence up to this point). Hoping to be back with something more concrete soon!
@different55 can you point me to (or attach) what songs you were testing with? I like what you've done here, but I want to experiment with a slightly different code structure (incorporate optimizeNotes() into download() so that optimizeNotes() doesn't need to be called every time a setting is changed and so that optimizedNotesL/optimizedNotesR aren't required). However, before I share my proposed differences with you I want to make sure I'm not overlooking anything and my changes produce the same results as yours.
Got together a few songs that optimize pretty well and have a lot of variety. Got tied notes, tied notes that cross measures, consecutive rests, leading silence when there's only one channel, leading silence only on one channel, trailing silence, only thing I'm missing is is leading silence on two channels.
IIRC I started out with it in download() but I eventually split it off into its own thing so that I could keep the memory usage counter accurate.
@different55 thanks for pointing out the desire to keep the memory usage up to date and accurate. Given that I think your approach for having an optimizeNotes() function that is called whenever a user makes a configuration change is necessary. I've reviewed the code. Please address the comments I've made above. Thanks!
For #16
First time screwing around in C++ so definitely needs some work, any and all advice for cleanup would be welcome.