Time passed between two events

Hello,

I’d like know how much time elapsed between two strokes of the same note and according to the result and other criteria take appropriate action, e.g. initiate a program change when the time elapsed is below 200 ms. I could not figure out how I can do that in a simple way with timers. It would be sufficient to be able to access the timestamp showed in the event monitor.

Hi,

For this we need a timer. The most accurate you can do with Bome MIDI Translator is 1 ms increments.

  • Translator 0.0 takes the desired note message and sets a snapshot of the known duration in the variable gb from the variable ga then prints it out. If it is the first note sent is says ‘No Previous Note’. After printing out the message it sets ga to a value of 0 and starts the timer. If the value of gb is less than 200 then Perform ‘PC’ is called with the value of the PC message.
  • Translator 0.1 is a repeating timer and just increments the value of ga at 1 ms intervals.
  • Translator 0.2 kills the timer (if needed) and set ga back to 0.
  • Translator 0.3 sends the PC

I set up my aliases as follows:
image

You can learn more about aliases from this tutorial.

note-timer-2024-01-04.bmtp (1.8 KB)

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Hi Steve,

Thank you for your help. From the knowledge I gained, and also from studying the new “Perform” action, I was able to integrate these timers into my existing program, and to my surprise it worked at the first attempt.
Application: When I play a certain key pattern (with time constraints) in a piece, a program change is issued so that the drawbar settings of an organ patch are changed automatically when I arrive at a certain position in the song.

Best regards, Alex

1 Like

Split Keyboard - Drawbar Organ - Ignore 79 7B - change program - V8.bmtp (20.8 KB)

Hi Steve,

Since I’m using the timer, I have delayed notes.

In the following example, I played 3 triads (chords with 3 notes), the first very short, the second shortly following the first, but held about one second, and the third chord again short.

What happened is the following: the first chord lasted 161 ms from start to end (which is ok), the second chord followed after 101 ms (which is ok), BUT LASTED 11’060 ms, and the third chord followed with a delay of 0 ms and lasted 0 ms.

As I didn’t hear the third chord, I quickly stopped playing, then heard it after 10 seconds, and copied the timestamped log:

52938540 - MIDI OUT [BomeBox: BomeBox DIN]: 97 3F 59
52938540 - MIDI OUT [BomeBox: BomeBox DIN]: 97 36 57
52938559 - MIDI OUT [BomeBox: BomeBox DIN]: 97 3C 53
52938672 - MIDI OUT [BomeBox: BomeBox DIN]: 87 3F 5E
52938686 - MIDI OUT [BomeBox: BomeBox DIN]: 87 36 5C
52938701 - MIDI OUT [BomeBox: BomeBox DIN]: 87 3C 56

52938802 - MIDI OUT [BomeBox: BomeBox DIN]: 97 3A 53
52938818 - MIDI OUT [BomeBox: BomeBox DIN]: 97 35 4B
52938826 - MIDI OUT [BomeBox: BomeBox DIN]: 97 3E 4B
52947059 - MIDI OUT [BomeBox: BomeBox DIN]: 87 35 54
52947059 - MIDI OUT [BomeBox: BomeBox DIN]: 87 3E 68
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 87 3A 5A

52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 97 3C 46
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 97 40 48
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 97 37 57
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 87 37 3D
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 87 40 52
52947062 - MIDI OUT [BomeBox: BomeBox DIN]: 87 3C 60

This means while playing the second chord there was a delay of about 10 seconds!
What happens here?

PS: I have to add that this happens only from time to time, and anywhere in the song.

Here’s another one, with a 4 second delay. I’ve printed out the timer every second.

68200317 - MIDI OUT [BomeBox: BomeBox DIN]: 95 46 3E
68200341 - MIDI OUT [BomeBox: BomeBox DIN]: 95 41 3B
68200366 - MIDI OUT [BomeBox: BomeBox DIN]: 95 4A 3C
68201091 - 3.1:4 ga=6000
68202091 - 3.1:4 ga=7000
68203091 - 3.1:4 ga=8000
68204091 - 3.1:4 ga=9000
68204491 - MIDI OUT [BomeBox: BomeBox DIN]: 85 41 3E
68204491 - MIDI OUT [BomeBox: BomeBox DIN]: 85 46 3C
68204492 - MIDI OUT [BomeBox: BomeBox DIN]: 85 4A 5A
68205091 - 3.1:4 ga=10000
68206091 - 3.1:4 ga=11000

Well this is quite more complex than I designed. It looks like you are using the same timer for several notes and the chances of all notes coming in at the exact same time is pretty slim. I’m not sure I’m in a position to debug the program that you designed. My example was to get you started with the simple concept of what you requested but not to debug your final code.

Was it your intend to use a single timer for all incoming notes? If so, when do you capture the start and stop time?
How long was the program running.

My recommendation is to put ‘Log’ messages at the key points that you want to monitor to try and figure out what is happening. I would pay close attention to Logging the start and stop points of the timer.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Yes, I need just one timer. If the last note of a sequence to trigger a program change is sensed by the translator, it’ll check the previous notes to determine if the sequence really happened and the time difference between the last two notes. If these criteria are fulfilled, the program change is issued. Regardless of the outcome, the timer is restarted.

But the program is a mess right now and I just wanted to know if it works in principle.

Regarding the problem with the delays, the only thing I can imagine is that I was offline temporarily (for a couple of seconds). I have checked my router settings and with the help of UPC changed some of its parameters. Hopefully this is it. I have not experienced the same thing since then.

Yes it should.

Maybe that was it.