Jump to content

"Compare" button - how to recognize it for MCU controller? any idea?


vladistone
Go to solution Solved by Jordi Torres,

Recommended Posts

actually - in the title the question is:

how to recognize and assign the "compare" button for the MCU controller. for any option from the list:
- Global mode or parameter settings;
- Assignment Control;
- FX GUI;
- in 3D part plugins and instruments


any idea? patches? javascrips? experience...

Edited by vladistone
Link to comment
Share on other sites

45 minutes ago, vladistone said:

how to recognize and assign the "compare" button for the MCU controller.

My MCU does not have a "compare" button. If you mean, how you can you select a plugin header's compare button via the MCU, that's not something the Mackie Control protocol lets you do. Neither is there a key command in Logic for this either, I believe.

The only way I could think of achieving this, especially as you may have many different plugin windows, is to dedicate an MCU button for this and use this to run a Keyboard Maestro macro that does a screen image search for the plugin header compare button and click on it - but you'd have to handle potentially multiple plugin windows, and overlapped windows etc.

Edited by des99
Link to comment
Share on other sites

25 minutes ago, des99 said:

У моего MCU нет кнопки "сравнить". Если вы имеете в виду, как вы можете выбрать кнопку сравнения заголовка плагина через MCU, это не то, что протокол Mackie Control позволяет вам делать. Насколько я знаю, для этого в Logic тоже нет ключевой команды.

Единственный способ, который я мог придумать для достижения этого, тем более, что у вас может быть много разных окон плагинов, — это выделить для этого кнопку MCU и использовать ее для запуска макроса Keyboard Maestro, который выполняет поиск изображения на экране для кнопки сравнения заголовка плагина и щелкните по нему, но вам придется обрабатывать потенциально несколько окон плагинов, перекрывающиеся окна и т. д.

if I understand you correctly, then LPX does not have a specific parameter for this interface button? and even an ASCII keystroke won't trigger the action? ; GUI only with mouse?

Is there really no hack to intercept the control signal? The Remote control uses touchscreen control and OSC...

Edited by vladistone
Link to comment
Share on other sites

40 minutes ago, vladistone said:

then LPX does not have a specific parameter for this interface button?

Not a control surface parameter or a key command that you can trigger from an MCU, no.

40 minutes ago, vladistone said:

GUI only with mouse?

Correct - as far as I know.

41 minutes ago, vladistone said:

Is there really no hack to intercept the control signal? The Remote control uses touchscreen control and OSC...

I don't know how the Remote communicates, I've not looked into that too much. But remember, Logic Remote communicates directly with Logic (via the custom code in the Logic Remote control surface module), not via the MCU protocol, so they can implement what they like for this, including remotely adding plugins and accessing anything in the Logic codebase etc. That doesn't mean that is something the user can necessarily do, or do easily.

I haven't looked - can you add this Compare command in Logic Remote?

Link to comment
Share on other sites

11 minutes ago, des99 said:

Я не смотрел - вы можете добавить эту команду сравнения в Logic Remote?

I try to investigate this transmition right now... using the OSC monitor

https://apps.apple.com/us/app/protokol-midi-osc-monitor/id1451570764

and from this app:

https://github.com/kasperkamperman/OSCDataMonitor

  • Like 1
Link to comment
Share on other sites

bad news: compare function disabled into Remote control.

Perhaps there are other ways to perform the "compare" actions? Even the ASCII keystroke option would be good; Since a similar type of event can be organized by the some devices (for example: SSL nucleus controller). 

I hope for a common collective reasonable solution 🙂

Edited by vladistone
Link to comment
Share on other sites

  • Solution

Hi @vladistone,

19 hours ago, vladistone said:

Perhaps there are other ways to perform the "compare" actions?

That Compare button on plugin windows can be easily toggled with AppleScript:

 

TogglePluginCompareAppleScript.thumb.gif.72d88673059cf07011b90cc99873ba39.gif

In turn you can trigger the necessary AppleScript via keystrokes, MIDI or even OSC. Like @des99 mentioned, Keyboard Maestro can help with that, but if you'd rather do it without buying a KM license and/or you don't mind writing a bit of Lua code, then there's Hammerspoon.

J.

Edited by Jordi Torres
changed GIF
  • Like 2
Link to comment
Share on other sites

Yes - when I say "something like KM", I generally mean, KM can do it easily (running macros triggered from MIDI commands that perform GUI actions and more in one self-contained utility), but there are also other tools that can broadly achieve similar things, with varying degrees of utility and ease.

  • Like 1
Link to comment
Share on other sites

8 hours ago, Jordi Torres said:

Hi @vladistone,

That Compare button on plugin windows can be easily toggled with AppleScript:

ToggleCompareAppleScript.thumb.gif.5662645514e9e8d5c40bfd38dd81a795.gif

In turn you can trigger the necessary AppleScript via keystrokes, MIDI or even OSC. Like @des99 mentioned, Keyboard Maestro can help with that, but if you'd rather do it without buying a KM license and/or you don't mind writing a bit of Lua code, then there's Hammerspoon.

J.

Unbelievable, but I was hoping for similar scripting technologies ... it remains to learn the language!
by the way, the MIDI javascript engine (embedded in LPX) - can help? or is external GUI event handling required?

The main benefit of the forum is that productive thoughts and efforts are formed without unnecessary white noise around problems! thank you so much for thought in the direction of goal

Edited by vladistone
Link to comment
Share on other sites

Espesial thanks to @Jordi Torres ! 👍

I followed your hint and to use AS (Applescript) by MCU controller.

I didn’t invent too much how to launch the csript. Was seted script-file execution through the MacOS VoiceOver utility:

- by add single string of the keystroke command option to run the AS.

I admit that I had to turn off a lot of different settings of VO and allow the accessibility settings of the computer in the "privacy" section. But now the LPX GUI "compare" button has become obedient for external MIDI-controllers!

I'm not sure if this is an elegant solution for running a script... maybe there is a cheaper and easier solution... for example using the same applescript? or other apps (there is a lot of information on the net about using the MidiPipe AppleScript Trigger, and there are also options for using the MSC protocol through the LXscript player,.. this requires a deeper dive into learning javascripting...), but maybe I will reconsider my preferences if this method will show its clumsy abilities in the future...

 

Edited by vladistone
  • Like 1
Link to comment
Share on other sites

Hi @vladistone,

Glad to hear that bit of AppleScript helped.

However later I found out that sometimes the number associated to the Compare button can change (for example, from "checkbox 3" to "checkbox 2"), so it's better to refer to it by name, like so:

tell application "System Events"
  tell process "Logic Pro"
    click checkbox "Compare" of window 1
  end tell
end tell

---

9 hours ago, vladistone said:

by the way, the MIDI javascript engine (embedded in LPX) - can help?

Not for this, no.

 

3 hours ago, vladistone said:

I admit that I had to turn off a lot of different settings of VO and allow the accessibility settings of the computer in the "privacy" section. But now the LPX GUI "compare" button has become obedient for external MIDI-controllers!

I'm not sure if this is an elegant solution for running a script... maybe there is a cheaper and easier solution... for example using the same applescript? or other apps (there is a lot of information on the net about using the MidiPipe AppleScript Trigger, and there are also options for using the MSC protocol through the LXscript player,.. this requires a deeper dive into learning javascripting...), but maybe I will reconsider my preferences if this method will show its clumsy abilities in the future..

You could actually set this all up with a single Hammerspoon (Lua) script that would trigger that AppleScript whenever a specific MIDI message from a specific MIDI device comes in, and only when Logic Pro is in focus (i.e. is the frontmost application).

Luckily for you I already had some Hammerspoon scripts for this kind of thing, so one of my scripts could easily be adapted to your particular scenario.And yes, when using AppleScript like this and a tool like Hammerspoon you will have to allow them to "control your computer" via System Preferences > Security & Privacy > Accessibility.

Do you know already know which MIDI command you want to use to trigger the AppleScript?

J.

Edited by Jordi Torres
  • Like 1
Link to comment
Share on other sites

 

VO is mapped to a keystroke... and my controller is capable of generating ASCII, CC# and classic MCU/HUI MIDI emulations. so I haven't thought about assigning a MIDI event yet...


What confuses me so far is the many translator programs for GUI control using devices. This complicates the maintenance and configuration of peripheral equipment, the scheme of which must be kept in mind at all times.

Diagram.jpeg

Edited by vladistone
Link to comment
Share on other sites

1 hour ago, Jordi Torres said:

Hi @vladistone,

Glad to hear that bit of AppleScript helped.

However later I found out that sometimes the number associated to the Compare button can change (for example, from "checkbox 3" to "checkbox 2"), so it's better to refer to it by name, like so:

tell application "System Events"
  tell process "Logic Pro"
    click checkbox "Compare" of window 1
  end tell
end tell

---

Not for this, no.

You could actually set this all up with a single Hammerspoon (Lua) script that would trigger that AppleScript whenever a specific MIDI message from a specific MIDI device comes in, and only when Logic Pro is in focus (i.e. is the frontmost application).

Luckily for you I already had some Hammerspoon scripts for this kind of thing, so one of my scripts could easily be adapted to your particular scenario.And yes, when using AppleScript like this and a tool like Hammerspoon you will have to allow them to "control your computer" via System Preferences > Security & Privacy > Accessibility.

Do you know already know which MIDI command you want to use to trigger the AppleScript?

J.

Hi @Jordi Torres! You are intrigued me by Hammerspoon scripts. I neve used Lua coding. Please show your works examples.

so it would be ideal to have a general translator or programming environment for all non-standard assignments.

and for other users it would be a good example of your code.

Edited by vladistone
Link to comment
Share on other sites

I found is that Hammerspoon have many releases and there is no descriptions. I'm running MacOS 10.13.6 and the latest release doesn't work for me. Is it correct to use the applicable release with so many configurations and PRs?

Edited by vladistone
Link to comment
Share on other sites

Again, Keyboard Maestro, while not cheap, lets you do *all* of this (listen to incoming MIDI, run scripts, click on GUI elements, and much more), without requiring you to learn any coding at all, and without requiring multiple interacting pieces of software - which is why I recommend it for this kind of thing. It may cost some money, but it saves an incredible amount of time and effort into researching, piecing together, and learning a bunch of different technologies for these kinds of problems.

(KM has saved me so much time, effort (and hair!) over the years, it's been *well* worth the price! But it's probably overkill if you only ever want it for this one time, of course.)

Anyway, it seems you're happy enough going the more complicated route 🙂 , so hopefully you can achieve what you want in the way that makes most sense for you. 👍

Edited by des99
Link to comment
Share on other sites

Hi vladistone,

1 hour ago, vladistone said:

I'm running MacOS 10.13.6 and the latest release doesn't work for me.

That surprises me a bit, based on the release notes macOS 10.13 is precisely the minimum supported version right now. You could anyway try with a slightly older version than the latest. 

I'm attaching a script that does what I mentioned before:

4 hours ago, Jordi Torres said:

You could actually set this all up with a single Hammerspoon (Lua) script that would trigger that AppleScript whenever a specific MIDI message from a specific MIDI device comes in, and only when Logic Pro is in focus (i.e. is the frontmost application).

Also attached is a version that triggers the AppleScript with a keystroke.

Let me know if you have any questions but the comments in the scripts should help you understand what's going on.

J.

TogglePluginCompare.zip

  • Like 1
Link to comment
Share on other sites

On 3/14/2023 at 3:18 AM, Jordi Torres said:

Привет, Владистон.

Ты имеешь в виду, что не можешь скачать этот zip? Ошибки HTTP в 500-х являются ошибками сервера и не имеют ничего общего с содержимым моих скриптов.

Дж.

today I got lucky or just good weather outside - I managed to download the Hummerspoon app up to 0.9.91 and your scripts:

as I understand it, the hotkey assignment is defined as F1 by default:

-- Bind the key that will run the AppleScript to toggle the plug-in Compare button
local keyTrigger = hotKey.bind(nil, "f1", function()
  runScript.applescript(clickCompareButton)
end)

defined variables to run the script:

-- Create Window Filter for Logic Pro window
local logicWindowFilter = windowFilter.new("Logic Pro")

logicWindowFilter:subscribe(windowFilter.windowFocused, function()

and the conditions for starting the script are organized:

  -- Enable hotkey when Logic Pro is in focus
  keyTrigger:enable()
end):subscribe(windowFilter.windowUnfocused, function()
  -- Disable hotkey when Logic Pro is not focus
  keyTrigger:disable()
end)

any things more what i have to known?

Edited by vladistone
Link to comment
Share on other sites

more questions came up while studying the second script TogglePluginCompareWithMidi.lua :

-- Callback function for the Hammerspoon MIDI object created above (hs.midi.new)
-- Parameters: object, deviceName, commandType, description, metadata
-- Here we listen for incoming Control Change message that will trigger the AppleScript when received
local handleMidi = function(...)
  local commandType = select(3, ...)
  local metaData = select(5, ...)
  if commandType == 'controlChange' then
      if metaData.controllerNumber == 48 and metaData.controllerValue == 127 then
        runScript.applescript(clickCompareButton)
      end
  end
end

here it is already necessary to dive into the study of the lua syntax ... otherwise a simple copy / paste will not help out:

function(...)
select(3, ...)
select(5, ...)

the tail of the script is clear to me - because it checks the fulfillment of the conditions for starting the script when the expected MIDI message is received; The only nuance is that you have described MIDI CC # 48, I don’t understand it in decimal or hex format?

Link to comment
Share on other sites

On 13.03.2023 at 00:32, des99 said:

Again, Keyboard Maestro, while not cheap, lets you do *all* of this (listen to incoming MIDI, run scripts, click on GUI elements, and much more), without requiring you to learn any coding at all, and without requiring multiple interacting pieces of software - which is why I recommend it for this kind of thing. It may cost some money, but it saves an incredible amount of time and effort into researching, piecing together, and learning a bunch of different technologies for these kinds of problems.

(KM has saved me so much time, effort (and hair!) over the years, it's been *well* worth the price! But it's probably overkill if you only ever want it for this one time, of course.)

Anyway, it seems you're happy enough going the more complicated route 🙂 , so hopefully you can achieve what you want in the way that makes most sense for you. 👍

I tried the KM app and was pleasantly surprised by how easy it is to program an applescript event in it.
I have only one question left:
- how to add a description of the feedback goal in the MCU Scribble Strip? I mean control by LPX smart control inspector or other applications? for the same "Compare" V-pot 8 button that will be assigned to the MIDI controller.

The simplest and most direct way I found is to overwrite the CA Label parameter (see printscreen), but it is rough and doesn't match the general settings of the smart control. want a smarter way

CA.png

CA compare.png

Edited by vladistone
Link to comment
Share on other sites

another important note:

when you re-execute the applescript (which returns the state of the "compare" button to its original state - "blue color"), the state of the UNDO button does not restore - although the DAW remembers these manipulations, (LPX feeadback is absent in 2nd time, for restore the "undo" button), that is, the UNDO button is lite off. 🤔

Edited by vladistone
Link to comment
Share on other sites

Hi @Jordi Torres

I`ll be waiting your discribtion

in any case, whoever reads this post will have a choice between using a paid "crutch" in the form of KM or improving their skills&knolages in coding by HS
and I also have an interest in upgrading my skills - to the level of "advanced user" and not a banal copy/paister 🙂

Edited by vladistone
Link to comment
Share on other sites

I'm wondering - how can I implement feedback between MIDI controller and HS or KM 🤔

i meaning about it:

5 hours ago, vladistone said:

...
I have only one question left:
- how to add a description of the feedback goal in the MCU Scribble Strip? I mean control by LPX smart control inspector or other applications? for the same "Compare" V-pot 8 button that will be assigned to the MIDI controller.

The simplest and most direct way I found is to overwrite the CA Label parameter (see printscreen), but it is rough and doesn't match the general settings of the smart control. want a smarter way

CA compare.png

 

Link to comment
Share on other sites

6 minutes ago, vladistone said:

and I also have an interest in upgrading my skills - to the level of "advanced user" and not a banal copy/paister

Hmm, OK...

I can assure you, KM macros can get incredibly deep, including advanced programming, and you often have to be quite creative to do skillful, reliable macro creation. I consider myself an advanced user, and a programmer, and I use KM when you *can't* easily achieve things by coding alone - ie, where you have the drive the user interface of other apps to get your task done. In the case, KM is simply the best, easiest, fastest and most powerful integrated tool to achieve that.

I would *always* prefer to do things with proper programming if possible, as it's generally more flexible, reliable and faster than using macro tools. I use KM for the times where that approach isn't feasible, and often for complex tasks, I'm using a variety of approaches (I'm doing exactly that today, in fact, and I need both toolsets to achieve my outcome.)

But sure, if you want to use this project as an opportunity to improve your skills, that's great. I'm a big believer in learning new skills and self-education. I've spent my life doing this. 👍

Link to comment
Share on other sites

Hi @vladistone,

I'll go over some of the stuff you asked about from the scripts I shared:


-- Bind the key that will run the AppleScript to toggle the plug-in Compare button
local keyTrigger = hotKey.bind(nil, "f1", function()
  runScript.applescript(clickCompareButton)
end)

Should be more or less clear from the comment, but hotkey.bind is taking three arguments here: key modifiers (set to "nil" here as I'm not using any), the key F1, and a callback function which ends up calling the the bit of AppleScript that's present elsewhere in the script when F1 is pressed.

BTW, there are other modules in the HS API that deal with keystrokes (and other input events like mouse, trackpad, etc.) in different ways.

-- Create Window Filter for Logic Pro window
local logicWindowFilter = windowFilter.new("Logic Pro")

logicWindowFilter:subscribe(windowFilter.windowFocused, function()
  -- Enable hotkey when Logic Pro is in focus
  keyTrigger:enable()
end):subscribe(windowFilter.windowUnfocused, function()
  -- Disable hotkey when Logic Pro is not focus
  keyTrigger:disable()
end)

the hs.window.filter module is quite useful as it allows you to do stuff based on which application's window is in focus. So here I'm selectively enable and disabling all the stuff that's being triggered by the F1 key based on whether Logic's window is in focus or not.

Now for some MIDI stuff:

-- Callback function for the Hammerspoon MIDI object created above (hs.midi.new)
-- Parameters: object, deviceName, commandType, description, metadata
-- Here we listen for incoming Control Change message that will trigger the AppleScript when received
local handleMidi = function(...)
  local commandType = select(3, ...)
  local metaData = select(5, ...)
  if commandType == 'controlChange' then
      if metaData.controllerNumber == 48 and metaData.controllerValue == 127 then
        runScript.applescript(clickCompareButton)
      end
  end
end

This is a function that is passed to the hs.midi object's "callback" method. With this you basically listen for incoming MIDI events from a specific device and can do stuff (like running bit of AppleScript to toggle the compare button) based on those events.

So here the AppleScript is only run in response to incoming CC48 events that have a value of 127. So 48 there is decimal, not hexadecimal.

That function expects 5 arguments to be passed as I mention in the comment (object, deviceName, commandType, description, metadata), but since I do not need to use all of them, I used the three dots (which denote a variable number of arguments) in combination with those select functions to "cherry-pick" the ones I wanted to use (commandType and metadata, arguments number 3 and 5 in that list). This is a feature in Lua which other languages implement as well in more or less similar fashion. More info here: 5.2 – Variable Number of Arguments

 

Hope that helped.

J.

 

  • Like 2
Link to comment
Share on other sites

9 hours ago, des99 said:

Hmm, OK...

I can assure you, KM macros can get incredibly deep, including advanced programming, and you often have to be quite creative to do skillful, reliable macro creation. I consider myself an advanced user, and a programmer, and I use KM when you *can't* easily achieve things by coding alone - ie, where you have the drive the user interface of other apps to get your task done. In the case, KM is simply the best, easiest, fastest and most powerful integrated tool to achieve that.

I would *always* prefer to do things with proper programming if possible, as it's generally more flexible, reliable and faster than using macro tools. I use KM for the times where that approach isn't feasible, and often for complex tasks, I'm using a variety of approaches (I'm doing exactly that today, in fact, and I need both toolsets to achieve my outcome.)

But sure, if you want to use this project as an opportunity to improve your skills, that's great. I'm a big believer in learning new skills and self-education. I've spent my life doing this. 👍

your answer is not constructive in essence ... it only distracts from the problems posed earlier, and even more so you did not answer the previous request:

15 hours ago, vladistone said:

I have only one question left:
- how to add a description of the feedback goal in the MCU Scribble Strip? I mean control by LPX smart control inspector or other applications? for the same "Compare" V-pot 8 button that will be assigned to the MIDI controller.

The simplest and most direct way I found is to overwrite the CA Label parameter (see printscreen), but it is rough and doesn't match the general settings of the smart control. want a smarter way

CA compare.png

 

Link to comment
Share on other sites

2 hours ago, Jordi Torres said:

Hi @vladistone,

I'll go over some of the stuff you asked about from the scripts I shared:


-- Bind the key that will run the AppleScript to toggle the plug-in Compare button
local keyTrigger = hotKey.bind(nil, "f1", function()
  runScript.applescript(clickCompareButton)
end)

Should be more or less clear from the comment, but hotkey.bind is taking three arguments here: key modifiers (set to "nil" here as I'm not using any), the key F1, and a callback function which ends up calling the the bit of AppleScript that's present elsewhere in the script when F1 is pressed.

BTW, there are other modules in the HS API that deal with keystrokes (and other input events like mouse, trackpad, etc.) in different ways.

Hi @Jordi Torres

 Perfect!

Only 2 question:

  1. how the behavior of the keys and modification keys too is described (instant action? toggle? track the behavior of the modifier or "Follow key state first" soft-switch? responce for fire-mode?) in general, perhabce all is this  determined by the syntax of the functions?...
  2. how would you implement feedback to match the controller's scrabble strip?
9 hours ago, vladistone said:

I'm wondering - how can I implement feedback between MIDI controller and HS or KM 🤔

i meaning about it:

important for me - recieve a "fishing rod", examples of code injection in LPX!

And I will try to learn how to catch and "fry fish" as needed and the tasks set for myself.

 

 

Edited by vladistone
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...