2

I'm currently struggling with the following scenario: I'd like to make my Raspi (3B) play a short MP3 jingle and then, after a 250 µsec pause, speak a short text by using an add-on sound card (JustBoom DAC HAT). Both mpg123, and eSpeak are running separately, buth all attempts to run them one after another from a C++ client app, were futile 'cause eSpeak complained about sound card #1 not working. My HAT, however, is card #0 in the alsa config file, and on-board sound has been kicked out of the config:

pcm.!default {
  type plug

  slave {
    pcm "hw:0,0"
    format S32_LE
    channels 2
    rate 192000
  }
}

ctl.!default {
        type hw
        card 0
}

hw:0,0 is my JustBoom card:

pi@autoradio:/import/valen/autoradio $ aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: sndrpijustboomd [snd_rpi_justboom_dac], Gerät 0: JustBoom DAC HiFi pcm512x-hifi-0 []
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0

Here is the error message:

ALSA lib confmisc.c:768:(parse_card) cannot find card '1'

An obvious alternative would be PulseAudio, but I've never managed to make it play anything, as client code keeps on complaining about a refused connection.

So is there a method to make bith mpg123, and eSpeak coexist peacefully and play their sounds one after the other without conflicts? Thank you.

  • Why is eSpeak trying to access card 1? How is it configured? – CL. Dec 28 '18 at 11:13
  • This is what I am wondering about all the time! Default sound card is hw0,0 as there is only one active sound card, which features only one device. I haven't changed anything to the eSpeak config. – Neppomuk Dec 28 '18 at 13:18
2

OK, I've found out that mpg123 and eSpeak stumble upon each other whilst trying to spit out their sound data through the sound card. Configuring an output mixer in /etc/asound.conf resolved the issue. Here is the complete config file, taken from the ALSA project website and adapted to my needs:

pcm.dmixer {
    type dmix
    ipc_key 1024
    ipc_perm 0666
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 4096
        rate 192000
        format S32_LE
        channels 2 
    }
    bindings {
        0 0
        1 1
    }
}

pcm.dsnooper {
    type dsnoop
    ipc_key 2048
    ipc_perm 0666 
    slave 
    {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 4096
        rate 192000
        format S32_LE
        channels 2 
    }
    bindings {
        0 0
        1 1
    }
}

pcm.duplex {
    type asym
    playback.pcm "dmixer"
    capture.pcm "dsnooper"
}

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

ctl.!default {
    type hw
    card 0
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.