-
Notifications
You must be signed in to change notification settings - Fork 151
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
converting start/end position in terms of bar #119
Comments
Not really. The closest you can currently get is using I have sometimes thought about making a function which converts from absolute time in seconds to bar/beat position, and vice versa. It was mostly held up by the fact that there was no way to change both the wall-clock and metrical timing of a |
Thanx for the reply. Given the answer, is there a way to check whether a track is monophonic? Or, should I check for notes having the same start position? |
By monophonic I assume you mean that only at most 1 note is playing at a given point in time (i.e. no chords)? A simple and inefficient way to do that would be # instrument can be retrieved from the PrettyMIDI.instruments list
monophonic = True
for note1 in instrument.notes:
for note2 in instrument.notes:
if note1.start > note2.start and note1.start < note2.end:
monophonic = False |
Test for an instrument track being monophonic - probably not the most efficient way: def is_mono(instrument):
return (instrument.get_piano_roll() > 0).sum(axis=0).max() <= 1 Note it depends on |
As for obtaining the position within the metric grid (measure, beat) actually the MIDI may not contain enough information to precisely determine that. Consider the case with smoothly changing tempo represented just by varying note lengths in ticks, not by tempo change messages. We would have to estimate the tempo curve (instantaneous tempo function + phase of beats and measures) and then perform a mapping to the space of measures. In addition there might be changes in the key signature (eg. 4/4 -> 3/4), so the number of beats per measure may change as well. |
I actually have found this to be pretty rare in MIDI files found "in the wild", but it does happen sometimes. That's what the |
Hi Craffel, is this feature curently available? Could please give a hint on this? Thanks |
Hi Craffel, Thanks |
No, it's not a big priority for me, but a pull request would be welcome.
You can use |
HI Craffel, Thanks |
No, |
Is |
Hi Craffel, The midi files where not empty, pfa the ones that i tried with. Just changed the extension as jpg to upload. You could download and rename as midi. Thanks |
The files you uploaded do not produce empty piano rolls. import pretty_midi
pm = pretty_midi.PrettyMIDI("Anger_Abm_145bpm_7 - Copy)
import numpy as np
print(np.all(pm.get_piano_roll() == 0))
print(np.nonzero(pm.get_piano_roll())) produces
I'm sorry but I can't continue to provide this kind of support - these GitHub issues are for reporting bugs, not for helping with usage of the library. |
Hi Craffel, Thank you so much for these inputs and our sincere apologies for all those silly questions. Just started using the library and getting used with the terminologies and methods. As the domain is music which has multiple terms for the same thing, finding it a bit difficult to understand whether the intentions of certain methods are what we expect to be. Will surely limit our questions are will post everything together. Thanks |
Hello. I tried this and it works pretty well for determining mono instruments. Can you shed some light on why this works? Thanks |
Is there a way to represent the start/end position of notes in terms of bar, and vice versa?
(I don't know if "bar" is the right term. I mean a musical length period that is equal to 4 successive notes of quarter lengths.)
The text was updated successfully, but these errors were encountered: