-
Hello everybody Anyway I have this very basic piece of script from mido import Midifile , Message, MetaMessage
mf = "somefile.mid"
mid = MidiFile(mf)
track = mid.tracks[0]
for msg in track:
d_msg = msg.dict()
print d_msg which gives me {'type': 'text', 'text': '/Je', 'time': 720}
{'type': 'text', 'text': " n'ai", 'time': 240}
{'type': 'text', 'text': ' pas', 'time': 240}
{'type': 'text', 'text': " d'au", 'time': 480}
{'type': 'text', 'text': 'to...', 'time': 240}
{'type': 'text', 'text': '/Je', 'time': 720}
{'type': 'text', 'text': " n'ai", 'time': 120}
{'type': 'text', 'text': ' pas', 'time': 240}
{'type': 'text', 'text': " d'vé", 'time': 480}
{'type': 'text', 'text': 'lo...', 'time': 360} now I modify the value for the key 'type' if d_msg['type'] == 'text' :
d_msg['type'] = 'lyrics'
print(d_msg) wich gives me {'type': 'lyrics', 'text': '/Je', 'time': 720}
{'type': 'lyrics', 'text': " n'ai", 'time': 240}
{'type': 'lyrics', 'text': ' pas', 'time': 240}
{'type': 'lyrics', 'text': " d'au", 'time': 480}
{'type': 'lyrics', 'text': 'to...', 'time': 240}
{'type': 'lyrics', 'text': '/Je', 'time': 720}
{'type': 'lyrics', 'text': " n'ai", 'time': 120}
{'type': 'lyrics', 'text': ' pas', 'time': 240}
{'type': 'lyrics', 'text': " d'vé", 'time': 480}
{'type': 'lyrics', 'text': 'lo...', 'time': 360} and now I am completely stuck when I want to turn the I think that I need to use the from_dict method , but I do not know how to do that Thank You In Advance for any kind of help Alain |
Beta Was this translation helpful? Give feedback.
Answered by
AL1-1956
Sep 24, 2023
Replies: 1 comment
-
Okay so I found out , and it was pretty obvious new_msg = msg.from_dict(d_msg)
print(new_msg) So I close the case |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
AL1-1956
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay so I found out , and it was pretty obvious
So I close the case