Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    /dev/mixer on N900 ?

    Reply
    verrnum | # 1 | 2010-08-26, 14:15 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pospani | # 2 | 2010-08-28, 05:41 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by pospani; 2010-08-28 at 05:55.
    The Following User Says Thank You to pospani For This Useful Post:
    wreckgar23

     
    verrnum | # 3 | 2010-08-28, 21:16 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    digitalvoid | # 4 | 2010-08-28, 21:23 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pospani | # 5 | 2010-08-29, 06:32 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pospani | # 6 | 2010-08-29, 06:38 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    verrnum | # 7 | 2010-08-29, 09:39 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    dannym | # 8 | 2010-08-29, 17:35 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by dannym; 2010-08-29 at 17:46.

     
    verrnum | # 9 | 2010-08-29, 20:36 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    lauksas | # 10 | 2011-03-18, 22:47 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
vBulletin® Version 3.8.8
Normal Logout