nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

pimoroni PhatDac No Duplex sound

Sun May 15, 2016 2:49 pm

I have been trying to get this DAC card to work with full duplex sound and have gotten nowhere.

Does anyone here know how to accomplish this?

What I have is:

It will play only one source at a time. While it plays that source there is no other access to the DAC from any other source.

I am not an expert with the sound configuration

My configuration:

Distributor ID: Raspbian
Description: Raspbian GNU/Linux 8.0 (jessie)
Release: 8.0
Codename: jessie

Pi 2 Model B 1GB a21041 (Embest, China)

Adafruit 3.5 PITFT

Pimoroni Phat Dac

Key Software: Pythin Pygame Espeak MPD Pianobar LIRC

My PiGuiPiano which gives me touchscreen or remote control to listen to music check NOAA weather + Time dictated by espeak
Not completely current but close: https://github.com/ErnieBoxer/PiGuiPiano



Image

nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

Re: pimoroni PhatDac No Duplex sound

Sun May 15, 2016 3:11 pm

Just a cross reference to my Pimoroni post:

http://forums.pimoroni.com/t/how-to-get ... g-now/2361

Sleep Mode zZ
Posts: 319
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland

Re: pimoroni PhatDac No Duplex sound

Sun May 15, 2016 3:53 pm

I know for sure that ALSA in the past could not handle several applications at the same time. It is most probably is like that still. If a program uses ALSA directly as an output that will reserve ALSA output for that program and other programs can't play any sounds through it.

You have to use PulseAaudio or Jack. They were created just for this purpose. You can think of them mixers that takes the outputs from many programs and plays the mix through the ALSA output that they have reserved for themselves. That means that you should not send sound output directly to ALSA in any of the programs that you are using. You should use either Jack or PulseAudio depending on your application - and have a PulseAudio or Jack server running on your Pi. PulseAudio is a general solution and Jack is for musicians for whom audio latency matters. (It is also possible to use both at the same time.) Unfortunately, it can be complicated to get everything running nice.


Edit.: I was wrong in the above. ALSA has a mixer plugin called dmix, and it had it even before PulseAudio was around. My wrong impression might actually be the fault of PulseAudio. My first distro were Ubuntu 8.04, which adopted PulseAudio and had lots of problems with it. I ended stripping PulseAudio away from it but maybe did a bad job with it and that is the reason for my impression that ALSA can't mix multiple sound sources to a sound card.

So there are three different systems to mix audio streams to one output: PulseAudio, Jack and ALSA with dmix. Jack is for professional quality audio, PulseAudio and ALSA with dmix are for less critical use. From them you should most probably go with whatever your GNU/Linux distribution of choice has chosen to use - makes life easier.

Ps.; the problem is not about full duplex audio. Full duplex means the ability to send and receive a signal at the same time. Phat DAC has no inputs, and no analog to digital converters, so it can't work in full duplex mode even in theory.
Last edited by Sleep Mode zZ on Thu May 26, 2016 1:12 am, edited 1 time in total.

nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

Re: pimoroni PhatDac No Duplex sound

Sun May 15, 2016 6:08 pm

Pluse did not work and made for static and crashing.

Guess i look into jackd

nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

Re: pimoroni PhatDac No Duplex sound

Sun May 15, 2016 6:47 pm

Looks like in order to use jackd 1/2 you are supposed to build all your apps with the flags to support jackd. Possibly I will be motivated to try this some time in the future. So I might as well build a Gentoo system.

nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

Re: pimoroni PhatDac No Duplex sound

Mon May 16, 2016 11:32 pm

Hope this helps someone else.

This works for duplex sound:
/etc/asound.conf

Code: Select all

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
}


Needed for MPD in /etc/mpd.conf

Code: Select all

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

nikoff90
Posts: 21
Joined: Wed Sep 25, 2013 12:43 am

Re: pimoroni PhatDac No Duplex sound

Wed May 25, 2016 6:49 pm

Most recent update with software volume master and mpd. mpc controls volume for mpc but alsamixer tab not working on mpc, alsamixer does work for master on Software control.

DAC does work stacked with the PITFT 3.5 no issues now.

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


sudo nano /etc/asound.conf

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

Code: Select all

 # 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"
        }

Now software:

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

edit mpd.conf with this audio_output




Code: Select all

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

Return to “Troubleshooting”