[darkice] Re: PulseAudio to Darkice

  • From: Daniel Eckl <daniel.eckl@xxxxxxxxx>
  • To: darkice@xxxxxxxxxxxxx
  • Date: Wed, 22 Mar 2017 18:34:56 +0100

Ping to the list: Darkice from raspbian repositories is not compiled with
pulseaudio support. I assist Joel now with self-compiling darkice with PA
support :) But I think that's not of interest for the list.

Regards,
Daniel

2017-03-21 17:25 GMT+01:00 <24@xxxxxxxxxxxxx>:

Hi Daniel,

 I am not sure what you mean by "Is your darkice really compiled with
pulseaudio support?" I started with the latest Raspbian image that had
pulseaudio included in the image. I did not install pulseaudio separately.
I then installed darkice on this latest Raspbian image. I then added the
compressor and limiter to the existing pulseaudio that came with the
Raspbian.

 If I did this wrong please let me know.

 The thing about using device = pulseaudio, could I have had gotten the
"Unknown PCM pulseaudio" error with
the options in pavucontrol set incorrectly? I was going to try using
device = pulseaudio and paSourceName = default then play with the
configuration in pavucontrol. Also I did not have paSourceName = default
when I got the "Unknown PCM pulseaudio" error.

 I will let you know what I find out.

Daniel, I really appreciate your support.

Joel Goodwin


---- Daniel Eckl <daniel.eckl@xxxxxxxxx> wrote:
After one night of sleep I thought about your darkice error messages and
the device configuration types you tried already. I now realised that you
already tried device=pulseaudio. I think that should have worked, at
least
it does for me. So I thought about other reasons why this connection
might
fail.

One possibility is: Is your darkice really compiled with pulseaudio
support? If not, then all your tries with device=pulseaudio will fail.
Alsa
has a pulse plugin where an application can connect via alsa which is
then
sent to pulseaudio. My suggestion: avoid that whenever possible. Just
another layer with possibilities for delays, buffer issues and weirdness.

Another possibility: If your darkice has pulseaudio support, then you
have
to make sure, it is allowed to connect to pulseaudio daemon. Since this
automatically works through cookies in $HOME/.config/pulse, the easiest
way
is to start pulseaudio from the same user as darkice afterwards. Then it
should "just work". There are possibilities to use a system daemon
pulseaudio running as root, but it makes things complicated. If you need
to
fight with that, pulseaudio client libraries can be controlled with some
environment variables to tell it where it finds the pulseaudio socket and
stuff.

Regards,
Daniel

Am 20.03.2017 22:23 schrieb "Daniel Eckl" <daniel.eckl@xxxxxxxxx>:

Hi Joel,

let's see what I can come up with. First: You are right, you want to
have
pulseaudio to get exclusive access to your soundcard using alsa. Every
other application afterwards has to connect to pulseaudio to
send/receive
audio. So be sure to make this work first. Your pulseaudio is working,
you
already see the audio from (i guess) line-in at the "input devices"
tab of
pavucontrol. That's good. That "input" is called a "source" in
pulseaudio
wording.

Let's first try to make it work without compressor.

This input section in darkice.conf should connect darkice to
pulseaudio no
matter how your source is named. It may connect to the wrong source,
but
nevermind at the beginning:

[input]
device = pulseaudio
paSourceName = default
sampleRate = 44100
bitsPerSample = 16
channel = 2

When you start darkice you now should see it in your "Recording" tab of
pavucontrol. Check if it uses the right source and if not, just switch
it
to the right one. Now you should have the status quo again, just with
pulseaudio as your center piece.

Now we take care of the compressor. First you have to have the needed
ladspa plugins installed. On Ubuntu this is the package "swh-plugins".
Then
I guess in the end you want the setup to be scripted, so we now go to
console.

Pulseaudio now has the module called "ladspa-sink". As the module
says, it
is a sink, like an output device. You can play something to it. I
know, you
have no player, but an input stream. We solve that later.

We now build a little audio chain, and we build it from end to start.
First I create a null sink. This is a virtual output "device" that
takes
ausio and discards it. Simply useless, right? Well, wait :)

# pactl load-module module-null-sink sink_name=nullstream

Now we create a ladspa-sink that can receive audio, runs the compressor
over it and sends it to the null sink

# pactl load-module module-ladspa-sink sink_name=ladspa_compressor
master=nullstream plugin=dyson_compress_1403 label=dysonCompress
control=0,1,0.5,0.99

Now we want a ladspa limiter running before the compressor. So we
create
another sink receiving audio, running the limiter over it and sending
it to
the compressor:

# pactl load-module module-ladspa-sink sink_name=ladspa_limiter
master=ladspa_compressor plugin=fast_lookahead_limiter_1913
label=fastLookaheadLimiter control=10,0,0.8

So now we can send audio to the Limiter, this sends the audio to the
compressor and that send the audio to the null sink that discards it.

Now we want the audio from the line-in souce to be sent to the limiter.
For that we use the "loopback" module. It takes audio from a source and
sends it to a sink. But we need to be able to exactly tell it which
source
he need to use.

# pactl list sources short

For me the output looks like this (probably scrambled by email
representation):


0       alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor
       module-alsa-card.c      s16le 2ch 44100Hz   RUNNING
1       alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
     module-alsa-card.c      s16le 2ch 44100Hz   RUNNING
2       alsa_input.pci-0000_00_1b.0.analog-stereo
      module-alsa-card.c      s16le 2ch 44100Hz  RUNNING

The first 2 sources with their names containing "output" and ending
with
".monitor" are irrelevant for you now. There you can "wiretap" sound
that
is being played to this device (pulseaudio calls that "sink"). We want
the
real input. In my case it's the last line, this is the line-in of my
built-in soundcard. So for me the source is
"alsa_input.pci-0000_00_1b.0.
analog-stereo"

So the loopback looks this way for me (you use your real source):

#  pactl load-module module-loopback source=alsa_input.pci-0000_00_
1b.0.analog-stereo
sink=ladspa_limiter

Great, the audio flows from source to limiter to compressor to
nullstream
and... is gone.

Now we remember the ".monitor" sources. Every sink has a ".monitor"
source
where we can wiretap what's being played there. And that's where we
attach
darkice now, to the monitor of our nullstream. Change the input config
to:

paSourceName = nullstream.monitor

and voila, that should do the trick. Hopefully I did no critical
typos...
:D

If that works, then persistence the setup by putting the pactl lines to
your config. Either you do that system-wide in /etc/pulse/default.pa
or -
better - only for this streaming user in $HOME/.config/pulse/
default.pa.
Copy the one from /etc as a template. Add the pactl lines to the
bottom of
that file, just delete the "pactl" at the line beginning. Something
like:

load-module module-null-sink sink_name=nullstream
load-module module-ladspa-sink sink_name=ladspa_compressor
master=nullstream plugin=dyson_compress_1403 label=dysonCompress
control=0,1,0.5,0.99
load-module module-ladspa-sink sink_name=ladspa_limiter
master=ladspa_compressor plugin=fast_lookahead_limiter_1913
label=fastLookaheadLimiter control=10,0,0.8
load-module module-loopback source=alsa_input.pci-0000_00_
1b.0.analog-stereo
sink=ladspa_limiter

Phew, thank god you have to do this only once :D

Let me know if that worked!

Regards,
Daniel

2017-03-20 19:16 GMT+01:00 <24@xxxxxxxxxxxxx>:

Hello Darkice enthuses,

 Long time Darkice user trying to expand features to use with
Darkice. My
goal is to add a Dyson compressor via PulseAudio to the Darkice
stream. So
my specific question has to do with getting Darkice to sink a
PulseAudio
output. The errors I am getting are: ALSA lib
pulse.C:243:(pulse_connect)
PulseAudio: Unable to connect: Connection refused and DarkIce:
Darkice.cpp:1187: can't open connector

 I am starting with a system that has the darkice.cfg file using:
device
= hw:1,0
and the system takes the source from the sound card I am using and
provides it to the Darkice application and the stream is working.

 Next I start PulseAudio with: pulseaudio --start

 I try to run darkice again and it won't run because Pulse audio took
control of the source. This is OK I think

 Running pavucontrol and looking under the Input devices tab, I can
see
the VU meter moving in sync with the audio I generate with a local
microphone. So I know PulseAudio is receiving the source from the
sound
card.

 What I have tried has been different ways to express "device" in the
darkice.cfg file and adjustments using the pavucontrol for the
PulseAudio
configuration.

Different ways I have tried to define PulseAudio as the source for
Darkice in the darkice.cfg file that have not worked.

1.  device = default

2.  device = pulse                     #On the Ubuntu manpages for
darkice.cfg, it says to use "pulseaudio" for the device.
                                       #If you use that you will get
this
error: Unknown PCM pulseaudio

3.  device = pulse
    paSourceName = 4

4.  device = pulse
    paSourceName = default

5.  device = pulse
    paSourceName = bmc2835 ALSA

6.  device = /dev/dsp                  #Then use: sudo padsp darkice
to
start Darkice

Another way to word my problem is: I am getting input to PulsAudio and
want to know how to get Darkice to use this available PulseAudio
signal for
streaming.

Any suggestions would be appreciate. Thank-you for your support!


Joel Goodwin


Hardware configuration: Cirrus Logic sound card, Raspberry Pi 3

Sofrware: Darkice-1.3 and PulseAudio(The version that came with
Raspbian)
running on Raspbian Jessie with PIXEL 2017-03-02









Other related posts: