Selecting audio devices by name

50 views
Skip to first unread message

Tim Roberts

unread,
May 4, 2016, 12:46:12 AM5/4/16
to Extempore
Hi All,
I'm using a script to launch extempore to save a heap of typing.  This is great, because I can easily launch extempore with the correct audio devices.  However, this is not so great because when another mac, that has airplay enabled, is nearby, airplay becomes device 0, shifting all other devices up by 1.  As a result, if I launch extempore the devices are no longer correct.
Is there a way to choose the device based on the name, rather than the device number?

I could turn wifi off, and for demonstrating I will do that, but it's a pain to enable and disable during development.  If the airplay is enumerated while extempore is running, I think everything continues as it should, but it may not.  Something for me to test.

Here are the device ID's and then the script that I run to launch extempore.

-----Available Audio Devices-----------------------------

audio device[0]:AirPlay api[0]:Core Audio inchan[0] outchan[2]

audio device[1]:Built-in Microph api[0]:Core Audio inchan[2] outchan[0]

audio device[2]:Built-in Input api[0]:Core Audio inchan[2] outchan[0]

audio device[3]:Built-in Output api[0]:Core Audio inchan[0] outchan[2]

----------------------------------------------------------


#!/bin/bash

#Script for loading extempore with default inputs and outputs

echo "Starting Extempore process"

echo "with Stereo in and Stereo out"

cd /Users/Tim/extempore/cmake-build

./extempore --device=2 --channels=2 --indevice=1 --inchannels=2 --frames=128


echo "Done"

Tim Roberts

unread,
May 4, 2016, 3:50:34 AM5/4/16
to Extempore
For now, I've changed my script to the code below.  It lists the audio devices available and then allows the user to choose the one that they would prefer.  Ideally I would add error checking to the frame size, but this is good enough for me at the moment.
I have a bat file that I run on my PC that I might also update to do a similar thing.

#!/bin/bash
#Script for loading extempore with default inputs and outputs
echo "Listing audio devices available to extempore"
cd ~/extempore/cmake-build
./extempore --print-devices
echo "Which output device would you like to use?"
read out_device
echo "How many channels does it have?"
read out_channels
echo "Which input device would you like to use?"
read input_device
echo "How many channels does it have?"
read input_channels
echo "How large would you like the frame buffer to be? (Must be a power of 2)"
read frame_buffer_size
echo "Launching extempore"
./extempore --device=$out_device --channels=$out_channels --indevice=$input_device --inchannels=$input_channels --frames=$frame_buffer_size

Ben Swift

unread,
May 4, 2016, 4:04:19 AM5/4/16
to extemp...@googlegroups.com
Hi Tim

I know the pain of having an errant airplay device throw the setup stuff
out of whack - that almost ruined a gig for me once.

The nicer solution is to integrate the "select device by name" stuff
into src/AudioDevice.cpp so that you could do it with the --device flag,
but I'm about to head off to china for a while and so probably won't get
around to it for a bit.

Having said that, it's a nice little community-sized project, if
anyone's keen.

Cheers,
Ben

Jim Kuhn

unread,
May 4, 2016, 5:07:01 PM5/4/16
to Extempore, b...@benswift.me
Tim,

I just committed and pushed a change to support this (lightly tested).

New command line options are "--device-name" and "--indevice-name".  They override their ID counterparts if both are specified.  Note that the full name must match.  For example, on my system one of the devices listed is:

audio device[1]:HDA Intel PCH: ALC662 rev3 Alt Analog (hw:0,2) api[0]:ALSA inchan[2] outchan[0]

I must specify the whole name:

$ ./extempore --device_name "HDA Intel PCH: ALC662 rev3 Alt Analog (hw:0,2)"

or an (appropriate) error will be generated.  Something like this (when I gave a shortened name):

*** Can't find named device: HDA Intel PCH: ALC662 rev3 Analo

Jim 
Reply all
Reply to author
Forward
0 new messages