Change song midi preserving its metadata

Have questions? Just saying hello? This is the place.
No explicit, hateful, or hurtful language. Nothing illegal.
Post Reply
cmplays
Posts: 58

Post by cmplays » 03-30-17 11:03 pm

I created a midi file to play for myself, imported it into Synthesia, split hands, added my fingering notes... in short, put it a bit of effort. But now I feel the need to change a few notes around, i.e. generate a new midi file and import it. Can I do that while preserving all the custom info that I added to the original version?

Version 10.3.4096 on Win 10.

cmplays
Posts: 58

Post by cmplays » 04-01-17 10:31 am

Let me ask more specifically:

If I get the song hash from recentSongs.xml, then find the entry for that hash in fingers.xml and save it, then replace the midi file, find the new hash for that file, then put the entry with the new hash back into fingers.xml, would it work? Does fingers.xml also contain the info on splitting the song between two hands, or is that in a separate file?

Nicholas
Posts: 12053

Post by Nicholas » 04-01-17 11:20 pm

Replacing the hash would re-associate the existing data with the new file. You'd have to replace it in a few files; fingers.xml being one of them.

It can get tricky though. Depending on your MIDI editor, all bets are off as to whether the new file has its notes in anything approaching the original order of the previous version of the song. You might get lucky -- some editors have a lighter touch -- and have everything line up nicely though.

(If you'd like to see the new hash, drag that file into the metadata editor, select the song from the list, and it will show the hash at the top of the window.)

cmplays
Posts: 58

Post by cmplays » 04-02-17 9:39 pm

Oh, I didn't know about the metadata editor. It made everything much simpler. I imported the metadata, saved it, then associated it with the new file, and it all worked like a charm.

PowerFritz
Posts: 6

Post by PowerFritz » 12-19-18 4:54 pm

Hi,

may I add a quick question on this, please..? I have the same problem from time to time, i.e. I do little changes in a song file.. I do maintenance with MuseScore2, then export it to MIDI file. I understood the file id on the filesystem changes since it is a new file.

I used metadata editor to find out both file ids (old MIDI file and new one).

I got to the \users\<user>\appdata\roaming\synthesia directory and GREPed for the old file's id.. found 4 or 5 xml files (not "scores.xml"), replaced old file id with new file id.. opened synthesia and.. scores are gone.

I just realize.. while typing this.. user cmplays did not ask for scores but finger etc. information.

I had a look into scores.xml, the hashes I saw there do not match file hashes.

So.. my question is.. is there a way to preserve score statistics when replacing a file on the file system? Or did I do something wrong? I use Synthesia 10.5 on Windows 7/64.

Thanks and kind regards,

PowerFritz

Nicholas
Posts: 12053

Post by Nicholas » 12-23-18 2:37 pm

The hashes in scores.xml are something a bit different than a file hash. Historically I've called them "configuration hashes" or "ConfigHash" and they're unique IDs based on which notes were selected to be played by the user for that performance. So, you'll get a different ConfigHash depending on which hand you choose, etc.

The way to link things back together is by looking at the leftHand, rightHand, and bothHands attributes in songInfo.xml. The "hash" attribute there is the file's MD5 like you'd expect. Then, the three other hashes are each the ConfigHash for the given part, which should match up with the values in scores.xml.

PowerFritz
Posts: 6

Post by PowerFritz » 07-15-19 1:26 pm

Hi again,

let me give a comment on that.. I think it doesn't work like this, but it helped :-).

What I mean.. in songInfo.xml I see songs with left-/right-/both hands attributes, but they don't match with config hashes in scores.xml. I already tried to grep in all xml files for the MD5 file hash to find any link to scores.. but nothing. Moreover.. since there are 9 lists of scores per song (melody, rhythm, concert with left-/right-/both hands), I would expect 9 links in songInfo.xml, so.. as much as I can say, the config hashes in scores.xml get calculated somehow, but they are not linked as they are to any another file.

But that doesn't matter.. my way to keep scores after I did some change to a midi file (and changed its MD5):

only use scores.xml:
1.
Find config hashes (up to 9 hashes) of the old version.. by searching for score/date (e.g. score="9982" or "2019-Jul-15"). They're kept even if linked songs hash was changed. You can also do that by doing some quick practice to the old song as first practice activity of a day, so this date won't exist in scores.xml yet. Practice step by step (up to 9 times), so you can search by today's date and sequence of time stamp in scores.xml.

2.
Put new midi in place, start praticing again. Now you can identify new version's new config hashes by date. Copy line blocks from old config hash to the new one. That's it.

If I missed something or something is wrong.. I'm sorry, please let me know.

Kind regards,

PowerFritz

Nicholas
Posts: 12053

Post by Nicholas » 07-15-19 3:17 pm

That's a reasonable way to do it. I'll have to double-check the 9 hashes things. I would have expected melody vs. not-melody (rhythm and recital are treated the same, except recital happens to be locked at 100% speed) to be the only extra distinction, so there should only be up to 6 possible hashes.

Post Reply