[SOLVED] ALSA with software mixing and equalizer plugin

Questions about codecs, DVD playback, web plugins...
Forum rules
Before you post please read how to get help

[SOLVED] ALSA with software mixing and equalizer plugin

Postby Bobbo on Fri Feb 17, 2012 6:42 pm

Hello everybody!

I'm in the process of purging my system of pulseaudio, since for me it's been a huge resource hog and did not play well with renoise.
Anyway, one of the nice features of pulseaudio was simplicity and ease of use, from adding equalizer plugin to routing sound. Now I don't have this simplicity but I have longer battery life and more CPU time for me! :mrgreen:

Anyway, to the point! And the reason I'm writing this thread. I wan't the features I had with pulseaudio, but using ALSA. There are two parts to this quest. Both are individually solved. They work.. just, not together. :lol:

Part 1.
I have the equalizer plugin working, all sounds go through it and end up sounding awsome in my cheap computer loudspeakers. But only one application at a time. I'm not sure who would ever want two apps playing sound at the same time though but it's nice if I could get it working anyway.

Part 2.
I also have a dmix plug set up and working. All sound get through it, mixed together and sent to the sound device.

Now the problem is getting these two to work together!
Here's my .asoundrc and how I've done it. This is how it looks when it's NOT working. :?

Code: Select all
#hda_intel defined as card 0, which is my first and only soundcard
pcm.hda_intel  {
        type hw
        card 0
}

#software mixer using dmix plug, to play from several sources (my sigmatel dont have hw-mix capabilities
pcm.swmixer  {
        type dmix
        ipc_key 1024
        slave {
                pcm hda_intel
                period_time 0
                period_size 1024
                buffer_size 4096
                rate 44100;
        }
        bindings {
                0 0
                1 1
        }
}

#this (ctl) is to be able to find and controll equal with alsamixer, I think that's what ctl is for..
ctl.equal {
        type equal
}

pcm.plugequal {
        type equal

        #send to swmixer, or stright to at top defined soundcard, hda_intel
        slave.pcm swmixer
        #slave.pcm hda_intel

        #testing purpose
        #slave.pcm "plug:dmix"
        #slave.pcm "plughw:0,0"
}

#pcm.eq {
#       type plug
#       slave.pcm plugequal
#} - defining eq sound device using the plugequal plug

#default sound device
pcm.!default {
        type plug
        slave.pcm plugequal
        #slave.pcm swmixer
}


It's currently configured to send everything though the plugequal device, which after streaming through the equal plugin sends it to the swmixer (dmix) plug, and then on to the sound device.

To have sound send stright to swmixer (which works fine) I just switch the commented stuff in pcm.!default from slave.pcm plugequal to slave.pcm swmixer.

Here's a note! ..and something I don't quite understand
It works sending sound to plugequal, and then on to sound device only if I change its slave.pcm to read slave.pcm "plughw:0,0". Not if I use slave.pcm hda_intel. Strange isn't it? :shock:

The error I get when trying to play a wave using aplay is:
Playing WAVE 'commando.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1043: Broken configuration for this PCM: no configurations available
it doesn't say much..

Could anyone enlighten me with a few hints and lead me on the way to find out what's going on, it'd be much appreciated!

Thank you kind Minties! :mrgreen:


EDIT: I just came up with a better idea, of sending all streams to dmix and THEN do the equalizing. That should save some CPU the few times I'm acually streaming more than one sound. The problem is ALSA lib pcm_dmix.c:1023:(snd_pcm_dmix_open) dmix plugin can be only connected to hw plugin :lol: Well maybe there's a way to work around this..

EDIT2: HURRAY! I nailed it! Ok my second plan to save CPU and send the final mix through the EQ did not go as planned. Maybe because dmix can't use type plug only type hw. There might be a better mixing plug out there? Anyway. What I did was create a dummy pcm device that sends from plugequal to swmixer! This is how it looks:
Code: Select all
#hda_intel defined as card 0, which is my first and only soundcard
pcm.hda_intel  {
        type hw
        card 0
}

#dummy plug
pcm.equal {
        type plug;
        slave.pcm swmixer;
}

#software mixer using dmix plug, to play from several sources (my sigmatel dont have hw-mix capabilities
pcm.swmixer  {
        type dmix;
        ipc_key 1024;
        slave {
                pcm hda_intel
                #pcm "hw:0,0";
                #pcm "hw:equal";
                period_time 0;
                period_size 1024;
                buffer_size 4096;
                rate 44100;
        }
        bindings {
                0 0
                1 1
        }
}

#this (ctl) is to be able to find and controll equal with alsamixer, I think
ctl.equal {
        type equal
}

pcm.plugequal {
        type equal

        #send to swmixer, or stright to at top defined soundcard, hda_intel
        #slave.pcm "swmixer";
        #slave.pcm hda_intel
        slave.pcm equal;

        #testing purpose
        #slave.pcm "plug:dmix"
        #slave.pcm "plughw:0,0";
}

#default sound device
pcm.!default {
        type plug;
        slave.pcm plugequal;
        #slave.pcm swmixer;
}


I also added some semi colons, they are not needed. There seem to be alot of freedom to how to write the .asoundrc. Notice the
Code: Select all
#testing purpose
#slave.pcm "plug:dmix"
#slave.pcm "plughw:0,0";

Sending from plugequal to plug:dmix have always worked, and WAS a solution for my problem.. but. For some reason there was more CPU usage that way. I think it's because dmix resampled the sound data. Anyway, now it's working and will not resample from 44.1kHz :mrgreen:


Late EDIT #3: Just out of curiosity. Did anyone ever try this? :P
Bobbo
Level 1
Level 1
 
Posts: 32
Joined: Thu Apr 15, 2010 12:15 am

Linux Mint is funded by ads and donations.
 

Return to Sound, Multimedia & Codecs

Who is online

Users browsing this forum: No registered users and 4 guests