Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MIDI ProgChg triggering Menu
#1
I have a foot switch sending ProgChg messages and using Gintaras MT_MidiInProc with a little modification the foot switch now can trigger Gintaras' sample dialog items. The ProgChg messages live in p1 (see code below, where in line 4 you can 'out' the MIDI messages having three fields msg, p1, p2 ). They appear to be in the one but last byte of p1, so that this byte has to be filtered out (p1 & 0x0000FF00) and bit shifted 8 times (>>8) to produce the code of the switch pressed.

Note: Using the mac MT_Main can produce a conflict where either MidiTriggers does produce an error message or the first enumerated MIDI device in the Example Menu cannot be found in your software. Here's how to solve that.

Example: Using a keyboard and a foot switch and 4 virtual MIDI ports (LoopBe ) there are 6 ports showing up in the QM MIDI Triggers Example Dialog under MIDI input device. Choosing any port from this list while another program is using even only one of these MIDI controllers produces a confusing error message: 'There is not enough memory available for this task'. Confusing , since it has nothing to do with memory, but with ports in use. Even if you now choose a free port from the drop down list, the same error message will appear! It only disappears after closing all your other software using MIDI devices, thus freeing their ports.

There are two solutions.
1- Start MT_Main before any other software and choose a MIDI port from the drop down list that you know is surely unused later on. This works but the drawback is obvious.
2- In MT_Dialog the parameter tls1 determines the port number to be used. If you change that to a surely always free port you're fine. Add a line tls1=YourFreeportnumberHere, just after rget(tls1 "midiinid" "" 0 -1). How to get the correct tls1 (zero based) value? Connect all MIDI devices, start the MT_Dialog and get the position number of your free port shown in the MIDI input device drop down list. Subtract one and add the code mentioned above. Now you can start your software in any order you like.

Having QM do stuff with a MIDI foot switch is really fun. Moreover QM offers another advantage where I often find myself using free VST plugins, which have UI's that show no handles, no id's :-( Using 'Find accessible object', finds their Title Bar which is usable. From where a.Mouse(1) lands on this Title bar you can mou+ x y in order to press the desired button with a lef. However you still need the x y values in pixels. I have made a macro (+ FF + Toolbar) for the purpose: If you get your macro working to the point where the a.Mouse(1) lands on the Titlebar you just press and hold Ctrl-Alt-Shift_LeftMouse. If you now move the mouse to the desired button and you can read the relative mouse coordinates from the Toolbar which gets created by the macro (attached)

Please add your own experience below.

Have fun!

Function MT_MidiInProc1
Code:
Copy      Help
;;out p1
if(p1 = 0xfe) ret
;display messages:
out "msg=0x%-10.8X    p1=0x%-10.8X    p2=0x%-10.8X" m p1 p2

;get ProgChg:
str sk=p1 & 0x0000FF00 >> 8
out sk
;run menu:
mac _mt_menu sk
err act _hwndmt

;Function receives MIDI input messages and filters
;ProgChg messages. When you press e.g. a Foot Switch
;with number that match MT_Menu item label, menu item is executed.


Attached Files
.zip   MouseMeasurent1.zip (Size: 1.02 KB / Downloads: 433)


Forum Jump:


Users browsing this thread: 1 Guest(s)