Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-20 Thread Gordon Scott

Hi

I've not followed earlier writing on this thread, so may well be out of 
turn here, but one option for synchronising clocks across multiple 
boards is to distribute low-ish stable reference and then 
phase-locked-loop multiply that up at each place where you want a an 
oscillator.


It's more complicated that just distributing a clock, but has advantages 
that high-ish frequencies aren't sent over distance and that clocks on 
different boards can be different multiple of the reference.


Gordon.

On 20/01/2020 00:29, José Luis Artuch wrote:

Hi Frederik,

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.

I think it would be most convenient to build a single oscillator for
all audio boards.
Regards.
José Luis



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




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


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread José Luis Artuch
Hi Frederik,
> 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.
I think it would be most convenient to build a single oscillator for
all audio boards.
Regards.
José Luis



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


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread Jürgen Gluch
Dear Ralf,

thanks for your opinion. I also looked to the different scenarios for the
sound setup in my home and I agree that there are different approaches. IMO
all have pro/cons, there is no gold standard.

You propose a decentralized system with gadgets distributed in every room.
The individual end-stations would need to be kinda smart to announce
themselves to a kind of multi-room network, need something to synchronize
themselves to the other zones and probably could only play 1 source at the
time.

My setup is centralized, with all the hardware except the speakers located
in a cabinet. Every user can choose within the software MPD what music
plays where (from local database, web radio and know also spotify). All
music is in perfect sync. I can distribute additional sounds (door bell,
announcements) on top to every active zone. Switching zones without
limitation and independent of users (every family member can control with
own mobile phone) is something that no decentralized can accomplish from
within one app. Also the sound does not break down if any control client
disconnects.

Audio output only stops if the central server stops - and this is true for
both scenarios! Your setup would not distribute the local web radios, my
setup would not distribute the analogue audio... where is the difference?

I dislike the wireless solutions (Blutooth, Wifi) to distribute music.
Further I don't want to invest money in a closed hard/software eco system
(e.g. like Sonos, Russound). Who knows how support and replacement is in
some years...  Open decentralized solutions (often based on RPi) are much
more failure-prone and worse in sound quality than my setup, I think.

Further you emphasize "consumer grade" a lot - yes I am a consumer, the
setup is not meant to be a professional grade music studio or concert
location. I want to be able to play music in my home in multiple rooms with
a little more comfort - sometimes in sync (mostly party background music),
but often each family member takes it own audio to the own location.

So, I don't see your point...
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread Ralf Mardorf
On Sat, 18 Jan 2020 21:53:23 +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.

An off-topic side note:

IMO this is an odd approach. Hard wiring 4 amps in 4 different rooms
with obviously consumer grade audio devices of one machine, gains
absolutely nothing over 4 completely independent audio setups, each for
one room. Apart from the issue you are experiencing now, that probably
is solvable, the main issue is, that if the one machine gets damaged,
audio for 4 rooms doesn't work anymore. IMO the better approach would
be to allow access to a server data base of audio files and links to
web radio stations, but to have separated audio systems for each room.

For consumer grade audio quality smart phones and the wall mounted
tablet PC, accessing the server to get audio files and web radio links,
but connecting directly via e.g. bluetooth to an audio system in a
particular room, is way better, since less failure-prone.

It would be different, if one machine has got an expensive professional
garde audio device and 4 rooms should benefit from the highly graded
audio quality.

Your way IMO is making something very simple way to complicated. I
dislike the smart home approach, that usually isn't anything but
smart, but just asking for trouble.


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


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread Jürgen Gluch
Dear Frederick, dear Jerome,

Thank you for the valuable input. It contained the right buzz words to
enable me to find the solution in the internet [see 1].
Indeed, pulsaudio provides a usable sink and is already running. I did not
install/modify anything in my system.

with the command:
 pacmd list-sources | grep name
I get my device name to use:
alsa_output.pci-_00_03.0.hdmi-stereo.monitor

This is used by a streaming software, for now I followed Dimitry's example
and used VLC:
cvlc -vvv pulse://alsa_output.pci-_00_03.0.hdmi-stereo.monitor --sout
'#transcode{acodec=mpga,ab=128,channels=2}:standard{access=http,dst=localhost:8005/spotify.mp3}'

My MPD plays back the stream from http://localhost:8005/spotify.mp3
On my setup I experience a delay of ~2seconds between an action at spotify
app and heard speaker output. This is OK for me, because all four zone
outputs are in perfect sync and will be like this.

CU
Jürgen

[1] https://sandalov.org/blog/1441/
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread frederik

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






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




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


Re: [Alsa-user] How to redirect audio to a stream (e.g. as input for mpd)

2020-01-19 Thread Bardot Jérôme
On 18/01/2020 21:53, 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.
> 
You can use icecast to create a webradio can be use by mpd in a .m3u file

ie :

#EXTM3U
#EXTVLCOPT:network-caching=1
http://stream-uk1.radioparadise.com/rp_192.ogg

after that you "only" need a way to start the diffusion (webradio)
and/or the play on rooms.

by the way if you find how to redirect sound i m interessted too


> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/alsa-user
> 



0x053A41EF03878A98.asc
Description: application/pgp-keys


signature.asc
Description: OpenPGP digital signature
___
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user