craffel/pretty-midi

Setting or changing Tempo of a Midifile

soorejmg opened this issue · 8 comments

Hi,
Is there an option to set or change the tempo of a midi file available?. Could you let know the way for this. Couldnt see anything other than seeing the estimated tempo in the document. Please advice

Thanks
Soorej

You can use adjust_times. There is no other way to change the tempo directly and have the event times update automatically.

Hi,
Is there an example how to do this?. Could not really understand it from the document. Please provide if you have any.
Thanks
Soorej

Hi, Thanks for this details. While trying to change the tempo, noticed some error in the tempo reading. Not sure whether the understandin is right, when i slow down the music , the tempo is increasing, while it should be a low speed music. For example,
my intiital tempo was 162 (assuming bps), Then i slowed down using adjust_time to 1.4 times of initial, but then it shows 214. The tempo should have been a lesser value. Please advice
Thanks
Soorej

Can you post code?

image

tempo_final
Out[241]: 214

tempo
Out[242]: 162

Don't use estimate_tempo; it will produce a (possibly incorrect) estimate and is only intended for files that do not have tempo change events annotated. Use get_tempo_changes.

Hi,
Thanks Craffel. It works. :)

Thanks
Soorej