Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate URI breaking LV2 compilation, fix broken cmake config for packaging #1

Merged
merged 3 commits into from
Feb 25, 2024

Conversation

pallaswept
Copy link

Thanks for the SIMD upgrade, very nice! Perhaps I can give a little something back.

You can't use the same URI for two different plugins:

> lv2ls
lilv_world_add_plugin(): warning: Duplicate plugin <https://github.com/werman/noise-suppression-for-voice>
lilv_world_add_plugin(): warning: ... found in file:///usr/lib64/lv2/rnnoise_mono.lv2/
lilv_world_add_plugin(): warning: ... and      file:///usr/lib64/lv2/rnnoise_stereo.lv2/ (ignored)

There may be more fancy ways to deal with this, but I tried to stay as close to your upstream as possible, keep it simple, effective, and minimal in change. This just adds an anchor to the URI, (ie, https://github.com/werman/noise-suppression-for-voice - for both plugins, which fails - becomes https://github.com/werman/noise-suppression-for-voice#1 for mono and https://github.com/werman/noise-suppression-for-voice#2 for stereo). The anchor doesn't actually exist in the URL, this has no ill effect on the plugin at all, the page still loads fine if you try to load it, but it does give the mono and stereo plugins different URIs, so they can both load, and that means the stereo LV2 plugin is actually available, which, without this change, it isn't.

You can't use the same URI for two different plugins

lv2ls
lilv_world_add_plugin(): warning: Duplicate plugin <https://github.com/werman/noise-suppression-for-voice>
lilv_world_add_plugin(): warning: ... found in file:///usr/lib64/lv2/rnnoise_mono.lv2/
lilv_world_add_plugin(): warning: ... and      file:///usr/lib64/lv2/rnnoise_stereo.lv2/ (ignored)
@pallaswept
Copy link
Author

See also: werman#158 and werman#170

Don't use march=native/mtune=native because we might be building on a different system to the one we execute on (eg: packaging). User can set arch/tune flags as appropriate.
@pallaswept
Copy link
Author

I see github has automatically included another change I made but had intended to upstream separately (annoying, but it's there now....) - removing the compiler flags to build for the native CPU. This is a nice idea if we are building on the machine we will run on, but breaks the plugin for packaging, since it will tune for the packaging server's CPU, and possibly won't run on the CPU of people installing that package.

Users can set the flags by export CFLAGS=-march<whatever is appropriate> as needed, before the build. In the case of packaging, that means not doing that at all, in the case of running it on the local machine, that means -march=native, in the case of a guy on an AMD machine building it for his intel machine, that might mean -march=skylake or whatever.

@pallaswept pallaswept changed the title Fix duplicate URI breaking LV2 compilation Fix duplicate URI breaking LV2 compilation, fix broken cmake config for packaging Dec 17, 2023
Updating the docs to reflect the changes made to remove march=native from the cmake scripts.
@pallaswept
Copy link
Author

pallaswept commented Dec 17, 2023

Updated the readme since github automagically rolled these changes together, I'd better document it.

@JellyBrick JellyBrick added the enhancement New feature or request label Feb 25, 2024
@JellyBrick
Copy link
Owner

Thank you for your contribution!
Sorry for the delay in the review.

@JellyBrick JellyBrick merged commit b67178f into JellyBrick:master Feb 25, 2024
@Konfekt
Copy link

Konfekt commented Feb 25, 2024

Thank you very much for the new binaries. Somehow this new .so file, in contrast to the original cannot be found by pipewire:

[E][91647.063495] default      | [ ladspa_plugin.c:  272 load_ladspa_plugin()] failed to load plugin '/home/konfekt/.config/pipewire/lib/ladspa/librnnoise_ladspa.so': File or directory does not exist

@pallaswept
Copy link
Author

File or directory does not exist

It seems you have installed the new version to a different location

Pipewire's configuration searches for the provided name, appends .so, and searches the ladspa plugin path (the LADSPA_PATH environment variable, or defaults to /usr/lib64/ladspa). In your error message, it's saying /home/konfekt/.config/pipewire/lib/ladspa/ so likely, you've set that as your ladspa plugin path, and need to install the new binary there. Perhaps, you're using an unsupported method to locate the library (specifying the full path) which, good luck with that :D since it's undocumented I can't tell you what will work, but I guess you'll just need to adjust the path in the config files to point to the new installation location.

@Konfekt
Copy link

Konfekt commented Feb 26, 2024

Thank you @pallaswept. The configuration path did not change from that of the original .so and /home/konfekt/.config/pipewire/pipewire.conf.d/99-input-denoising.conf read

context.modules = [
{   name = libpipewire-module-filter-chain
    args = {
        node.description =  "Noise Canceling source"
        media.name =  "Noise Canceling source"
        filter.graph = {
            nodes = [
                {
                    type = ladspa
                    name = rnnoise
                    plugin = /home/konfekt/.config/pipewire/lib/ladspa/librnnoise_ladspa.so
                    label = noise_suppressor_mono
                    control = {
                        "VAD Threshold (%)" = 50.0
                        "VAD Grace Period (ms)" = 200
                        "Retroactive VAD Grace (ms)" = 0
                    }
                }
            ]
        }
        capture.props = {
            node.name =  "capture.rnnoise_source"
            node.passive = true
            audio.rate = 48000
        }
        playback.props = {
            node.name =  "rnnoise_source"
            media.class = Audio/Source
            audio.rate = 48000
        }
    }
}
]

To be sure, there's also export LADSPA_PATH="libdir/ladspa:/usr/local/lib64/ladspa:/usr/lib64/ladspa:${XDG_CONFIG_HOME}/pipewire/lib/ladspa" in ~/.profile, but moving the .so file into /usr/lib64/ladspa and removing the full path in

                    plugin = librnnoise_ladspa.so

results in the same no file found error.

In any event, it works fine with the original .so file as I've just been following the original setup instructions, so that error is not very indicative.

@pallaswept
Copy link
Author

Thank you @pallaswept. The configuration path did not change from that of the original .so and /home/konfekt/.config/pipewire/pipewire.conf.d/99-input-denoising.conf read

This implies that the file's location changed.

but moving the .so file into /usr/lib64/ladspa and removing the full path in

                    plugin = librnnoise_ladspa.so

results in the same no file found error.

This is still invalid syntax I'm sorry! you want

                     plugin = librnnoise_ladspa

Pipewire will append the ".so" for you, then search the ladspa plugin path.

This new code definitely builds and runs without error here when following upstream documentation for locating the file, as per the above. In spite of this being my fix for lv2, I'm using the ladspa version still, since I've found it to have a smaller buffer requirement of pipewire. I expect that it will work by using the full path, if the file exists at that location, but I can't say for sure, because I've not tried it, and the doc doesn't mention it.

In any event, it works fine with the original .so file as I've just been following the original setup instructions, so that error is not very indicative.

It suggests that the .so file is not present in that same location. I don't see any need to modify your configuration, if it works, you should just be able to replace the .so file, and it should continue to work.

Perhaps you can use listplugins | grep -i noise to help you troubleshoot?

@Konfekt
Copy link

Konfekt commented Feb 27, 2024

Thank you. Somehow this .so file is not recognized by pipewire (Compiled and Linked with libpipewire 0.3.64): with this .so file as /usr/local/lib64/ladspa/librnnoise_ladspa.so:

$ listplugins | grep -i noise                                                   ~
/usr/lib64/ladspa/noise.so:
	White Noise Source (1050/noise_white)
	Noise Source (White) (1069/noise_source_white)
	Pink Noise (Interpolated) (1841/pink_interpolated_audio)
	Pink Noise (full frequency range) (1844/pink_full_frequency)
	Pink Noise (sample and hold) (1843/pink_sh)
/usr/lib64/ladspa/tap_pinknoise.so:
	TAP Pink/Fractal Noise (2155/tap_pinknoise)

With the original one:

$ listplugins | grep -i noise                                                   ~
/usr/local/lib64/ladspa/librnnoise_ladspa.so:
	Noise Suppressor for Voice (Mono) (9354877/noise_suppressor_mono)
	Noise Suppressor for Voice (Stereo) (9354877/noise_suppressor_stereo)
/usr/lib64/ladspa/noise.so:
	White Noise Source (1050/noise_white)
	Noise Source (White) (1069/noise_source_white)
	Pink Noise (Interpolated) (1841/pink_interpolated_audio)
	Pink Noise (full frequency range) (1844/pink_full_frequency)
	Pink Noise (sample and hold) (1843/pink_sh)
/usr/lib64/ladspa/tap_pinknoise.so:
	TAP Pink/Fractal Noise (2155/tap_pinknoise)

@pallaswept
Copy link
Author

Thank you. Somehow this .so file is not recognized by pipewire

That listplugins tool is part of the ladspa SDK so something might be wrong with the file (ie corruption of the local copy of the file?) if it's not working there.

This output was obtained with a copy of that build you linked above.

analyseplugin ~/Downloads/linux-rnnoise/ladspa/librnnoise_ladspa.so 

Plugin Name: "Noise Suppressor for Voice (Mono)"
Plugin Label: "noise_suppressor_mono"
Plugin Unique ID: 9354877
Maker: "werman"
Copyright: "GPL v3"
Must Run Real-Time: Yes
Has activate() Function: No
Has deactivate() Function: No
Has run_adding() Function: No
Environment: Normal
Ports:  "Input" input, audio
        "Output" output, audio
        "VAD Threshold (%)" input, control, 0 to 99, default 49.5, integer
        "VAD Grace Period (ms)" input, control, 0 to 1000, default 500, integer
        "Retroactive VAD Grace (ms)" input, control, 0 to 200, default 100, integer
        "Placeholder" input, control
        "Placeholder" input, control

Plugin Name: "Noise Suppressor for Voice (Stereo)"
Plugin Label: "noise_suppressor_stereo"
Plugin Unique ID: 9354877
Maker: "werman"
Copyright: "GPL v3"
Must Run Real-Time: Yes
Has activate() Function: No
Has deactivate() Function: No
Has run_adding() Function: No
Environment: Normal
Ports:  "Input (L)" input, audio
        "Input (R)" input, audio
        "Output (L)" output, audio
        "Output (R)" output, audio
        "VAD Threshold (%)" input, control, 0 to 99, default 49.5, integer
        "VAD Grace Period (ms)" input, control, 0 to 1000, default 500, integer
        "Retroactive VAD Grace (ms)" input, control, 0 to 200, default 100, integer
        "Placeholder" input, control
        "Placeholder" input, control

My MD5 sum for that .so file is ac408362622c490d0b8914a96a106784 and for the whole linux zip archive from the github actions job f83a22673a25dba7965f3ad1bd3f1c3d

@Konfekt
Copy link

Konfekt commented Feb 27, 2024

I can confirm these md5 hashes:

~/.config/pipewire/lib/ladspa> md5sum librnnoise_ladspa.so      
ac408362622c490d0b8914a96a106784  librnnoise_ladspa.so

λ › md5sum linux-rnnoise.zip                                            ~/Downloads
f83a22673a25dba7965f3ad1bd3f1c3d  linux-rnnoise.zip

Maybe it has to do with an Ubuntu build not being recognized on Opensuse?

@Konfekt
Copy link

Konfekt commented Feb 27, 2024

Thank you and sorry for taking your time, it is this common libc dependency issue:

λ › analyseplugin ./librnnoise_ladspa.so.simd                     lib/ladspa master
Failed to load plugin "./librnnoise_ladspa.so.simd": /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./librnnoise_ladspa.so.simd)

versus

λ › analyseplugin ./librnnoise_ladspa.so.orig                     lib/ladspa master

Plugin Name: "Noise Suppressor for Voice (Mono)"
Plugin Label: "noise_suppressor_mono"
Plugin Unique ID: 9354877
Maker: "werman"
Copyright: "GPL v3"
Must Run Real-Time: Yes
Has activate() Function: No
Has deactivate() Function: No
Has run_adding() Function: No
Environment: Normal
Ports:	"Input" input, audio
	"Output" output, audio
	"VAD Threshold (%)" input, control, 0 to 99, default 49.5, integer
	"VAD Grace Period (ms)" input, control, 0 to 1000, default 500, integer
	"Retroactive VAD Grace (ms)" input, control, 0 to 200, default 100, integer
	"Placeholder" input, control
	"Placeholder" input, control

Plugin Name: "Noise Suppressor for Voice (Stereo)"
Plugin Label: "noise_suppressor_stereo"
Plugin Unique ID: 9354877
Maker: "werman"
Copyright: "GPL v3"
Must Run Real-Time: Yes
Has activate() Function: No
Has deactivate() Function: No
Has run_adding() Function: No
Environment: Normal
Ports:	"Input (L)" input, audio
	"Input (R)" input, audio
	"Output (L)" output, audio
	"Output (R)" output, audio
	"VAD Threshold (%)" input, control, 0 to 99, default 49.5, integer
	"VAD Grace Period (ms)" input, control, 0 to 1000, default 500, integer
	"Retroactive VAD Grace (ms)" input, control, 0 to 200, default 100, integer
	"Placeholder" input, control
	"Placeholder" input, control

It does not tell which libc version the original file was linked to. I suspect it to be 2.31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants