Audacity saves the last used sound card settings in the audacity.cfg file.
Here's an extract from my current set-up:
Code: Select all
[AudioIO]
RecordingDevice=ALSA: default
Host=ALSA
PlaybackDevice=ALSA: default
RecordChannels=2
This is using ALSA through PulseAudio.
PulseAudio is controlling the "default" devices, so while I'm using PulseAudio I can leave the Audacity settings just like this and only need to make the appropriate changes in PulseAudio mixer.
I have 2 sound cards attached to this computer - the internal sound card and a USB sound card.
If I want to change the playback or the recording device that Audacity uses, I
could explicitly set the device in Audacity Preferences (Edit menu > Preferences > Devices", but if I do that it could cause problems the next time I launch Audacity. For example, if I set Audacity Preferences to use "hw:1.0" (the USB device) for playback, but then the next time I launched Audacity I did not have the USB device connected - Audacity would be unable to find the playback device (because it's not there).
Instead of doing that, I leave Audacity set to record from "ALSA: default". Here's the method that I use:
To change the playback device:
1) Launch Audacity.
2) Import or generate some audio data.
3) Play > Pause.
4) Open "PulseAudio Volume Control" and in the Playback section "Move Stream" to the required device.
5) STOP Audacity playback (important)
6) Press PLAY on Audacity - it is now using the new device.
To change the recording device:
1) Launch Audacity.
2) Click on the Record Monitor to start monitoring.
3) Open "PulseAudio Volume Control" and in the Record section "Move Stream" to the required device.
4) Click on the Record Monitor to stop monitoring (important).
5) Start recording with the new device.
I hope this works as well on your computer as it does here - simple, no fuss, reliable.
Now the sticking point - switching to/from Jack audio.
This is a lot more problematic. I've been playing with Jack-enabled PulseAudio on Ubuntu 10.04 (alpha/beta).
In theory this will make switching to Jack just as easy as the above method, but unfortunately I've not managed to get it to work yet

To be fair - this is still quite experimental, and I'm trying to run it in a virtual machine using a real-time kernel that is not officially supported by VirtualBox.
Hopefully when Ubuntu 10.04 is officially released and I'm running on real, not virtual, hardware, I'll have more success, but for now, like you, I'm stuck with clumsy workarounds.
As far as I can tell, the problem is that Jack is not (currently) supported by PulseAudio in Ubuntu (9.04/9.10), and both sound servers want exclusive access to the audio device. For Jack to work, it must suspend PulseAudio. So, you start Jack, then open Audacity - it's looking to connect to ALSA through PulseAudio, but it can't because it's been suspended. This gives you two options - either you go into Audacity Preferences and specify explicitly which audio device you want to use (for example "hw:1,0"), or you set Audacity to use Jack. Either way you need to be careful - if Audacity tries to use a device that is not available it will probably lock up or crash.
My current method for switching to Jack:
1) Open Audacity and check the default sample rate, then close Audacity.
2) Start Jack with Jack Control, ensuring that the same sample rate is set.
3) Open Audacity and set the host to Jack.
4) Press the Record button - Jack should automatically connect Audacity's Pulse Audio inputs to the system inputs (clicking on the monitor will crash Audacity because connection to a recording device has not yet been established).
5) Open "Connect" in Jack Control to check that Audacity is connected as expected.
My current method for switching back from Jack to PulseAudio:
This is all with Jack NOT running.
1) Open Audacity
2) In Audacity Preferences select Host:ALSA, Devices: default
3) Restart Audacity
The thing that gives me hope is that this all works very much better than it did a year ago. Jack, PulseAudio, Portaudio and Audacity are all maturing technologies. It looks like it will be PulseAudio that finally pulls all the threads together - it would just be nice if they could get there a bit quicker
