Duddy Cool Duddy Cool - 1 year ago 229
C++ Question

select audio output divece when using QSoundEffect

I am using

to play loops of some short
files. This class was the solution for me because it allow us to play low latency sounds.

Everything was fine but now I need to select the output device but I haven’t found the way to do this with
. I know that using
I can get a list of the available devices and use one of them in the constructor of a
object to play a wav file but
doesn't allow us to make low latency loops.

So the thing is that I need the functionality of selecting the audio output device that
but the ability of playing play low latency loops that

In other words I have all the pieces of my desired solution but I don’t know how to put them together.

Answer Source

Since Qt5.7 the alsa qt plugin (libqtaudio_alsa.so) is using the device "default", this you can configure in /etc/asound.cfg or ~/.asoundrc In the example below I'm selecting dmix plugin as default device:

pcm.dmixed {
    type dmix
    ipc_key 1024
    ipc_key_add_uid 0
    slave.pcm "hw:0,0"
pcm.dsnooped {
    type dsnoop
    ipc_key 1025
    slave.pcm "hw:0,0"

pcm.duplex {
    type asym
    playback.pcm "dmixed"
    capture.pcm "dsnooped"

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

ctl.!default {
  type hw
  card 0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download