How Do I Retreive Meta Message Values? #575
-
I am trying to read, from a .mid file, a few key meta message values, such as Key Signature, Time Signature, etc. I can detect them using statements like: But I am unable to work out how to then retreive the values, e.g., the numerator= and denominator= parts. I have hunted around for about an hour now to find a code example for doing this, but all I can find are examples of writing a MetaMessage, none for reading one. NOTE: I am more of a C++ guy, some Python experience, but not all that much. So my lack of understanding may be down to some combo of unfamiliarity with Python and, of course, none with mido (as yet). Any help appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi, and thank you for using mido! All the attributes are docummented.
You simply have to read them from the object: if msg.type == 'time_signature':
print(f"Numerator: {msg.numerator}")
print(f"Denominator: {msg.denominator}")
... Let me know if you need further clarification. |
Beta Was this translation helpful? Give feedback.
-
That's too easy! But, I just tried it and it works. Thanks for the quick response Raphaël. |
Beta Was this translation helpful? Give feedback.
Hi, and thank you for using mido!
All the attributes are docummented.
For the
time_signature
object you'll find the attributes:numerator
denominator
clocks_per_click
notated_32nd_notes_per_beat
You simply have to read them from the object:
Let me know if you need further clarification.