raedwulf / alsaequal

GNU Lesser General Public License v2.1
32 stars 13 forks source link

Unable to use equalizer with softvol #3

Open timothyjward opened 4 years ago

timothyjward commented 4 years ago

Hi, I've tried using the equalizer (and seen it work) but I don't seem to be able to use it in conjunction with a software volume control.

What I want is something like the following asound.conf:

pcm.!default {
    type plug
    slave.pcm "equal"
}

pcm.plugequal {
    type plug
    slave.pcm "equal"
}

ctl.equal {
    type equal;
}

pcm.equal {
    type equal;
    slave.pcm "plugsoftvolume"
}

pcm.plugsoftvolume {
    type plug
    slave.pcm "softvolume"
}

pcm.softvolume {
    type            softvol
    slave {
        pcm         "plughw:2,0"
    }
    control {
        name        "SoftMaster"
        card        2
        device      0
    }
max_dB 0.0
min_dB -50.0
resolution 100
}

I want it this way around because the equalizer will work much better with the full input signal, and then the final volume control can be used to adjust the overall volume. Unfortunately when I do this I get:

aplay: pcm_params.c:170: snd1_pcm_hw_param_get_min: Assertion!snd_interval_empty(i)' failed.`

I don't see any reason why the equalizer plugin should require that it outputs to a hardware device (the docs even suggest it should be possible to target dmix).

raedwulf commented 4 years ago

I'll have a look into this, thanks!

JasonLG1979 commented 3 years ago

@timothyjward Try putting softvol before equal. Something like this (you don't need to use quotes for strings that don't have special chars):

pcm.!default {
    type softvol
    max_dB 0.0
    min_dB -50.0
    resolution 100
    slave.pcm plugequal
    control {
        name SoftMaster
        card 2
    }
}

pcm.plugequal {
    type plug
    slave.pcm equal
}

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

ctl.equal {
    type equal
}

ctl.!default {
    type hw
    card 2
}
stekliPes commented 3 years ago

I know this is quite a late answer, but I am using a very similar configuration (plug -> softvol -> plug -> equal -> softvol -> dmix) configuration and i found that simply adding "rate: unchanged" to the plug before equal, see below:

pcm.!default {
  type asym
  playback.pcm preequal
  capture.pcm null
}

pcm.preequal {
  type plug
  slave.pcm equal
  slave.rate unchanged
}

ctl.equal {
  type equal
  controls /etc/equal.state
}

pcm.equal {
  type equal
  slave.pcm master
  controls /etc/equal.state
}

ctl.master {
  type hw
  card 0
}

pcm.master {
  type plug
  slave {
    pcm  master_volume
  }
}

pcm.master_volume {
  type softvol
  slave.pcm master_switch
  control {
    name "Master Volume"
    card 0
  }
  min_dB -127.5
  max_dB 0.0
}

pcm.master_switch {
  type softvol
  slave.pcm analog_out
  control {
    name "Master Switch"
    card 0
  }
  resolution 2
}
pcm.analog_out {
   type dmix
   ipc_key 1024
   slave {
       pcm "hw:0,0"
       channels 2
       period_size 1200
       buffer_size 12000
    }
}
ygoe commented 2 years ago

Any news here? I've tried setting that rate option but it's ineffective. I understand the original post's explanation to do the equalizer first and then the volume scaling and that's what I prefer, too. I get another error message, though:

ALSA lib pcm_params.c:2226:(snd1_pcm_hw_refine_slave) Slave PCM not usable
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument

I can use the equalizer directly with the hardware, but it'll play at full volume and make a very loud cracking sound at the start of each file. Or I can use the volume and mixer, but without the equalizer. I'd like to have both! Without the cracks.

Changing the order of equal and softvol doesn't change anything either.

raedwulf commented 2 years ago

Unfortunately sorry, I don't have time to maintain this, I'm looking for someone to take on maintenance of the repository.

Lauszus commented 2 years ago

Here's a configuration that I have been using:

# Use the PCM "dmix" plugin
pcm.dmixer {
    type dmix
    ipc_key 1024
    ipc_perm 0666
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 44100
        channels 2
    }
}

# Use the PCM "softvol" plugin and route the output to "dmixer"
pcm.softvol {
    type softvol
    slave.pcm "dmixer"
    control {
        name "PCM"
        card 0
    }
}

# Create a control - use "alsamixer -D softvol" to use it
ctl.softvol {
    type hw
    card 0
}

# Use the PCM "equal" plugin and route the output to "softvol"
pcm.equal {
    type equal
    slave.pcm "plug:softvol"
}

# Create a control - use "alsamixer -D equal" to use it
ctl.equal {
    type equal
}

# Override the default PCM, so "equal" is used
pcm.!default {
    type plug
    slave.pcm "equal"
}

# Make the "equal" control the default
ctl.!default {
    type equal
}

The result is equal -> softvol -> dmix :)