Closed BaptisteLoquette closed 2 years ago
MIDI files do not have a sampling rate per se. You could probably compute an optimal sampling rate based on the pulses per quarter note value of the MIDI file, but there would not be a fixed sampling rate - it would depend on the tempo, which can change over the course of the file.
Okay I see, but from the tempos could I determine the best sampling rate ?
You could, but it would vary over the course of the MIDI file.
But a software like MuseScore3 seems to find the appropriate sampling rate to render from the initial MIDI file, though with the combination of get_piano_roll() then piano_roll_to_pretty_midi() the rendered MIDI file in MuseScore seems either too slow either too fast you see ?
piano_roll_to_pretty_midi is an approximate/example function - you should not use it for anything except for fun.
Okay I see, but get_piano_roll() can be used no just for fun right ?
Depends on your definition of fun, I guess. It should only be used in settings where using a fixed sampling rate for the entire MIDI file is appropriate/workable.
I see, thanks for all your answers, I really appreciate that. Supposing a constant known tempo how could I determine the best sampling rate pls ? If you don't have time to answer could you give me some references on the subject pls ?
You'll need to set it according to the pulses per quarter note and the tempo - you can start with https://en.wikipedia.org/wiki/Pulses_per_quarter_note. I will leave derivation of the exact formula up to the reader :)
Thx !
Hello, hope you're doing well. When using the get_piano_roll() function, the sampling rate it set by default to 100, but for many midi files it doesn't fit good. When using the piano_roll_to_pretty_midi() function we can see a lot of changes in comparison with the original MIDI file.
How to get the right sampling rate ? I can't find a function to get the sampling rate of the initial MIDI file through pretty midi or Mido. Can you help me please ?
Thanks