gregoiregentil
gregoiregentil

Reputation: 1899

ALSA: Use plugin in c code while playing sound

I'm playing a wav sound file with some c code such as this. It uses all the APIs:

snd_pcm_*

I would like to use the equalizer plugin:

libasound_module_ctl_equal.so, libasound_module_pcm_equal.so

found in "libasound2-plugin-equal"

How can I integrate and call an Alsa plugin from c code?

Upvotes: 0

Views: 556

Answers (2)

gregoiregentil
gregoiregentil

Reputation: 1899

The answer is simpler that I imagined:

snd_pcm_open(&pcm_handle, "equal", SND_PCM_STREAM_PLAYBACK, 0) < 0);

You can pass the name of the plugin to snd_pcm_open with the right set of default file.

Upvotes: 0

Varun
Varun

Reputation: 477

you need to make it part of alsa chain e.g in ~/.asoundrc add

pcm.plugequal {
    type equal;
    slave.pcm "plughw:0,0";
}

pcm.!default {
    type plug;   
    slave.pcm plugequal;  
}

Than you can use the command to play sound file

aplay some.wav

For Ctl device you can add below in ~/.asoundrc

ctl.!default {
    type equal;
}

You can just call alsamixer

Upvotes: 0

Related Questions