Volume control - can't set for secondary sound card

Asked by feeboo

The volume control for AWN doesn't work for me. I'm one thing off of being able to get rid of the top gnome bar in Ubuntu 8.10 but I need to be able to control the audio and this current applet won't work for me. I don't have the ability to turn off the onboard audio from the BIOS but that shouldn't be a solution that people say anyway cause it's dumb. So how can I get the volume applet to recognize that I'm not using the onboard sound and instead using a CL Audigy 2ZS PCMCIA card?

thank you for any assistance you can provide.

Question information

Language:
English Edit question
Status:
Solved
For:
Awn Extras Edit question
Assignee:
No assignee Edit question
Solved by:
onox
Solved:
Last query:
Last reply:
Revision history for this message
onox (onox) said :
#1

At the moment that's not possible, but if you answer following questions I can modify the applet:

open your terminal, type: "python"
type: import alsaaudio

then type: alsaaudio.cards()
Paste the output

(assuming it outputs a list with 2 elements -- something like ['a', 'b']), type: alsaaudio.mixer(1)
Does this output a list?

Then type: alsaaudio.mixer(2)
Does this output an alsaaudio.ALSAAudioError?

Then quit by pressing ctrl+d

Revision history for this message
feeboo (feeboo) said :
#2

Thank you very much for your reply. I do want to say that I LOVE AWN and although not as pretty as some of the alternatives (especially with what I've seen for Windows XP), I think it's the best out there in terms of usability and features. But enough ass-kissing.

This is everything I tried. I'm pretty new to Linux but I think I did as asked.

feeboo@workhorse:~$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import alsaaudio
>>> alsaaudio.cards()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'cards'
>>> alsaaudio.mixer(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'mixer'
>>> alsaaudio.cards()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'cards'
>>>

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

And I'll try to give as much info as possible regarding my sh*tty laptop. I have another outstanding issue on ubuntuforums that involves flash audio. I can listen to music, watch videos, listen to any type of sound. But any video that I watch online that is flash (youtube, etc), the audio doesn't work. I'm thinking the problems could be related.

Revision history for this message
onox (onox) said :
#3

Can you check in your package manager what version of python-alsaaudio you have?

Could you try alsaaudio.mixers(1) and alsaaudio.mixers(2)? I forgot the 's'.

About flash... do you have pulseaudio? See https://wiki.ubuntu.com/PulseAudio#Firefox/Flash%20and%20PulseAudio

Revision history for this message
feeboo (feeboo) said :
#4

0.2-1ubuntu1

as for adding a 's'

feeboo@workhorse:~$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> alsaaudio.mixers(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'alsaaudio' is not defined
>>> alsaaudio.mixers(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'alsaaudio' is not defined
>>>

as for flash audio I've tried a dozen different things. It's really peculiar. When I have time I'm gonna go through everything once again and hopefully make it work. I'm more concerned about getting the volume control to work. Thanks again.

Revision history for this message
onox (onox) said :
#5

>>> alsaaudio.mixers(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'alsaaudio' is not defined

You need to type: "import alsaaudio" first :)

Ok, it seems that alsaaudio.cards() is only defined in 0.4. One last thing: could you add the following to a file test_alsa_cards.py:

import commands

for i in commands.getoutput("hal-find-by-property --key alsa.type --string playback").splitlines():
    print i
    print commands.getoutput("hal-device " + i + " | grep alsa.card")

and then type in your terminal: python test_alsa_cards.py. Paste the output

Revision history for this message
feeboo (feeboo) said :
#6

:)

/org/freedesktop/Hal/devices/pci_8086_24c5_sound_card_0_alsa_playback_4
  alsa.card = 0 (0x0) (int)
  alsa.card_id = 'Intel 82801DB-ICH4 with AD1886A' (string)
/org/freedesktop/Hal/devices/pci_8086_24c5_sound_card_0_alsa_playback_0
  alsa.card = 0 (0x0) (int)
  alsa.card_id = 'Intel 82801DB-ICH4 with AD1886A' (string)
/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_3
  alsa.card = 1 (0x1) (int)
  alsa.card_id = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102)' (string)
/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_2
  alsa.card = 1 (0x1) (int)
  alsa.card_id = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102)' (string)
/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0
  alsa.card = 1 (0x1) (int)
  alsa.card_id = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102)' (string)

the first thing you wrote (adding "import alsaaudio") didn't change the final output. same response as before.

Revision history for this message
onox (onox) said :
#7

import alsaaudio -> you mean the output of alsaaudio.mixers(1)?

Revision history for this message
onox (onox) said :
#8

If you type python, then import alsaaudio, and then alsaaudio.mixers(1), then you should get anything but a NameError.

One last thing: type in your terminal:

hal-device /org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0

And:

hal-device `hal-get-property --key alsa.originating_device --udi /org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0`

Revision history for this message
feeboo (feeboo) said :
#9

feeboo@workhorse:~$ hal-device /org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0
udi = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0'
  info.callouts.add = { 'hal-acl-tool --add-device' } (string list)
  linux.device_file = '/dev/snd/pcmC1D0p' (string)
  info.callouts.remove = { 'hal-acl-tool --remove-device' } (string list)
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1e.0/0000:02:09.0/0000:03:00.0/sound/card1/pcmC1D0p' (string)
  alsa.device_file = '/dev/snd/pcmC1D0p' (string)
  info.subsystem = 'sound' (string)
  info.parent = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0' (string)
  alsa.originating_device = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0' (string)
  info.product = 'ADC Capture/Standard PCM Playback ALSA Playback Device' (string)
  alsa.card = 1 (0x1) (int)
  info.udi = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0' (string)
  alsa.type = 'playback' (string)
  alsa.card_id = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102)' (string)
  linux.hotplug_type = 2 (0x2) (int)
  alsa.device = 0 (0x0) (int)
  linux.subsystem = 'sound' (string)
  info.capabilities = { 'alsa', 'access_control' } (string list)
  alsa.pcm_class = 'generic' (string)
  info.category = 'alsa' (string)
  alsa.device_id = 'ADC Capture/Standard PCM Playback' (string)
  access_control.file = '/dev/snd/pcmC1D0p' (string)
  access_control.type = 'sound' (string)

and

feeboo@workhorse:~$ hal-device `hal-get-property --key alsa.originating_device --udi /org/freedesktop/Hal/devices/pci_1102_8_sound_card_0_alsa_playback_0`
udi = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0'
  linux.sysfs_path = '/sys/devices/pci0000:00/0000:00:1e.0/0000:02:09.0/0000:03:00.0/sound/card1' (string)
  info.subsystem = 'sound' (string)
  sound.originating_device = '/org/freedesktop/Hal/devices/pci_1102_8' (string)
  info.parent = '/org/freedesktop/Hal/devices/pci_1102_8' (string)
  info.product = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102) Sound Card' (string)
  sound.card = 1 (0x1) (int)
  info.udi = '/org/freedesktop/Hal/devices/pci_1102_8_sound_card_0' (string)
  sound.card_id = 'Audigy 2 ZS Notebook [SB0530] (rev.0, serial:0x20011102)' (string)
  linux.hotplug_type = 2 (0x2) (int)
  linux.subsystem = 'sound' (string)
  info.capabilities = { 'sound' } (string list)
  info.category = 'sound' (string)

Revision history for this message
onox (onox) said :
#10

Can you confirm that when you type python, then import alsaaudio, and then alsaaudio.mixers(1), that you get a list, but not a NameError? Do you also get a list with alsaaudio.mixers(0)? Do you get a ALSAAudioError with alsaaudio.mixers(2)? That's the last info I need to modify the applet to support multiple cards.

Revision history for this message
feeboo (feeboo) said :
#11

feeboo@workhorse:~$ python
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import alsaaudio
>>> alsaaudio.mixers("1")
ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
alsaaudio.ALSAAudioError: No such file or directory
>>> alsaaudio.mixers(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: argument 1 must be string, not int
>>> alsaaudio.mixers('1')
ALSA lib control.c:909:(snd_ctl_open_noupdate) Invalid CTL 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
alsaaudio.ALSAAudioError: No such file or directory
>>>

i don't know what to tell you. changing the number doesn't do anything either. i'm amazed by your service and i'll help however i can. but this doesn't seem to work for whatever reason. it's asking for a string. i added quotes, which i figured wouldn't work but i'd give it a shot.

Revision history for this message
onox (onox) said :
#12

It seems python-alsaudio-0.2 uses cardnames instead of a cardindex, but these cardnames are different than the names returned by HAL. Can you ask the ubuntu folks to package 0.4?

Revision history for this message
onox (onox) said :
#13

Can you try to create a file test_gst.py:

import gst
print gst.element_factory_make("alsasink").probe_get_values_name("device")

It should print a list, probably like this: ['hw:0,0', 'hw:0,4']

then do: python
import alsaaudio
alsaaudio.mixers("hw:0,0")

(or a different name if you get different output from test_gst.py)

Revision history for this message
feeboo (feeboo) said :
#14

i'm now working on two computers cause i got my old computer working again. so copying output over won't be as easy but i'll certainly do it if it helps you out with this. but in this case i don't think it'll make a difference. i'm still getting alsaoutput errors.

i created that file. added the commands to it. opened up terminal, opened python and imported that file. it outputted 5 things

(0,0),(0,4),(1,0),(1,2),(1,3) with the hw stuff around each one.

then i typed import alsaaudio and it gave me the prompt and then i typed alsaaudio.mixers with every one of them, not that i expected the output to change but i wanted to be thorough.

every time i got this error

alsaaudio.ALSAAudioError: No such file or directory

I'm now going to send something to Ubuntu although i have no clue whether they'll listen to me or not =)

i bet you didn't expect this all to be such a headache. your dedication to your project though is incredible. i've never seen anything like it.

Revision history for this message
onox (onox) said :
#15

What makes this difficult is that python-alsaaudio-0.2 (the version shipped by ubuntu) is different than 0.4. I can only conclude that with 0.2 it's nearly impossible to support multiple sound cards. However, I'm now exploring gstreamer with gst-python, which is a multimedia framework (used by several gnome apps) and is much more flexible than python-alsaaudio. I can't say how long it's gonna take, but I'm working on it.

Revision history for this message
feeboo (feeboo) said :
#16

just to let you know i wrote this:
https://answers.launchpad.net/ubuntu/+question/61473

and that eventually resulted in this:
https://bugs.launchpad.net/ubuntu/+source/pyalsaaudio/+bug/331171

i wouldn't worry too much about this problem at this point. if it's a bug with ubuntu and it's going to get fixed (hopefully) soon than it may be best just to wait for that. i'll update the second i hear it's been fixed and get back to you.

if you want to continue with gstreamer i'll gladly do whatever you ask. but again, there may not be a point.

Revision history for this message
onox (onox) said :
#17

I have already gstreamer support working for a single soundcard.

Can you do this:
1) Set the Master track volume of your first soundcard (Intel) to a low number via gnome's volume control
2) Set your Master track volume of your second soundcard (Audigy) to a high number via gnome's volume control

Can you add following to test_gst_mixer.py:

#!/usr/bin/env python
import gst

mixer = gst.element_factory_make("alsamixer")
mixer.set_state(gst.STATE_READY)
mixer.set_property("device", "hw:0,0")

for track in mixer.list_tracks():
    if track.flags & gst.interfaces.MIXER_TRACK_OUTPUT and track.num_channels > 0:
        if track.flags & gst.interfaces.MIXER_TRACK_MASTER:
            print track.label, "min,max: (%d, %d), channels=%d volume=" % (track.min_volume, track.max_volume, track.num_channels) + str(mixer.get_volume(track))

mixer.set_state(gst.STATE_NULL)

Execute this file (python test_gst_mixer.py) with hw:0,0 like above. Then change it to hw:1,0 and execute the file again. You should see something like this:

Master min,max: (0, 31), channels=2 volume=(24, 24)

Question: are the volume numbers higher the second time or the same? (Maybe you should also try hw:0 and hw:1 (without ,0)

Revision history for this message
onox (onox) said :
#18

Can you test the new testing PPA (bzr1094)? See https://edge.launchpad.net/~awn-testing/+archive/ppa
You can change your card in the preferences. Please tell me if it works or not.

Revision history for this message
onox (onox) said :
#19

Can you test the new testing PPA (bzr1094)? See https://edge.launchpad.net/~awn-testing/+archive/ppa
You can change your card in the preferences. Please tell me if it works or not.

Revision history for this message
feeboo (feeboo) said :
#20

Sorry, I've been away all weekend and I've been working on it for the past hour. I didn't attempt your second last message but I can if you would like. I've been trying to get the trunk version of your product going. I'm having a lot of difficulty. I'm using the Synaptic Package Manager and whenever I click on one it says that it won't install because of missing packages. Then I click on those and it says:

libawn0-trunk:
 Depends: libgnome-desktop-2-11 (>=1:2.25.5) but it is not installable
  Depends: libgtk2.0-0 (>=2.15.0) but 2.14.4-0ubuntu1 is to be installed

I should probably just use a sudo line and install them that way. I don't want to mess it up though. Would you mind writing out the command to ensure that all dependencies are installed? Or tell me how to go about doing it with the Synaptic Package Manager. I just figure it's wiser to ask then to try a half dozen things and then have to remember it all when I tell you I couldn't figure it out :P

Revision history for this message
Best onox (onox) said :
#21

A dev says you're trying to install jaunty packages. You have 8.10 which is iirc intrepid, so you need to change your sources.list. Oh and the bzr1105 version was just built, I would try that instead of 1094 because in 1105 it should detect multiple soundcards properly.

Revision history for this message
feeboo (feeboo) said :
#22

Well probably last time I get to talk to you so I'll once again say how impressed I am with your dedication. I'm listening to a mix right now and I've switched it back and forth between the two sound cards a few times and it hasn't messed up in any way. I've also figured out that you can scroll the volume up and down when hovering over the icon. sweet, sweet idea. Anyway, it's working great now. Still not sure if I'm ready to drop the top bar but at this point I have no reason not to. All thanks to you. Cheers mate.

Sincerely

Rob S

Revision history for this message
onox (onox) said :
#23

Nice to hear that you like the applet :D. You can also mute/unmute the volume by clicking the middle mouse button (that should be your scrollwheel) when hovering over the icon.