Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
174 stars 17 forks source link

Some Midi files play at wrong speed #91

Closed sneakernets closed 6 years ago

sneakernets commented 6 years ago

Some midi files seem to play at half speed. I have an example midi file attached. the tempo is 120, and ADLMIDI appears to play it at 60. Summer In The Park.zip

Wohlstand commented 6 years ago

The tempo it takes is 100, and it's because the file itself is sucky and possibly saved by FL Studio. I totally annoyed on it's MIDI files are has wrong offset of tempo event, or the tempo event is storing on some far-far place that is NOT correct for MIDI file...

Wohlstand commented 6 years ago

Anyway, I'll review it's internal more detailled, possibly I'll have some workaround to support them. The issue is same to OPNMIDI too

Wohlstand commented 6 years ago

While I'm at my job, I can't do anything now, but you can try to compile this editor: https://github.com/Wohlstand/MidiEditor and check out how the tempo event is stored (scroll down in the main window to see non-note events are under the piano). The oldy Sonar 1.2 at me fails to load those damned MIDI files correctly, therefore I fixing them through this MidiEditor to continue the work on them in the Sonar.

sneakernets commented 6 years ago

From what I remember, this was created using a very old sequencer called "NoteWorthy Composer"

sneakernets commented 6 years ago

Ah haaaa! I found out what the issue is - in the original MIDI spec, if the tempo wasn't specified, it was assumed to be 120 bpm at 4/4. I didn't know that, as Yamaha always placed tempo markers regardless...

Wohlstand commented 6 years ago

Okay, now I can check out the internals of this MIDI file to say why it gives a crap...

default

The Tempo marker IS in the MIDI file, but... it seems incorrectly aligned and missing up while MIDI data parsing... That case is needed to be checked...

Wohlstand commented 6 years ago

Anyway, if it's really default tempo must be 120 than 100, seems it's need to change that to let all tempo-less MIDI files play 120 tempo. Later I'll dump all raw events of MIDI file and check the logic...

Wohlstand commented 6 years ago

Just now I have made a small fix, and the thing must work now... Try it out :wink:

sneakernets commented 6 years ago

I'll try this now! thanks!

sneakernets commented 6 years ago

Yay! it works!