Scripting sound preferences?

I'm finding myself changing sound preferences (specifically, output) frequently, and I'd like to write a shell script to do this for me. Does anyone know what command(s) to use?

Could you clarify what you mean?

Is it output volume or output device, output mixer or output port that you change?

There are potentially different ways of doing differnt things.

Output device.

So any chance of doing this? Or at least, any ideas on where I can start to look for answers?

We still don't know what you want since you didn't clarify your question at all, just repeated it.

What, exactly, do you want to do? What are you trying to automate -- what have you been doing already? In detail! "I click such and such in such a program" not "I change the output device".

You might be able to get what you want done by replacing your ~/.alsarc, maybe.

I'm not sure what's unclear; I answered reborg's question. Here's a screenshot of the GUI version of what I want to change: the output device from "Internal Audio Analog Stereo" to something else.