mido icon indicating copy to clipboard operation
mido copied to clipboard

I cannot modify time of a message!

Open csarami opened this issue 4 years ago • 1 comments

Hi,

I have a list of times expressed in ticks and a list of messages (meta), I'd like to change times of the messages to match the times in the list.

tickList = [....]

i= 0
for msg in t:
    while i < l-2:
        if msg.is_meta and hasattr(msg, 'data') and len(msg.data) == 7: 
            msg.time = tickList[i] if i == 0 else tickList[i+1]-tickList[i]
        i +=1

However, times remain the same! why, please?

10 <meta message sequencer_specific data=(67, 123, 1, 52, 0, 52, 127) time=1920>
11 <meta message sequencer_specific data=(67, 123, 1, 50, 8, 50, 127) time=1920>
12 <meta message sequencer_specific data=(67, 123, 1, 50, 8, 50, 127) time=3840>
13 <meta message sequencer_specific data=(67, 123, 1, 50, 8, 50, 127) time=1920>
15 <meta message end_of_track time=0>

Any help would be greatly appreciated.

CS

csarami avatar Apr 19 '20 22:04 csarami

I am not sure what exactly you want to do. Do you have a list of time values that you want to attach only to messages that match the if statement?

What the code does is to loop over all messages, and then for each message it for loops and tries to set the time attribute of that message multiple times. This doesn't seem quite right.

If your tick list has one tick value per message you can simply do this:

for msg, ticks in zip(track, tickList):
    msg.time = ticks

but it looks like you're doing something a bit more complex.

olemb avatar Dec 18 '20 01:12 olemb