Bug 105806 - module-ladspa-sink: How can I use run_adding?
Summary: module-ladspa-sink: How can I use run_adding?
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: modules (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium enhancement
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-03-29 12:39 UTC by ovvv
Modified: 2018-07-30 10:34 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
patch for run_adding (5.15 KB, patch)
2018-03-29 12:39 UTC, ovvv
Details | Splinter Review
attempted wetness (3.55 KB, patch)
2018-04-01 11:11 UTC, ovvv
Details | Splinter Review

Description ovvv 2018-03-29 12:39:57 UTC
Created attachment 138417 [details] [review]
patch for run_adding

The run_adding function provided by some LADSPA plugins can be used to add the plugin output scaled with a specified gain instead of using its output directly.
So you can use it to specify the wet/dry level, can't you?

I've tried to implement it to module-ladspa-sink. The patch is in the attachment.

When I tested it with the glame butterworth lowpass filter (butterworth_1902.so from swh plugins), the debug message telling the configured gain appeared. However, run_adding didn't work, I've set run_adding_gain to 0.1 and 10, the output was the same both times, as though run instead of run_adding was used.
I've also tried setting the gain directly before run_adding is executed: https://pastebin.com/mj3tBgaB
But it didn't change anything.
Comment 1 Tanu Kaskinen 2018-03-30 05:14:53 UTC
I'm not familiar with run_adding(), except for what I just read from ladspa.h, and yes, it looks like it could be used for controlling the wet/dry level, kind of, but it's not very good for that purpose, because the dry signal will always play at 100% volume and the wet signal is just added to it.

I don't know why you don't hear any difference between run() and run_adding(). Maybe the filter that you tried doesn't implement run_adding() correctly?
Comment 2 Tanu Kaskinen 2018-03-30 05:18:14 UTC
Now I realized that you don't copy the input data to the output buffers before you call run_adding(). That means that the output is added to silent buffers, which is indistinguishable from using run(). run_adding_gain should have effect on the output volume, though.
Comment 3 ovvv 2018-03-30 16:10:39 UTC
I think using run_adding for the wet/dry level works well because merging the input and output is done by the plugin directly. Currently I'm merging them using module-loopback, but there're latency problems and probably redundant resampling: https://bugs.freedesktop.org/show_bug.cgi?id=105504

There's the (probably generated) source code of the lowpass filter: https://pastebin.com/tGynMJ1v
If I understand it correctly, a buffer_write function is defined differently for run and run adding.

I've got the same volume with run_adding_gain set to 0.1 and 10 for any reason.
Comment 4 ovvv 2018-04-01 11:11:48 UTC
Created attachment 138473 [details] [review]
attempted wetness
Comment 5 ovvv 2018-04-01 11:22:58 UTC
To find out how to copy the input samples to the output, I tried to add a simple "wet" parameter, see the attached patch. I thought after calling run I can simply copy the input arrays contents into the output arrays assuming input_count is the same as output_count and the cth input array belongs to the cth output array. But it didn't work: Regardless the wet value, it always sounded completely wet. Instead of mixing it with input, a time delay was added when playing sound.

How can I copy the input to the output?
Comment 6 Tanu Kaskinen 2018-04-02 11:08:49 UTC
Maybe the problem is that u->input and u->output are actually the same array? If LADSPA_IS_INPLACE_BROKEN() returns false, then they are the same array.
Comment 7 ovvv 2018-04-21 12:50:38 UTC
I've tested it with the noise.so ladspa plugin: 
pactl load-module module-ladspa-sink sink_master=0 sink_name=myt plugin=/usr/lib/ladspa/noise.so label=noise_white control=1 run_adding_gain=0.0001 && pacmd set-default-sink myt
When using run_adding, it did not sound like white noise but like some noise starting over and over. When playing some music, it is not added to the strange sound. It sounds different if I change the run_adding_gain or play music.
Comment 8 GitLab Migration User 2018-07-30 10:34:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/516.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.