Pipe audio-in to fifo

Moderator: flatmax

Post Reply
aHelding
Posts: 5
Joined: Sun Sep 18, 2016 10:32 pm

Pipe audio-in to fifo

Post by aHelding » Sat Jan 14, 2017 7:52 pm

Hi,

I'm playing around with Snapcast (https://github.com/badaix/snapcast), which works pretty well (while running wired - for some reason through wireless everything freezes up). However, I would like to route the input from one AI-enabled RPI, to it's own snapcast server through a fifo. The overall goal is to send the input of one RPI to multiple other RPIs for playback. Basically I trying to achieve this chain: Alsa in -> fifo -> snapcast server -> network -> snapcast client -> alsa out. Is this possible?

Have a great weekend

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Pipe audio-in to fifo

Post by flatmax » Wed Jan 18, 2017 7:18 pm

Snapcast look great !

Hmmm, let me try to understand what you want to do. You want to play loopback over localhost through snapcast to make sure the local playback is synchronised with the other snapcast clients ?

I am a little confused as to what file format you need on the /tmp/snapfifo pipe ?
I would imagine that you would want to do something like arecord and have it write to the fifo ? However it seems that snapcast does the codec work for you ?

I notice that they give you a sample asoundrc file for fifo writing ... have you tried this ?

Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

aHelding
Posts: 5
Joined: Sun Sep 18, 2016 10:32 pm

Re: Pipe audio-in to fifo

Post by aHelding » Thu Jan 26, 2017 4:29 am

To clarify, my setup is as follows: Two RPI3s with the audioinjector HAT. One runs both a Snapcast server and a Snapcast client (let's call this one A). The other runs only a Snapcast client (let's call this one B).

I can run a Snapcast server on A with a loopback (using the asoundrc file as provided one the Snapcast git). Playing a sound file with aplay on A, syncs audio playback on the Snapcast clients of both A and B. Furthermore I can run the server on A, utilising shairport-sync to 'airplay' music from my PC to the server on A, resulting in sync'ed audio on both Snapcast clients (A & B) (https://github.com/badaix/snapcast/blob ... md#airplay).

This all works relativly well, but I would like to be able to connect an external device (say an MP3 player), through the input RCAs on the audioinjector of RPI A, and have playback synced on both Snapcast client (A & B). To do this, I would expect I have to pipe the input (from arecord) directly to a fifo, and use this fifo as the input for the Snapcast server running on device A. The setup would resemble the approach exemplified in the Alsa asoundrc example provided by Snapcast (https://github.com/badaix/snapcast/blob ... up.md#alsa), routing the input to the fifo instead of the output.

As for the file format on the snapfifo, the example they give (in the above mentioned asoundrc example) they use a 'raw' format.

Just to clarify: I'm new to Linux and evenmore to this (low level) configuration, so I might have gotten some concepts mixed up!

bklebke
Posts: 6
Joined: Thu Sep 29, 2016 11:55 pm

Re: Pipe audio-in to fifo

Post by bklebke » Sun Feb 26, 2017 6:16 am

So this would be super helpful if I could jump in and leanr as well. I'm using a slightly different solution to output to receivers of various kinds (chromecast, airplay, etc) and dealing with a bit of asynchronicity. My application is I want to pipe in analog audio and then stream to the various digital clients.

I have an application that does this and takes PCM16 fifo, and does the transcoding work for me.

If I use arecord to feed a fifo pipe, does that "save" the line in as it's played, with the result being a steadily growing file? Like, if I left it running for enough time wouldn't it create a file large enough to crash the Raspberry Pi?

Ideally I'd like to use something akin to the "monitoring" function in a DAW: pass the audio into the pipe as PCM16 but don't save it. How do I do this, if it isn't done already automatically by arecord?

bklebke
Posts: 6
Joined: Thu Sep 29, 2016 11:55 pm

Re: Pipe audio-in to fifo

Post by bklebke » Sun Feb 26, 2017 6:48 am

Dope -- just answered my own question (mostly!). arecord into a pipe created with mkfifo works (pretty) well, but there are all kinds of buffer overruns an whatnot that get in the way of actual listening. Is there a way to increase the buffer size of the pipe?

Edit: answered my own question, the problem is due to wifi intermittency and how the itunes server was constructed. Plugged into ethernet and works like a dream. Thanks AudioInjector!

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests