How to redirect audio to a stream (e.g. as input for mpd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to redirect audio within alsa to stream, so that another software can use it other output.

Let me explain my setup. My multiroom audio for 4 rooms runs on my sever and the audio is hard wired to 4 stereo amplifiers. The server (on Xubuntu 19.04)  has two soundcards (HDMI as hw0,0 and a 7.1 soundcard as hw1,0). So far I only used the 7.1 for the multiroom audio. The 7.1 soundcard is remapped to dmixer and four 2.0 outputs, that are used by four independent mpd's (music player deamon). So every family member can run its own music player client on the mobile phone or use the wall mounted tablet to choose music (mp3 file database or web radio streams) and the rooms were the output should be active. This runs stable and nicely for years now.
Since some time we enjoy spotify and I want to stream the spotify audio also to the multiroom speakers. Therefore a spotify client (the original) is running on the server and its output goes to "pcm.!default", which I set to hw0,0. The different spotify apps play also nice together, but I cant find a solution for the connection from spotify output to mpd input.

Is there a possibility to stream the "pcm.!default" to file and make it available to mpd as a web stream (e.g. localhost, any port, as raw, wave or ogg)? I tried to use "type file" but was not successful.

My /etc/asound.conf looks like this:

# setup for the local playback at the server, also spotify
pcm.!default {
    type plug
    slave.pcm "mystream"
}

pcm.mystream {
     type file
     slave {
          pcm "hw:0,0"
          rate 48000
          channels 2
     }
     format wav
     file "/tmp/dump.wav"   #here should be something fancy, nothing appears in file...
}

# this is the mixer for the 7.1 sound card that is used by 4 mpds with 4 output zones each
pcm.dmixer {
    type dmix
    ipc_key 1099
    ipc_perm 0660
    slave {
        pcm "hw:1,0"
        rate 96000
        channels 8
        periods 128
        period_time 0
        period_size 1024
        buffer_size 4096
    }
    bindings {
        0 0
        1 1
        2 2
        3 3
        4 4
        5 5
        6 6
        7 7
    }
}

# here I map the channels of the 7.1 sound card to 4 x 2.0 stereo channels
# for the 4 zones
pcm.living {
     type plug
     slave {
          pcm "dmixer"
          channels 8
     }
     ttable.0.0 1
     ttable.1.1 1
}

pcm.bath {
     type plug
     slave {
          pcm "dmixer"
          channels 8
     }
     ttable.0.2 1
     ttable.1.3 1
}

pcm.kitchen {
        type plug
        slave {
                pcm "dmixer"
                channels 8
        }
        ttable.0.4 1
        ttable.1.5 1
}

pcm.terrace {
        type plug
        slave {
                pcm "dmixer"
                channels 8
        }
        ttable.0.6 1
        ttable.1.7 1
}

#eof

_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux