python-midi icon indicating copy to clipboard operation
python-midi copied to clipboard

Cannot find BPM change event

Open TheMariday opened this issue 8 years ago • 10 comments

Hi there,

I can't seem to find the connection between ticks and ms.

I've got a few midi files with variable BPM's and I can't seem to see any BPM change events when inspecting the track data.

I've got it working fine when I know the BPM before hand, but if this is hard-coded in then I can only play songs with that specific BPM.

Thanks and looking forward to hearing back from you,

Sam.

TheMariday avatar Oct 02 '16 15:10 TheMariday

Are you completely sure that the BPM changes and it's not just that the notes have different time intervals?

MaurizioB avatar Oct 02 '16 23:10 MaurizioB

I like that hypothesis. The only way to tell for sure is if we can examine a MIDI file.

vishnubob avatar Oct 03 '16 05:10 vishnubob

Looks like I've figured this one out (sorry for pulling you in on this one!)

All my midi's are 120bpm. Ableton Live seems to have ZERO ways to export bpm or bpm changes with the midi file. Very very strange...

I'm gonna have to ditch all my songs with a variable BPM and input each songs BPM at command line.

Hey ho but thanks for the quick response.

Sam.

TheMariday avatar Oct 03 '16 15:10 TheMariday

Another approach would be to use references like bass drums etc to figure out the downbeat, and then to re-write the entire pattern with tempo changes. It would require some heuristics, and re-writing of all tick offsets, but it should be possible.

vishnubob avatar Oct 03 '16 18:10 vishnubob

Well, while heuristics would be interesting, the best solution is to take note of tempo changes, delete all of them, export again, and write a simple script that adds tempo maps to the new imported files using python-midi.

MaurizioB avatar Oct 04 '16 09:10 MaurizioB

I think the point is his track doesn't have tempo changes. Tempo maps are an invention of python-midi, and they rely on tempo change events. I don't think you could ever write a fool-proof algorithm that could infer tempo changes when there are no tempo change events. ie. I suggested heuristics because not because it's interesting, but because it's probably the easiest way to solve the problem of re-creating that information.

vishnubob avatar Oct 04 '16 12:10 vishnubob

Sorry, I meant Tempo Events. My solution was more a by-hand one: once you know when (in bars/pulses) a tempo change occurs, you export the track after removing all the tempo changes in it, and manually add them to the track using python-midi. Anyway, it amazes me that Live can't export tempo changes!

MaurizioB avatar Oct 04 '16 13:10 MaurizioB

It boggles me that live doesn't support this. Even if you re-inport the midi back into Live it still just defaults to 120 bpm...

I think I'm gonna make note of the bpm and the changes then add them in with a script. Or use a different midi sequencer because this is getting silly. Probably gonna switch over to cubase or fruityloops.

Thanks for everyone's input and I'd love to share my project with you when its done.

TheMariday avatar Oct 05 '16 08:10 TheMariday

thinking this through, i bet ableton converts MIDI tracks into its own internal timekeeping time structure. ableton tracks use INSANE resolutions in their exported MIDI tracks, which is probably a reflection of its internal resolution. of course ableton tracks tempo changes, it just doesn't export them as MIDI because, well, that's not really ableton's wheel house (exporting MIDI files). i'm guessing the problems of exporting MIDI from their internal structures are non-trivial.

vishnubob avatar Oct 05 '16 13:10 vishnubob

Are you suggesting extracting the bpm from Abletons internal structure? That would be a challange,

In the meantime I've switched over to fruityloops. Still gobsmacked that it doesn't support this...

TheMariday avatar Oct 11 '16 10:10 TheMariday