Skip to contentSkip to conversation

Surround sound and volume control question

DISCUSSION Daniel Jacobowitz 4 participants 12 messages Oct 8, 2006 – Oct 10, 2006

lore
Share & tools
lore
#0 lore raw

How is volume control supposed to work for surround sound codecs? Is there typically a register which affects every channel, or do you have to adjust them separately? I've been staring at the datasheets and prodding the registers for mine (ICE1724, on a Shuttle SN25P). There's three pieces:
the vt1720, the vt1617a, and a wm8728. The vt1617a has ac97 volume control registers, but the "master" volume doesn't affect the center/lfe or rear surround channels. I am guessing that the wm8728 is just for the last two channels (I've got jacks for 7.1 but the vt1617a only does 5.1).

I cobbled together patches that add a stereo mute switch to the softvol plugin, and set that in front of the card. Then I can actually change volume or mute the whole set. But for various reasons this is unsatisfactory, e.g. because it's not called "Master Playback", and because it doesn't show up as the first mixer element - every application needs a bit of configuration to find the right volume control. And one of the applications I wanted to configure, gnome-settings-daemon, is basically unconfigurable. It just grabs whatever gstreamer sees at the front of the list.

(The mute patches available on request, btw, one alsa-lib patch and one kernel driver bugfix for user-created boolean controls.)

Before I go any further with this I want to know how it works elsewhere. I would think that having a single mixer control that affected all the surround speakers would be a pretty standard thing to want! Do other chips have a single register for it? Or does this one, and I'm just not seeing it?

If I have no other way to get this to work than with the softvol plugin, I think this is the way to go:
- Rename the "Master" volume control/switch to "Front".
- In userspace, have softvol create a control/switch named "Master".

Potential problems:
- With a library older than kernel driver I think things would start picking up the Headphone channel as the master volume control if I made this change, yuck.
- The user-created controls don't exist right away, so saving and restoring volume might not work.

All comments very welcome - I'm out of my depth here. There's a bit of related discussion in bug 1407.

Signature · 8 lines
Daniel Jacobowitz
CodeSourcery

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#1 lore raw

At Sun, 8 Oct 2006 18:27:26 -0400,

Quoted 9 lines · Daniel Jacobowitz

How is volume control supposed to work for surround sound codecs? Is there typically a register which affects every channel, or do you have to adjust them separately? I've been staring at the datasheets and prodding the registers for mine (ICE1724, on a Shuttle SN25P). There's three pieces:
the vt1720, the vt1617a, and a wm8728. The vt1617a has ac97 volume control registers, but the "master" volume doesn't affect the center/lfe or rear surround channels. I am guessing that the wm8728 is just for the last two channels (I've got jacks for 7.1 but the vt1617a only does 5.1).

That's the standard behavior of AC97 codec. The "master" doesn't influence on surrounds. Some ac97 codec chips have an extended mode that behaves differently, though.

Quoted 19 lines

I cobbled together patches that add a stereo mute switch to the softvol plugin, and set that in front of the card. Then I can actually change volume or mute the whole set. But for various reasons this is unsatisfactory, e.g. because it's not called "Master Playback", and because it doesn't show up as the first mixer element - every application needs a bit of configuration to find the right volume control. And one of the applications I wanted to configure, gnome-settings-daemon, is basically unconfigurable. It just grabs whatever gstreamer sees at the front of the list.

(The mute patches available on request, btw, one alsa-lib patch and one kernel driver bugfix for user-created boolean controls.)

Before I go any further with this I want to know how it works elsewhere. I would think that having a single mixer control that affected all the surround speakers would be a pretty standard thing to want! Do other chips have a single register for it? Or does this one, and I'm just not seeing it?

Quoted 4 lines

If I have no other way to get this to work than with the softvol plugin, I think this is the way to go:
- Rename the "Master" volume control/switch to "Front".
- In userspace, have softvol create a control/switch named "Master".

Maybe it's an easiest way...

Quoted 6 lines

Potential problems:
- With a library older than kernel driver I think things would start picking up the Headphone channel as the master volume control if I made this change, yuck.
- The user-created controls don't exist right away, so saving and restoring volume might not work.

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw
Quoted 12 lines · Takashi Iwai

At Sun, 8 Oct 2006 18:27:26 -0400,

Quoted 9 lines · Daniel Jacobowitz

How is volume control supposed to work for surround sound codecs? Is there typically a register which affects every channel, or do you have to adjust them separately? I've been staring at the datasheets and prodding the registers for mine (ICE1724, on a Shuttle SN25P). There's three pieces:
the vt1720, the vt1617a, and a wm8728. The vt1617a has ac97 volume control registers, but the "master" volume doesn't affect the center/lfe or rear surround channels. I am guessing that the wm8728 is just for the last two channels (I've got jacks for 7.1 but the vt1617a only does 5.1).

Quoted 3 lines

That's the standard behavior of AC97 codec. The "master" doesn't influence on surrounds. Some ac97 codec chips have an extended mode that behaves differently, though.

I assume this one doesn't. But could you tell me one supported card which does, so that I can compare? Thanks.

Quoted 2 lines

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

I see, I just tried it and alsactl will create a user control just fine. That's great.

I will give the softvol solution a try, and post the patches if it works.

Signature · 8 lines
Daniel Jacobowitz
CodeSourcery

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#3 lore raw

At Mon, 9 Oct 2006 09:45:39 -0400,

Quoted 14 lines · Daniel Jacobowitz
Quoted 12 lines · Takashi Iwai

At Sun, 8 Oct 2006 18:27:26 -0400,

Quoted 9 lines · Daniel Jacobowitz

How is volume control supposed to work for surround sound codecs? Is there typically a register which affects every channel, or do you have to adjust them separately? I've been staring at the datasheets and prodding the registers for mine (ICE1724, on a Shuttle SN25P). There's three pieces:
the vt1720, the vt1617a, and a wm8728. The vt1617a has ac97 volume control registers, but the "master" volume doesn't affect the center/lfe or rear surround channels. I am guessing that the wm8728 is just for the last two channels (I've got jacks for 7.1 but the vt1617a only does 5.1).

Quoted 6 lines
Quoted 3 lines

That's the standard behavior of AC97 codec. The "master" doesn't influence on surrounds. Some ac97 codec chips have an extended mode that behaves differently, though.

I assume this one doesn't. But could you tell me one supported card which does, so that I can compare? Thanks.

AFAIK, AD198x codecs have an non-compatible mode. It's controlled via register 0x76 bit 14.

Quoted 8 lines
Quoted 2 lines

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

I see, I just tried it and alsactl will create a user control just fine. That's great.

I will give the softvol solution a try, and post the patches if it works.

That's nice. Thanks.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#4 lore raw
In reply to Daniel Jacobowitz
Quoted 9 lines · Daniel Jacobowitz
Quoted 2 lines

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

I see, I just tried it and alsactl will create a user control just fine. That's great.

I will give the softvol solution a try, and post the patches if it works.

Isn't it inefficient to force all audio to go through a software volume control just to have a master volume? Wouldn't it be better to make a ganged control in the driver (until the alsa-lib abstract mixer layer is ready)?

Lee

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#5 lore raw
Quoted 7 lines · Lee Revell
Quoted 6 lines · Daniel Jacobowitz
Quoted 2 lines

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

I see, I just tried it and alsactl will create a user control just fine. That's great.

Quoted 8 lines
Quoted 3 lines

I will give the softvol solution a try, and post the patches if it works.

Isn't it inefficient to force all audio to go through a software volume control just to have a master volume? Wouldn't it be better to make a ganged control in the driver (until the alsa-lib abstract mixer layer is ready)?

I did consider doing it this way over the weekend. However, being able to adjust the relative volumes of the different channels still seems useful to me. If you have a single unified control, then you mess up trying to move the others.

What do you think? Should I just slave them all together and remove the other volume controls? It's probably easier; it just seems somehow lacking.

Signature · 8 lines
Daniel Jacobowitz
CodeSourcery

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#6 lore raw
Quoted 9 lines · Daniel Jacobowitz

I did consider doing it this way over the weekend. However, being able to adjust the relative volumes of the different channels still seems useful to me. If you have a single unified control, then you mess up trying to move the others.

What do you think? Should I just slave them all together and remove the other volume controls? It's probably easier; it just seems somehow lacking.

How do other OSes do it? Do they also force everything through a software volume control?

Is a ganged master control fundamentally incompatible with individual channel volumes? If so, doesn't it mean that this problem can never be solved by an abstract mixer layer?

Lee

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#7 lore raw

At Mon, 09 Oct 2006 10:42:56 -0400,

Quoted 7 lines · Lee Revell
Quoted 5 lines · Daniel Jacobowitz

I did consider doing it this way over the weekend. However, being able to adjust the relative volumes of the different channels still seems useful to me. If you have a single unified control, then you mess up trying to move the others.

Quoted 7 lines
Quoted 4 lines

What do you think? Should I just slave them all together and remove the other volume controls? It's probably easier; it just seems somehow lacking.

How do other OSes do it? Do they also force everything through a software volume control?

I've not seen any codes of Windows driver, but most likely they do software volume and effects control.

Quoted 3 lines

Is a ganged master control fundamentally incompatible with individual channel volumes? If so, doesn't it mean that this problem can never be solved by an abstract mixer layer?

It's possible to create a virtual volume element that represents the base attenuation level. Suppose "Master" to be a virtual volume (a mono), then the real volume values for front, rear and CLFE become "front + master", "rear + master" and "CLFE + master". The values have to be clipped to max 31 (or 63).

The problem is that the mixer values are no longer corresponding to the register values as 1:1. Thus the current code for get/put callbacks can't be used as it is. The values have to be cached and handled internally independent from the register values...

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#10 lore raw
In reply to Lee Revell
Quoted 6 lines · Lee Revell
Quoted 5 lines · Daniel Jacobowitz

I did consider doing it this way over the weekend. However, being able to adjust the relative volumes of the different channels still seems useful to me. If you have a single unified control, then you mess up trying to move the others.

Quoted 7 lines
Quoted 4 lines

What do you think? Should I just slave them all together and remove the other volume controls? It's probably easier; it just seems somehow lacking.

How do other OSes do it? Do they also force everything through a software volume control?

Unfortunately, I could find a program to dump the ice1724's IO space in Windows, but I couldn't find anything to dump the vt1617a AC97 registers (which require writes to select the registers IIRC). If you've got a recommendation, I can boot this machine into Windows and see what happens to the vt1617a's registers when the Windows driver adjusts the volume.

Quoted 3 lines

Is a ganged master control fundamentally incompatible with individual channel volumes? If so, doesn't it mean that this problem can never be solved by an abstract mixer layer?

I don't know. I guess you could preserve individual channel volumes by saving them separately (outside the registers), and using a volume of "master control plus channel control". But I don't know how the resulting quality would be or how tricky it would be to implement. Right now we never cache the volumes corresponding to hardware registers.

Signature · 8 lines
Daniel Jacobowitz
CodeSourcery

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#8 lore raw
In reply to Takashi Iwai
Quoted 10 lines · Takashi Iwai
Quoted 3 lines

Is a ganged master control fundamentally incompatible with individual channel volumes? If so, doesn't it mean that this problem can never be solved by an abstract mixer layer?

It's possible to create a virtual volume element that represents the base attenuation level. Suppose "Master" to be a virtual volume (a mono), then the real volume values for front, rear and CLFE become "front + master", "rear + master" and "CLFE + master". The values have to be clipped to max 31 (or 63).

Quoted 4 lines

The problem is that the mixer values are no longer corresponding to the register values as 1:1. Thus the current code for get/put callbacks can't be used as it is. The values have to be cached and handled internally independent from the register values...

Do you think this is a better choice than using softvol? If so, I will work on the implementation later this week.

Signature · 8 lines
Daniel Jacobowitz
CodeSourcery

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#9 lore raw

At Mon, 9 Oct 2006 13:04:51 -0400,

Quoted 12 lines · Daniel Jacobowitz
Quoted 10 lines · Takashi Iwai
Quoted 3 lines

Is a ganged master control fundamentally incompatible with individual channel volumes? If so, doesn't it mean that this problem can never be solved by an abstract mixer layer?

It's possible to create a virtual volume element that represents the base attenuation level. Suppose "Master" to be a virtual volume (a mono), then the real volume values for front, rear and CLFE become "front + master", "rear + master" and "CLFE + master". The values have to be clipped to max 31 (or 63).

Quoted 7 lines
Quoted 4 lines

The problem is that the mixer values are no longer corresponding to the register values as 1:1. Thus the current code for get/put callbacks can't be used as it is. The values have to be cached and handled internally independent from the register values...

Do you think this is a better choice than using softvol? If so, I will work on the implementation later this week.

Depends. It's definitely ligher for hardware at least, but would involve more changes in the driver side. OTOH, softvol can provide finer volume controls with higher resolution.

I thought of implementation of virtual mixer element in alsa-lib, but it'd be also a bit messy. The implementation in the driver side could be even easier.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#11 lore raw
In reply to Daniel Jacobowitz

Hi,

Just wanted to give you some input from a user of the more advanced features of alsa volume controls. I am running an acoustic lab at the University of Western Australia. I have previously helped out in alsa to reverse engineer a sound card and fix some minor bugs. We use alsa/jack to do sound recordings and to implement realtime audio processing algorithms where the absolute relationship between the volume level and the voltage level at the sound card output must be known. Currently I have had to reverse engineer the A/D - D/A and driver to work out this relationship and write card specific functions to set the volume levels for the soundcard output.

If you are making changes to the volume controls, the most valuable feature to the kind of work I am doing would be the ability to set the volume level in volts individually for each channel. Whatever you do please don't hide the actual analog gain settings behind software gain settings, it would make my work very difficult.

Cheers,
//Anders

Quoted 17 lines · Lee Revell
Quoted 7 lines · Daniel Jacobowitz
Quoted 6 lines
Quoted 2 lines

alsactl save & restore should work for softvol.
The softvol mixer element doesn't exist only at the very fresh state.

I see, I just tried it and alsactl will create a user control just fine. That's great.

Quoted 8 lines
Quoted 3 lines

I will give the softvol solution a try, and post the patches if it works.

Isn't it inefficient to force all audio to go through a software volume control just to have a master volume? Wouldn't it be better to make a ganged control in the driver (until the alsa-lib abstract mixer layer is ready)?

Quoted 8 lines

I did consider doing it this way over the weekend. However, being able to adjust the relative volumes of the different channels still seems useful to me. If you have a single unified control, then you mess up trying to move the others.

What do you think? Should I just slave them all together and remove the other volume controls? It's probably easier; it just seems somehow lacking.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV