Howto: get PHAT DAC to play all system sound + software volume control

I can get sound from MPD Pianobar but system seems to only play one app at a time only and will not play others such as espeak which I use for time and weather reports fron NOAA

Oo well I cant seem to make this work in any sort of flexible manner. Sound quality is good and it might be fine for a single app but without being able to make this thing play more than one imput I am left looking for other options.

Hum, I’m no alsa expert, but as I understand you need to configure it in a specific way if you want to use multiple audio sources.

I’ve seen pulseaudio mentioned a number of times in that context, whether or not that is a requirement as opposed to a convenience I’m not sure.

Either way, it’s not really a hardware issue - it should definitely be possible to send audio from multiple applications. I would hit the alsa doc and see if you can makes heads or tail of it.

You can say that is the case but I have yet to find anywhere were someone has successfully done this. I have found where others have attempted and failed. Please if someone knows how to do this point me in the right direction.

Since the pHAT DAC is based on a Hifiberry DAC, it does not support hardware mixing. Historically the work-around for this in ALSA is to define a dmix (direct mixing) plugin, an example of this can be found here.

Ok if anyone is interested this seemed to work on a fresh updated SD

sudo nano /boot/config
edit bottom to look like this this:

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtoverlay=i2s-mmap
dtoverlay=hifiberry-dac

mkae
sudo nano /etc/asound.conf

pcm.dmixer { 
    type dmix 
    ipc_key 1024
    ipc_key_add_uid false
    ipc_perm 0666			# mixing for all users
    slave { 
        pcm "hw:0,0" 
        period_time 0 
        period_size 1024 
        buffer_size 8192
        rate 44100
    }
    bindings { 
        0 0 
        1 1 
    } 
} 

pcm.dsp0 { 
    type plug 
    slave.pcm "dmixer" 
} 

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

pcm.default { 
   type plug 
   slave.pcm "dmixer" 
} 

ctl.mixer0 { 
    type hw 
    card 0 
}

sudo apt-get update && sudo apt-get dist-upgrade

sudo apt-get --purge autoremove pulseaudio

sudo apt-get remove jack-daemon

sudo apt-get install mpd mpc pianobar alsa-base alsa-oss alsa-tools alsa-utils alsaplayer-alsa alsaplayer-common gstreamer0.10-alsa gstreamer1.0-alsa alsa-oss oss-compat libsmartcols1 jackd libjack-jackd2-0:armhf qjackctl esound-common libasound2:armhf libasound2-data libasound2-plugins libsoundtouch0:armhf libtext-soundex-perl libsdl-mixer1.2:armhf pimixer

For mpd to work comment out pre configured audio output and add this in its place.
sudo nano /etc/mpd.conf

audio_output {
        type                    "alsa"
        name                    "Sound Card"
        options                 "dev=dmixer"
}

If you try this let me know if it works for you. I have yet to try espeak with this.

This /etc/asound.conf looks to make alsamixer have a software volume control + mpd volume works:

# the sound card
    pcm.real {
      type hw
      card 0
      device 0
    }

    #support  the ipc stuff is needed for permissions, etc.
    pcm.dmixer {
      type dmix
      ipc_key 1024
      ipc_perm 0666
      slave.pcm "real"
      slave {
        period_time 0
        period_size 1024
        buffer_size 8192
        rate 44100
      }
      bindings {
        0 0
        1 1
      }
    }

    ctl.dmixer {
      type hw
      card 0
      }

    # software volume
    pcm.softvol {
      type softvol
      slave.pcm "dmixer"
      control {
        name "Software"
        card 0
      }
    }
    # mpd volume control
    pcm.mpdvol {
      type softvol
      slave.pcm "dmixer"
      control {
        name "MPD"
        card 0
      }
    }
    # ctrl for mpd volume
    ctl.mpdvol {
      type hw
      card 0
    }

    # input
    pcm.input {
            type dsnoop
            ipc_key 3129398
            ipc_key_add_uid false
            ipc_perm 0660
            slave.pcm "810"
    }
    # duplex device
    pcm.duplex {
            type asym
            playback.pcm "softvol"
            capture.pcm "input"
    }

    # default devices
    pcm.!default {
      type plug
      slave.pcm "duplex"
    }

    # for oss devices
    pcm.dsp0 {
      type plug
      slave.pcm "duplex"
    }

edit mpd.conf with this audio_output
/etc/mpd.conf

audio_output {
        type                    "alsa"
        name                    "Sound Card"
        options                 "dev=dmixer"
        mixer_type              "software"
}