Reply
Thread Tools
Posts: 116 | Thanked: 4 times | Joined on Jan 2010
#1
hi,

i found an N800 example code to unmute / mute sound of mixer.

The mixer device is referenced in /dev/mixer.

But when i look for /dev/mixer in N900 device, i didn't find it.

Is it normal ?

Thanks for your help.
 
Posts: 5 | Thanked: 1 time | Joined on Aug 2010
#2
Originally Posted by verrnum View Post
hi,

i found an N800 example code to unmute / mute sound of mixer.

The mixer device is referenced in /dev/mixer.

But when i look for /dev/mixer in N900 device, i didn't find it.

Is it normal ?

Thanks for your help.
You can mute/unmute sound simply by calling:
Code:
amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On
You also can route all sound to Earphone by:
Code:
amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off

Last edited by pospani; 2010-08-28 at 05:55.
 

The Following User Says Thank You to pospani For This Useful Post:
Posts: 116 | Thanked: 4 times | Joined on Jan 2010
#3
Originally Posted by pospani View Post
You can mute/unmute sound simply by calling:
Code:
amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On
You also can route all sound to Earphone by:
Code:
amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off
Hi,

Thank you for your help.

amixer is a system command ? How to call system command from application ?

Thanks
 
Posts: 200 | Thanked: 300 times | Joined on Nov 2009 @ The Netherlands
#4
Originally Posted by pospani View Post
You can mute/unmute sound simply by calling:
Code:
amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On
You also can route all sound to Earphone by:
Code:
amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off
What are the red audio sources?
 
Posts: 5 | Thanked: 1 time | Joined on Aug 2010
#5
Originally Posted by verrnum View Post
Hi,

Thank you for your help.

amixer is a system command ? How to call system command from application ?

Thanks

From Qt you can use QProcess to execute external processes.
If you dont want do this by starting amixer from within your application, you must use ALSA libraries to accomplish this.
But believe me, it is much easier to call amixer as external process.
 
Posts: 5 | Thanked: 1 time | Joined on Aug 2010
#6
Originally Posted by digitalvoid View Post
What are the red audio sources?
All audio sources are routed. For example you can route audio output from mediaplayer to the earphone. But it makes no sense, routing audio to earphone is needed for VOIP applications, usually you want to hear the other voice out of the earphone and not from external speakers. By using this commands you can switch between earphone and external speaker.
 
Posts: 116 | Thanked: 4 times | Joined on Jan 2010
#7
Originally Posted by pospani View Post
From Qt you can use QProcess to execute external processes.
If you dont want do this by starting amixer from within your application, you must use ALSA libraries to accomplish this.
But believe me, it is much easier to call amixer as external process.
Thank for hints.
 
Posts: 56 | Thanked: 31 times | Joined on Jul 2008 @ Austria
#8
verrnum, Yes, "/dev/mixer" is the device the rest of the world uses for OpenSoundSystem audio on UNIX and UNIX-like systems.

However, because of licensing problems in the past (OSS went closed source for a time), Linux has developed its own audio subsystem called "Advanced Linux Sound Architecture" to replace it.
Nowadays, there's also a daemon called "pulseaudio" which does software mixing and per-application mixing etc.

Note that ALSA exposes some rather un-UNIXish API which everyone is supposed to use. One is not supposed to even open the device files (there are device files for ALSA, foo).
To understand the ALSA API, forget everything you thought you knew about UNIX device access and rather think about something like DirectSound or WinMM (I'm not a fan, but that's just how it is).

I think PulseAudio has an ALSA-lib interface, so when you use the ALSA libs to set something, you actually talk to PulseAudio.

Confused yet?

I've extracted the relevant bits of the Xfce4 mixer I wrote 7 years ago:

#include <alsa/asoundlib.h>
#include <alsa/mixer.h>
#include <alsa/control.h>

static char const* master_ids[MAX_MASTERS] = {
"Master",
"PCM",
"Analog Front",
"Speaker",
NULL,
};

static snd_mixer_t *handle = NULL;
static snd_mixer_elem_t *elem = NULL;
static char card[64] = "default";
snd_mixer_selem_id_t* master_selectors[MAX_MASTERS] = { NULL };

if ((err = snd_mixer_open(&handle, 0)) < 0 || !handle) {
printf("alsa: Mixer %s open error: %s\n", card, snd_strerror(err));
return;
}

if ((err = snd_mixer_attach(handle, card)) < 0) {
snd_mixer_close(handle);
return;
}
if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
printf("alsa: Mixer register error: %s\n", snd_strerror(err));
snd_mixer_close(handle);
return;
}
err = snd_mixer_load(handle);
if (err < 0) {
printf("alsa: Mixer load error: %s: %s\n", card, snd_strerror(err));
snd_mixer_close(handle);
handle = NULL;
return;
}

for (i = 0; elem == NULL && i < MAX_MASTERS && master_ids[i] != NULL; i++) {
snd_mixer_selem_id_alloca(&master_selectors[i]);
snd_mixer_selem_id_set_index(master_selectors[i], 0);
snd_mixer_selem_id_set_name(master_selectors[i], master_ids[i]);

elem = snd_mixer_find_selem(handle, master_selectors[i]);

if (elem != NULL) {
if (!snd_mixer_selem_has_common_volume(elem)
&& !snd_mixer_selem_has_playback_volume(elem)
) { /* no playback device */
elem = NULL;
}
}

snd_mixer_selem_set_playback_volume_all (elem, lval);

See for yourself at http://archive.ubuntu.com/ubuntu/poo...97.orig.tar.gz in file "lib/vc_alsa.c".

The platform part one is supposed to use on Maemo (I think) is http://www.gstreamer.net/data/doc/gstreamer/head/pwg/html/section-iface-mixer.html and it's used like this: https://launchpad.net/gmixer

P.S.: can someone please fix indentation in talk.maemo.org posts? Code samples are almost unreadable like this.

Last edited by dannym; 2010-08-29 at 17:46.
 
Posts: 116 | Thanked: 4 times | Joined on Jan 2010
#9
Thank you for your very complete answer

I am still a newby developper in linux plateform, and it's a little bit difficult too understand all your explaination.

I will user the amixer command via QProcess .

Thanks a lot.
 
Posts: 40 | Thanked: 14 times | Joined on Feb 2010 @ Rio de Janeiro, Brazil
#10
hi all,
I don't know if I had to open another thread to ask this... but still...
taking this scenario:
I'm in a call on the n900, and I want to show a music or any sound provided from the music player for me and the person that I'm calling.
Like we hear the same podcast, or show any track that I did.
Can I do this with the amixer command?
__________________
I vote, merge maemo/megoo apps to OVI!
 
Reply


 
Forum Jump


All times are GMT. The time now is 21:18.