Sharing the input

Moderator: flatmax

Post Reply
RFH
Posts: 3
Joined: Fri Jun 09, 2017 3:00 am

Sharing the input

Post by RFH » Fri Jun 09, 2017 3:08 am

I'm currently using the card as an audio logger to keep copies of the broadcasts for a small community radio station to satisfy the regulatory requirements. I do this by running a Java program I've written for the purpose.

What I would like to do is to also provide the internet stream from the same machine at the same time as logging the broadcast. There is currently an old machine running XP which does both these tasks and I'd like to be in the position to replace that machine soon.

My problem is that if I try to have two applications accessing the input at the same time then one of them comes up with the resource busy message. Is there any way to have two separate applications both "listening" to the input at the same time? Currently the Pi is using only ALSA as I have found various odd problem in the past when Pulse as installed on different machines.

I've not done much with sound on Linux machines before so any help would be appreciated.

Thanks,
Raymond

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

Re: Sharing the input

Post by flatmax » Sat Jun 10, 2017 9:24 pm

Hey Ramond,

Sounds like a nice project.

There is an ALSA plugin for sharing the input and similarly one for sharing the output. The input sharding plugin name is dsnoop. To use dsnoop, set the ALSA device name to plug:dsnoop. For example
arecord -Dplug:dsnoop fileName.wav

Let us know if this does the trick !
thanks
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

RFH
Posts: 3
Joined: Fri Jun 09, 2017 3:00 am

Re: Sharing the input

Post by RFH » Sun Jun 11, 2017 1:40 am

Thanks for that Matt.

It does work to let two copies of arecord run at the same time but it seems the Java sound routines get at the card differently and so I can't specify
the "plug:dsnoop" as a source in Java.

I've been reading up on the ALSA config options and I'm wondering if it's feasible to make this the default sound input as I think the Java sound routines might pick it up then, although I know from past experiences that Java can be very picky about which combinations of the various sound sexting (bits, rate et al) it thinks are valid!

Raymond

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

Re: Sharing the input

Post by flatmax » Sun Jun 11, 2017 1:03 pm

OK, in this case you can try something like this, note it is untested and will need some debugging, save this as your ~/.asoundrc :

Code: Select all

pcm.!default {
    type asym
    playback.pcm "dmixplug"
    capture.pcm "dsnoopplug"
}

pcm.dmixplug {
  type plug
  slave.pcm "dmix"
}

pcm.dsnoopplug {
  type plug
  slave.pcm "dsnoop"
}
This asoundrc is trying to set dmix at the default playback device and dsnoop as the default capture device.

If this doesn't work and you have to modify it, can you please post back the correct version.
thanks
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

RFH
Posts: 3
Joined: Fri Jun 09, 2017 3:00 am

Re: Sharing the input

Post by RFH » Mon Jun 12, 2017 12:49 am

That was spot on Matt, thanks a lot.

I can now do a "arecord test.wav" while the Java logger is running. I also tried, purely for test purposes, running two copies of the logger at the same time which also work flawlessly.

I need to get some things setup before I can test running the stream along the logger but I can't see why that shouldn't work too now.

Thanks again for your help. It's a very good sound card and I'm pleased it's so easy to get help even when it's not directly related to the card.

Raymond

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

Re: Sharing the input

Post by flatmax » Fri Jun 16, 2017 8:38 am

No worries, glad we could work through stuff successfully.

Could I please ask you to review the sound card here on Amazon ?
https://www.amazon.com/dp/B01HBC8CJ0

That would be very help ful.
Thanks
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

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests