Message to Max from external USB device

bkshepard's icon

I have an Elgato Stream Deck that I'd like to be able to program a button to turn audio on and off. I can send key commands and individual letters that create objects (n, m, c, t, etc.). However, since there isn't a key command for turning audio on/off, I'm hoping to send a message to Max (; dsp start) and (; dsp stop) from the Stream Deck. However, everything I've tried thus far, Max ignores. Is there a way to send a message to Max from an external USB device? Thanks.

prko's icon

Hello,

Have you resolved your problem?

I think you could simply use the [key] or [keyup] object.
However, I do not know if the buttons on the device toggle buttons are or not.

I am considering buying four pieces of "Elgato Stream Deck Pedal" to use on one computer. Would it be possible?

I really appreciate any help you can provide.

Source Audio's icon

https://cycling74.com/forums/shortcut-for-audio-onoff

short facts - max has to be foreground app to receive keystrokes directly,
only way to do so in background is either using hi object which works only on Mac,
beause windows does not allow mouse and keyboard as HID devices.
or some system key listener that resends data to max using some other kind of protocol.



bkshepard's icon

My question wasn’t about foreground/background. It was about whether or not I can toggle audio on and off. Max would be in the foreground. There are a bunch of key commands and “messages to Max” for all sorts of things, but there doesn’t seem to be any for turning audio on/off. As for the Stream Deck buttons, they can be either single buttons (do some action when pressed) or a toggle. You configure that in the Stream Deck application.

Source Audio's icon

You can assign any message to dsp on or dsp off and use it as toggle or not

you just need to make that toggle to respond to whatever messages you send.
here few examples


bkshepard's icon

Thanks, SA. What I was hoping to find was a way to just turn Max audio on/off without having to build anything inside a patch—sort of a universal key command kind of thing. There doesn’t seem to be a way to do that at the app level like you can with some other key commands.

Source Audio's icon

is there any reason for that general audio switch on app level?
You can't use max without a patch - it does nothing by itself,
you need a patch to use dsp at all.
If the problem is that you load and unload different patches
and want to avoid inserting dsp switch in each of them,
then load top level patcher with dsp control, and tick can't close top level patcher in standalone inspector. such patch does not need to be visible.

And in addition, dsp status can be patch independent, one can
turn dsp processing individually for different patches...


at the end - what would be app level function ?




bkshepard's icon

As a long time Max user, I’m well aware that without a patcher, Max does nothing. I would just like a quick way to turn audio processing on and off via my Stream Deck. Apparently, that’s not possible. Thanks for the thoughts, though.

Roman Thilenius's icon


well, if it would be built-in like he wishes, it would work with any patches or collectives, without the need to implement a custom function.

but otoh... i am not aware of any application which would support audio on/off by keyboard commands, and maybe there is a reason for that.

Scott Findley's icon

Not possible? And you call yourselves max users. Shame! Of course where theres a will there a way. How about using node for max to issue and respond to http mssgs (the native communication method of streamdeck javascript sdk) and a combination of OSC messages? Ive already got mine integrates with simple button push commands performing actions in max without it in focus. gotta thihnk outside the box peoples thats what max is all about~

Scott Findley's icon
if someone with just a little more .js chops than I could figure out the exact syntax one could, say get max to change titles of buttons, perform any function within the maxforlive sdk (like playing clips, changing pages etc.) Im just sayin.
bkshepard's icon

So with nothing open other than an empty Max patcher, you are able to turn the audio on and off with a key command, just like the way you can lock and unlock the patcher or create a new object with a simple key command? I’d love to see your solution?

Source Audio's icon

he is telling nonesense, don't bother
open max, create empty patch, and try to even manually
activate dsp button.
remember, dsp status is also a patch
containing adstatus objects and all the rest.
max has no menu to turn audio processing on or off,
which would be open to scripting.

bkshepard's icon

Yeah, I know… 😉

LSka's icon

I did it like this:

1. Created an abstraction called "audioswitch", here it is:

Max Patch
Copy patch and select New From Clipboard in Max.

The abstraction is a simple patch that checks the dsp status and switches it on or off accordingly, then destroys itself sending the "dispose" message to [thispatcher]
(warning, there's a loadbang, so to see the patch, you may need to disable it)

2. Edited the "max-keycommands.txt" found in /Applications/Max.app/Contents/Resources/C74/init and added the following lines: max definecommand B patcher insertobj audioswitch;
max definecommandinstructions patcher B "newobj audioswitch";

Now, every time I press shift-b on an empty patcher I switch the dsp on or off.

Another method could involve using the Streamdeck app to somehow call a script that tells Max to open the "audioswitch.maxpat" patcher. I don't own a Streamdeck, so I don't know how it works.

Source Audio's icon

I can turn dsp off even if max is not running at all,
if that can be added to list of very handy features

LSka's icon

Thank you, Source Audio, for all your kindness.