Re: 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 don't know about spotify or mpd, so I'm not sure if I'm understanding the question correctly, but with Pulseaudio you can monitor output sinks, for example:

https://wiki.archlinux.org/index.php/PulseAudio/Examples#Monitor_specific_output
https://wiki.archlinux.org/index.php/PulseAudio/Examples#ALSA_monitor_source

You can create a loopback device with Pulseaudio:

https://unix.stackexchange.com/questions/263274/pipe-mix-line-in-to-output-in-pulseaudio

Sometimes I use a combination of ALSA and pulse, but it tends to get out of sync over many hours, presumably because ALSA doesn't resample to compensate for crystal differences. Here would be an example command:

ecasound -i alsa,plughw:2 -o alsa,pulse:music

The alsalib package has a number of PCM devices that look promising: copy, share, dsnoop, file, tee, shm

https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

I'm no expert, but I would avoid any of the ALSA solutions. If you are sending one stream to multiple audio cards, the crystals are going to be slightly different (e.g. 48.033 kHz vs 48 kHz), so you need a system which is able to resample to keep these in sync. ALSA doesn't have that ability AFAIK. ALSA can "resample" 48 kHz to 44.1 kHz, but it can't do adaptive resampling to correct for crystal differences. Whether MPD can fix this, I don't know.

Frederick

On Sat, Jan 18, 2020 at 09:53:23PM +0100, Jürgen Gluch wrote:
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

<juglu@xxxxxxxxx>


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



_______________________________________________
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