New and struggling: How can I set the Audio Output Device from a patch?
Hi,
I'm new to Max and struggle with the problem that I want to change the Audio Output device on a Mac. From the Audio status I can see that "Build-in Output" is selected.
Now I want to change this to my external audio interface from a patch.
How do I do this?
Same for Input Device?
Thanks for a quick help.
Best, Alex
Use this to configure your dsp
Thanks JonnyB,
I'm actually looking for a way to set the Audio device without opening the dialog.
I want to make sure my Input and Output device is automatically set to "Fireface (blabla)".
Best, Alex
Actually you can just go into edit mode with your keyboard shortcuts while you're in the DSP dialog window and copy/paste bits from the patch. It's all created in Max patching :)
Otherwise just have a peek at the [adstatus] object help file.
adstatus did the job insofar as I can use the "option 0" and "option 1" argument and shoot them an integer message.
Unfortunately if additional interfaces appear (i.e. AirPlay) the integer numbers change. So I can not rely on the fact that shooting a 1 will always select the correct interface.
What I'm searching for is: How can I translate the device name into the correct integer for "option 0" and "option 1"?
Thanks, Alex
I looks like if you use 'route', you can always get he same number for your option no matter where it is in the list. In the example I used soundflower (2ch) and (64ch) which are numbers 2 and 3 in my list but I assigned them numbers 1 and 2.
Thanks a lot for trying to help.
That's also not exactly what I'm looking for.
To explain it with your example:
When I open your patcher for the first time, the drop down menu shows "Built-In Microphone".
I would want it to automatically switch it to e.g. "Soundflower (2ch)" without having to touch anything.
Therefore I'd need to know what number I have to shoot "adstatus option 0".
Now the problem with this number seems to be:
My list currently reads
0 Built-In Microphone
1 Soundflower (2ch)
2 Soundflower (64ch)
That means, if I shoot 1 to "adstatus option 0" then "Soundflower (2ch)" will be selected.
If now suddenly an AirPlay device appears in the network, the list reads:
0 AirPlay (
1 Built-In Microphone
2 Soundflower (2ch)
3 Soundflower (64ch)
You see what happens now, if I shoot 1 to "adstatus option 0"?
"Built-In Microphone" will be selected.
So I'm searching for a solution that basically fetches the correct number of "Soundflower (2c)" and shoots this to "adstatus option 0".
Thanks again,
Alex
So you want to report the 'new' numbers when the list changes.
like this?
here it is again in pres mode.
Thanks a lot, WIL.
Well almost. :-)
I don't want to touch the drop down in the first place.
What I'm looking for is an object that does the following:
I shoot the device name (e.g. "Built-In Microphone") to the inlet and as a result this device gets set.
So if you want: I need an adstatus that takes the string instead of the integer to set the audio device.
Tried creating this yesterday for several hours but had no luck.
I didn't have any luck trying to send messages to the ads or the umenu. It is possible to populate the umenu using "prepend" or "insert" messages but its too quirky. However, I don't see the point of sending a message instead of a number. Here is why; If you are going to take up screen space with individual messages for each menu item, it seems much more efficient to use my code where you scroll through the numbers and the menu item that is being set in the umenu (and ads) is automatically reported back. That way all you really is 1 number box and 1 message box on your screen. I just updated my current patches with this code... thanks!!! Previously I was opening the ads status window by sending an open message to the adc~ and changing my ads that way... this is much more efficient.
My use case is:
I need to be sure the correct audio device is selected once max and the patcher start up.
The problem is that the audio device does not always have the same number in the list. So sending "adstatus option 0 2" will not always be the correct device. This depends on which audio devices are currently connected.
It might be number 2 currently, but number 1 next time, or even number 3.
So sending a static integer to adstatus is not an option.
Therefore I need an object which scans all device names and creates a list looking like this:
0 Device1
1 Device2
2 Device3
3 Device4
Then I need the object inlet to accept the name "Device3" and return the integer via its outlet: "2"
This can be fed into adstatus then.
I would build the object myself but I did not have any luck in achieving it.
Does anyone have any hint?
It doesn't matter that the list is different each time. my code reports back the device AND the number no matter where it is in the list. look again. If AirDrop (your device) is 0 then it will report that back. If AirDrop is 7 it will repot that back. Don't know why you need all the extra stuff when you can scroll the number box, set your device instantly and see the result instantly.. done.
Beyond that, I got nuthin... sorry couldn't be more help.
Thanks again. I see that. But I need complete automation in my case.
I need it to start up with setting the device automatically without human intervention. So scrolling the box is not an option for my use case.
But appreciate you trying to be helpful.
If anyone is interested, after hours of work I finally did it.
This patch you can shoot the physical input device name you want to set in the form: "My-Input-Device"
And it sets the appropriate input device using adstatus.
This can be adapted for output device by changing 0 to 1 in both "adstatus option 0" objects.
I called it "Autoselect-Input-Device".
Example how to call it below.
If anyone comes up with an easier way to implement this: I'm grateful for any hints.
Thanks everyone
Alex
Example how to use it:
Realize this thread is pretty old, but I was just struggling with this myself, and found the simplest option was to bang the message "; dsp setdriver "YourDriverName" "YourSubDeviceName" ". You can find more info on this by searching "Controlling MSP with Messages" in the documentation.
-Brendan
Old thread but I can't get the ;dsp setdriver message to work. If I send the message ;dsp setdriver "Core Audio" "Scarlett 18i8 USB" I get "setdriver: can't find driver" error in the console. The same applies if I try to use any other subdriver such as "Soundflower (2ch)". Sending the message without the subdriver doesn't produce the error but it also doesn't change the audio device, just the driver.
I just came across this thread while searching for the same solution. Thanks, Alex Kiesl! Looks like your patch is going to do pretty much what I need!
Haha. Returning here 5 years later! Now I need to use this.
"adstatus option 0" only sets the input device.
How do I set the output device?
I think it's "option 1"
@Tom Law. Yeah. Where's my brain! Thanks.
Who needs a brain when you have the internet? ;)
Hey all,
I had some luck using a [t b b b b] to send out a series of bangs in order to populate a [umenu] from [adstatus option 0] and then send a message, prepended with [set], with the name of the device I wanted to use. No numbers, seems to work smoothly given limited testing. Happy for people to tell me when/how this will fail (as I'm about to build it into a standalone...)
First time posting Max code, hopefully this works:
thanks a lot for this thread!
changing the message in hawthorns patcher to "Built-in Output" (or what you desire) and modify the adstatus object to "option 1" and change the adc object to a dac object you can change the output device with this method.
nice thread.
I've turned the ideas into an abstraction (or two abstractions rather), including helpfile and refpage.
I chose to make it separate files for output and input because otherwise differentiating between what the user wants to set can end up in noman's land.
Hopefully useful to some. Certainly for myself.
safely ignore the jsui files that are missing, you can remove them from the abstractions. and while you're at it, place a 'qlim' before the leftmost list into [zl sect] for the output toggle to actually inform correctly.
Resuscitating this old thread again. Thanks for the great tips. I was able to find another solution to this using [coll] and the tips described in this thread. https://cycling74.com/forums/reverse-searching-a-'coll'-object-for-indices. (Roman's suggestion at the end is also good, but I copied Source Audio's code here)
This will set the input and output to the default Interface you define in the [loadmess]. It also has a button to reinitialize if you need to set it again after you've started the patch.
this all will fail, depending on audio driver availability.
it is in fact quite complex if one thinks that on windows
some devices can not be shared between more apps, and fail to load if allready used.
There are many ways to try to enforce wished drever and it's
options, but all that will fail if audio device is not ready to use.
and many other threads ....