MIDI note message to trigger a button press

@Andy
I’ve been playing around with this and I love what you have going on here.
I have a computer sending midi note on with a velocity over a network to the host computer which has companion running on it. I can confirm that the message is being sent correctly (MidiView app on the host machine) but I believe that companion is holding on to the note velocity because when I set up a button name to have the variable $(generic-midi:_noteon_1_51) it indeed does show what the velocity was that was sent but holds on to this indefinitely. Even when I send it a midi note off for that note, it continues to hold on to the velocity it was originally sent with the note on command. I also sent it different velocities and it still shows the original velocity. However, in the feedback, if I set the velocity to the last sent note, it triggers there correctly. So maybe I am doing something wrong here hopefully that can be addressed. Thanks!

I’m really sorry, I’ve been messing around trying to figure out how to construct a trigger that is actuated by a MIDI note on command - and so far am failing utterly. Could anyone who has got this working share details or a screenshot? I have imported the example companion config, and that is working - it’s getting a trigger working using the MIDI feedback that is, so far, eluding me. Sorry not to have been able to figure this out - it’s not for want of trying.

Yeah this is what I have been trying to do as well and not doing great with it. I have tried to create an internal button press if a condition was met, the condition being incoming MIDI but can’t seem to get that to do anything. Also have tried to get it to do a trigger if true but it gets stuck on and I can’t get it reset after that even if I send a velocity of 0 for the previous note.

The MIDI note on will work, but it basically “turns on a switch”. Once the switch is on, it doesn’t get turned on again until you turn it off. Turning it off requires a midi note number with a different velocity.

Clearly though, this is something that people are looking to be able to do without using a 2nd message, so I’ll do some research and see if there’s a way…

2 Likes

Thanks so much. I’m basically looking to see if I can do something like Midi Relay’s “triggers” facility, which lets you tell it that a particular note-on message, say, should cause a particular HTTP request to be sent (e.g. to Companion’s HTTP remote control API).

Understood. Thank you for letting me know about that feature.

It’s not really the way MIDI works, if you think of it historically - it was designed for synthesizers in the early 1980’s.
For example, the note-on message:
A note-on message would be sent when a key is pressed on the keyboard. The receiving end would “know” that the key is STILL pressed because it doesn’t assume it’s released until it receives a note-off message. That way the keyboard doesn’t have to continuously send note-on messages the whole time someone’s holding a key down. This is important to keep the data flow to a minimum. Any additional note-on messages (for that same note and channel) would simply be ignored until it saw a note-off message. That’s the way MIDI was designed, all those years ago!

As I’m using MIDI libraries, they follow that same MIDI specification, but I’ll scratch my head to see how I can massage it into NOT ignoring additional note on messages without any note-off messages.

Ok, thanks to a suggestion from @millse , I have added a “last Message Received” variable, which you can use to create a trigger to do what you’re asking. Hopefully it works for you - let me know!

Here’s a video of how to use it. You’ll need the latest build (1.1.5 or later).

3 Likes

Thanks so much, will give that a spin!

1 Like

Yes, this works - thanks so much! I think I do need to check carefully what happens if we’re trying to respond to two MIDI events in close succession.

1 Like

In my testing, it works down to 11ms. If the messages come in at 10ms apart or quicker, then it will miss the message unless it’s the last one.
That’s on a Mac mini m2. On an RPI, it has to be above 21ms between messages.
Let me know what you find.

1 Like

Please download v1.1.7, it has a bug fix for realtime messages.

1 Like

@Andy

YES! Everything works how I need it to! Thank you for the video and the super useful module!
Also a huge thanks for listening to what I needed and making the changes. I really appreciate that.

1 Like

Your post made my day. That’s great, and thank you for letting me know.

1.1.7 is now part of the main beta build. :blush:

So, this will work for 99% of what I want to do with it using triggers. However, I just need to ask for my own sanity… is it possible to do a button press without having to make a trigger? I have tried on the button itself as a press action, internal: Button: Trigger press and release if variable meets condition, and I made the condition the new last message received = the message (in my case noteon_1_11_127) and that doesn’t press the button for me. Should I just give that up or is there a way I can make this happen?

I’ll have to check this out. My first thought was that this should work!
Ok, I realize why it doesn’t. It’s an “action” which means it only checks at the moment that the button is pressed.
Triggers (and feedback) can run anytime, so that’s the difference.

Two questions:

  1. Can I go back to the stable release and still run your module? (I don’t love running in a beta version in a production environment)
  2. If I do stick with the beta version, how can I know if it is using the module on my local computer vs. the one available in the app itself?

The stable release won’t have the MIDI module in it, so you’d have to add the module downloaded from here with that version of Companion.

It’ll be easy to tell if Companion is loading my module, as there will be a “generic-midi” module available when you type “MIDI” in the “Add Connections” dialog.

If you’re running the beta version of Companion, it already includes the v1.1.7, but if you had a local version, you would see in the log “(Overridden)” when you’re using the local version. e.g.:

24.03.19 12:38:40 Instance/Modules: Looking for extra modules in: /Volumes/WD-2TB/Dropbox/Documents/companion v3/companion-module-dev
24.03.19 12:38:40 Instance/Modules: Found 5 extra modules
24.03.19 12:38:40 Instance/Modules: bonjour-test@0.0.1: checkcheckonetwo: bonjour (Overridden)
24.03.19 12:38:40 Instance/Modules: cockos-reaper@2.1.0: Cockos: REAPER (Overridden)
24.03.19 12:38:40 Instance/Modules: generic-midi@1.1.7: generic: MIDI (Overridden)
24.03.19 12:38:40 Instance/Modules: yamaha-clql@3.1.2: Yamaha: CL/QL (SysEx) (Overridden)
24.03.19 12:38:40 Instance/Modules: yamaha-rcp@3.4.9: Yamaha: RCP (Overridden)