[pulseaudio-discuss] Virtual sink to pipe audio stream to STDIN of shell-command?
Rene Bartsch
rene at bartschnet.de
Sun Aug 2 02:23:53 PDT 2015
Am 2015-08-02 03:11, schrieb Alexander E. Patrakov:
> 02.08.2015 01:17, Rene Bartsch wrote:
>> Hi,
>>
>> with
>>
>> load-module module-pipe-sink format=s32le rate=96000 channels=8
>> channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right
>> sink_name=brutefir.FCA610 file=/tmp/brutefir.FCA610
>> sink_properties='device.description="BruteFIR Behringer FCA610"'
>>
>> a virtual sink can be created which pipes audio streams to a FIFO. The
>> drawback is that an external script has to start external processing
>> of
>> the audio stream.
>>
>> Is there any way to call a shell command from Pulseaudio and route a
>> virtual sink to STDIN of that shell-command?
>
> No. But as this question is really about brutefir, not any arbitrary
> program, here is an alternative way to start it. The drawback is that
> it will not work after logging out and logging in again.
>
> Install JACK.
>
> In /etc/environment, put one line:
>
> JACK_START_SERVER=1
>
> In /home/user/.jackdrc, put one line:
>
> /home/user/.jack_session.sh
>
> In /home/user/.jack_session.sh, put this script, make it executable:
>
> #!/bin/sh
> jackd -r -d alsa -d hw:PCUSB -s -r 44100 -p 256 &
> ( sleep 4 ; brutefir ) &
>
> In /home/user/brutefir_config, put (in this example, a separate filter
> is applied to each channel for room-correction purposes):
>
> sampling_rate: 44100;
> #show_progress: false;
> filter_length: 1024,64;
> convolver_config: "/home/user/.brutefir_wisdom";
>
> coeff "left" {
> filename: "/home/user/.filter-left.pcm";
> format: "FLOAT_LE";
> };
>
> coeff "right" {
> filename: "/home/user/.filter-right.pcm";
> format: "FLOAT_LE";
> };
>
> input "i_left", "i_right" {
> device: "jack" { ports: "pulseaudio:front-left",
> "pulseaudio:front-right"; };
> channels: 2;
> sample: "AUTO";
> };
>
> output "o_left", "o_right" {
> device: "jack" { ports: "alsa_pcm:playback_1",
> "alsa_pcm:playback_2"; };
> channels: 2;
> sample: "AUTO";
> };
>
> filter "f_left" {
> inputs: "i_left"/9;
> outputs: "o_left";
> process: 0;
> coeff: "left";
> };
>
> filter "f_right" {
> inputs: "i_right"/9;
> outputs: "o_right";
> process: 0;
> coeff: "right";
> };
>
> Finally, copy /etc/pulse/default.pa to
> /home/user/.config/pulse/default.pa, and add there:
>
> load-module module-jack-sink connect=no client_name=pulseaudio
>
> Also, let me guess: are you trying to emulate virtual 7.1 sound on
> headphones? Then, if your filter is shorter than 64 samples, then
> there is no need to mess with brutefir at all. Just make a
> multichannel wav file with the contributions of each input channel to
> the left output, and provide it to module-virtual-surround-sink. The
> limitation to 64 samples can be easily patched out from
> module-virtual-surround-sink.
>
> And finally: this is the third request to convolve PulseAudio output
> with something arbitrary. Someone has to sit down and write a native
> replacement for brutefir. Unfortunately, for me, this is not really
> possible, because of the dayjob which keeps me busy 200% of time.
As a first step I suggest a module "module-pipe-shell" derived from
"module-pipe-{source|sink}" which pipes an audio stream through a
shell-command via STDIN/STDOUT. That approach would allow to easily add
any external filter to Pulseaudio without huge overhead/latency. The
module should be configurable in a bidirectional mode (STDIN+STDOUT) to
route an audio stream through a shell-command (BruteFIR supports STDIN
and STDOUT) or an uni-directional mode to record audio from a
shell-command or playback to a shell-command via pipe.
I tried to use "pacat" for that purpose, but it doesn't seem to be
capable to create a virtual sink.
The next step would be to copy the convolver-code of BruteFIR to the
Pulseaudio-Github-repository and interface the code as a module.
--
Best regards,
Renne
More information about the pulseaudio-discuss
mailing list