stevenwaterman / musetree

AI Music Generation for the Real World
http://musetree.stevenwaterman.uk/
MIT License
236 stars 33 forks source link

Tempo incorrect on imported midi #42

Open stevenwaterman opened 4 years ago

stevenwaterman commented 4 years ago

After exporting and re-importing a MIDI, the tempo is incorrect

In the attached (rename to .mst), 1 was exported and imported, becoming 5. In MrCheeze's MuseNet Midi, it is imported correctly, so my fork has done something wrong with the import code.

Save(15).txt

stevenwaterman commented 4 years ago

Fixed in v2.1.2

Was caused by a rounding error and the fact that my brain works in java but musetree uses javascript. Block of code went like:

desiredWaitTime = 50;
fullWaitBlocks = desiredWaitTime/128;
for(let i = 0; i < fullWaitBlocks; i++) {
    addWaitBlock()
}

In java 50/128 = 0 because of integer division but in javascript is 0.3ish which obviously is greater than 0. Fixed by adding a Math.floor in https://github.com/stevenwaterman/musenet-midi/commit/eda19d12a77e6f91bced602e611f6ac91fca4480

farfromsubtle commented 4 years ago

Oh I just posted this issue without seeing this ticket. Seems it still persists. Example file has been provided in the other thread.

stevenwaterman commented 4 years ago

From the other thread:

So far I have been unsuccessful at importing midi except for ones generated by musetree itself.

It seems that if I export from a DAW the notes are intact when imported to musetree but the tempo is slowed down drastically (I would guess around 50 bpm).

I even tried using mrcheeze's provided base midi to create my import with the same issue.

I exported from both Studio One and Logic Pro with the same effect.

Example attached.

base styx.mid.zip

stevenwaterman commented 4 years ago

Confirmed that this is the same bug. Musenet-midi import is adding 4095 tokens when importing. Bug is not present in mr cheeze's musenet midi.

stevenwaterman commented 4 years ago

This should be fixed v2.3.0. I had overlooked the part of MrCheeze's where he extracted the bpm from the MIDI header. I tested it with the midi you sent and it's working.

However - there's 3 different ways to specify tempo in a midi (Time division, ticks per beat, and ticks per frame + frames per second). MrCheeze's only supports ticks per beat. I've tried my best to support time division + frames, but I'm not convinced I've got it right. If you find issues with the other methods, let me know and I can try again!

stevenwaterman commented 4 years ago

Closing due to lack of activity, assuming it's fixed. Feel free to comment if anyone issues with this still and I'll re-open.

FlashlightET commented 3 years ago

Still importing too fast on some midi files. only some though, which is weird also github issue: site doesnt support midi attachments as if theyre dangerous malware or something Example File 1 (Fast) Example FIle 2 (Fast) Example File 3 (About Correct) All 3 files exported in FL Studio, same version

stevenwaterman commented 3 years ago

Yeah I noticed this myself recently. I'm not actively working on MuseTree other than messing around on it for my own use, but if/when I pick it up again I'll look into this. Personally I just bodged it by adjusting the Midi tempo to get it importing at the right tempo (not a great solution, sorry)