Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tempo not right when exporting from FL Studio #5

Open
MisterX2000 opened this issue May 25, 2017 · 5 comments
Open

Tempo not right when exporting from FL Studio #5

MisterX2000 opened this issue May 25, 2017 · 5 comments

Comments

@MisterX2000
Copy link

When I play a midi file downloaded from the web it works fine, but when I edit it in FL Studio and export it the tempo is not properly recognized by floppymusic. (It works fine in VLC Player and Windows Media Player)
I'm using a Raspberry Pi 1 Model B.
Any help would be appreciated.

Example files (modified is exported using FL Studio and the other is the original):
TheBlackPearl.zip

@Kingdread
Copy link
Owner

Unfortunately, I don't have my drives available, so I can not test my theories. From a quick debugging, it seems that floppymusic only reads 3 tempo change events from the modified MIDI, while it reads 156 from the unmodified file. That might explain the discrepancy.

floppymusic assumes that all tempo events are saved in the first track of the MIDI and that those are applied to each track. You can try applying the following patch, which will look for tempo events in each track, but only apply them to the corresponding track:

diff --git a/src/MidiFile.cpp b/src/MidiFile.cpp
index a03d413..c68ba2b 100644
--- a/src/MidiFile.cpp
+++ b/src/MidiFile.cpp
@@ -89,7 +89,7 @@ bool MidiFile::read(std::istream &inp)
     {
         // Tempo information should be stored on the first track and
         // (au contraire to what I thought) applied to every track.
-        (*tr)->calc_realtimes(m_time_division, m_tracks[0]);
+        (*tr)->calc_realtimes(m_time_division, *tr);
     }
 
     return true;

Also, I've looked at the files with rosegarden and MidiEditor. While rosegarden seemed to apply the tempi correctly, MidiEditor sounded about 50% "slower" (3 beats in 1.5s, compared to 3 beats in ~1s in the unmodified file). Is that what you hear with floppymusic too?

@MisterX2000
Copy link
Author

I've applied your code, but now both midis are slow. I've also tested it in MidiEditor and that is what I hear when I play the files with floppymusic.

@MisterX2000
Copy link
Author

And I've noticed that the tempo information is stored in the second track, not the first when you export via FL Studio. Can't you just read the tempo information from all tracks and apply it to all?

@Kingdread
Copy link
Owner

I guess using all tempo events could be possible, but would probably be behing a flag, as this SO question/answer suggests that tempo information should be in the first track (where MidiEditor probably expects it, too).

If you just want your FL Studio MIDIs to work, you can replace the (*tr)->calc_realtimes(m_time_division, *tr); line with

(*tr)->calc_realtimes(m_time_division, m_tracks[1]);

which will use tempo events from the second track for everything.

@MisterX2000
Copy link
Author

Ok, thanks. I've tried it out and it works, maybe I can find an option in FL Studio to switch the tempo track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants