Note: The alsaequal package does not support multilib, so configuring it on a 64-bit platform will lock out 32-bit programs. With the below asound.conf/asoundrc, you should be able to run these without equalization by setting the environment variable 'ALSA_ASYM_PLAY' to 'dmix' (or 'null' if you want to silence them completely).

Install media-plugins/alsaequal Configure thus:

/etc/asound.conf:

# Set the default backend card and device to the onboard Intel HDA codec; see
# /proc/asound/cards for the names of the cards in the system.
defaults.pcm.!card PCH
defaults.ctl.!card PCH
defaults.pcm.!device 0
defaults.ctl.!device 0

# Equalizer definition, uses dmix internally; use amixer in a script to adjust
# the equalizer boost/cut levels, or use the following command to adjust the
# levels interactively.
#
#   alsamixer -D equal
#
ctl.equal {
  type equal;
}
pcm.equal {
  type equal;
  slave.pcm "plug:dmix";
}

# The alsaequal plugin is not compatible with 32-bit programs on amd64, so it
# will crash them with the following message:
#
#   Failed to load plugin "/usr/lib/ladspa/caps.so": /usr/lib/ladspa/caps.so: wrong ELF class: ELFCLASS64
#
# To get around this, the asymed definition takes two parameters: PLAY and
# CAPT, to direct the slave PCMs. These are controlled either by arguments
# in the slave definition (i.e. slave.pcm "asymed:dmix,dsnoop" ), or by
# environment variables (ALSA_ASYM_PLAY=dmix ALSA_ASYM_CAPT=dsnoop aplay ...)
pcm.asymed {
  @args [ PLAY CAPT ]
  @args.PLAY {
    type string
    default {
      @func getenv
      vars [
        ALSA_ASYM_PLAY
      ]
      default "equal"
    }
  }
  @args.CAPT {
    type string
    default {
      @func getenv
      vars [
        ALSA_ASYM_CAPT
      ]
      default "dsnoop"
    }
  }
  type asym;
  playback.pcm $PLAY;
  capture.pcm $CAPT;
}

# Set the default playback device to the above asymed soft-device
pcm.!default {
  type plug;
  slave.pcm asymed;
}

Use 'alsamixer -D equal' to change the equalizer settings; they will be saved and restored by the OS boot scripts just like any other soundcard volume setting.

And here's a way to switch presets:

#!/bin/sh

# Mine: "80 74 68 66 66 66 64 62 58 56"
# Flat: "65 65 65 65 65 65 65 65 65 65"

set_equalizer_curve() {
  curve="${*}"
  ctl=0
  for point in ${curve}
  do
    ctl=$(( ${ctl} + 1 ))
    echo cset numid=${ctl} ${point}
  done | amixer -D equal -s
}

profile="${1:-mine}"
case "${profile}" in
mine) curve="80 74 68 66 66 66 64 62 58 56" ;;
flat) curve="65 65 65 65 65 65 65 65 65 65" ;;
*) echo "Unknown profile ${profile}" >&2 ;;
esac

[ "${curve}" ] && set_equalizer_curve "${curve}"