BruteFIR addon for ALSA/PulseAudio

  • Hi all,

    i'd like to introduce you to my addon providing a "BruteFIR" systemd-service with ALSA/PulseAudio support.

    https://github.com/chipfunk/LibreELEC.tv-addon-brutefir

    To realize it i created a new BruteFIR IO-module 'pulse' to allow for direct access to PulseAudio from within BruteFIR (https://github.com/chipfunk/brutefir). I was then able to package it as an addon (together with its dependencies fftw3/fftw3f). Creating startup and shutdown-scripts for the (still required) PulseAudio-modules (module-null-sink for input and module-alsa-sink for output), together with corresponding input-/output-configuration for BruteFIR, allows for a plug-n-play installation.

    This addon features:

    - BruteFIR running as a systemd.service
    - direct PulseAudio support as BFIO-module
    - configurable target device-names to control/hint connectivity for PulseAudio-server
    - PulseAudio-server, application- and stream-name are also configurable, to allow for networked multi-filter/-process/-stream setups (not tested though)

    I didn't test mixing different BruteFIR io-modules (e.g. PulseAudio in, ALSA out) yet, but expect it to work.

    Currently it is performing well, running two 4096-long kernels for my stereo-setup on a Odroid-C2 with 15% to 20% utilization and surviving multiple power-up-/down cycles.

    I was able to build it for all supported targets in LibreELEC 11.0.4.


    A big thank you to all the developers making this possible.


    I'm looking into uploading the binary packages to github, but need some more time todo so.


    I'd be happy to hear your opinions on improvements and/or bug-reports.

    Edited once, last by chipfunk: Fix link (January 9, 2024 at 1:33 PM).

  • Hi chipfunk,

    this sounds very promising!

    I would like to try it, but the link to the addon-brutefir seems to be broken (error 404). Could you please fix it?

    Thank you :)

  • Hi coleb,

    sorry for not getting back to you in a timely manner, somehow i did not receive update-notifications for this thread.

    Thanks for your interest and bug report. The repository was set to private-access, that was giving the 404-error. I made the repository public, so the source-code for the addon should be available here: https://github.com/chipfunk/LibreELEC.tv-addon-brutefir now. The links to the binary packages from this post should be available too.


    Sorry for the hickup, please let me know if you encounter any more problems.

    Edited 2 times, last by chipfunk (February 5, 2024 at 12:04 PM).

  • hello chipfunk,

    thank you very much for fixing the access issue :)

    I downloaded all files and installed everything on my S912 TV Box running LE 11.06.

    I did not yet setup any audio connection (here i have to learn a lot and try to fiddle out the correct setup), but i can confirm that brutefir service is already up and running and the PULSE:Null Output is selectable in the System/Audio Setting.

    So the first steps are done !

    Again, thank you very much and please keep on going :)

    best regards

  • Hey coleb,

    happy to help and hear you made progress, thanks for reporting back :)

    IIRC i made the default setup to pass two channels of Kodi's audio-signal through BruteFIR without filtering to the default ALSA-device. So even if you didn't configure anything yet you should be hearing Kodi's menu-sounds on two channels of ALSA default-device (which is HDMI in my case).

    Good luck and please do not hesitate to ask further questions.

  • yes, i can confirm that after selecting the PULSE:Null Output audio works via HDMI.

    I certainly will come back to you once i'll try to activate my USB-DAC(s) ihave attached to the TV box instead of the HDMI as sink(s) for brutfir output. And setting up a room correction filter will also be on my task list (Euipment is already availabe REW, UMIK, ..).

    Thank you for you kind offer to provide further assistance !

  • yes, i can confirm that after selecting the PULSE:Null Output audio works via HDMI.

    Awesome, you're the first giving me feedback on that, thanks a lot.

    I certainly will come back to you once i'll try to activate my USB-DAC(s) ihave attached to the TV box instead of the HDMI as sink(s) for brutfir output. And setting up a room correction filter will also be on my task list (Euipment is already availabe REW, UMIK, ..).

    Oh nice, multi-device/-stream support, that's a use-case i haven't tried yet :)

    You seem to be proficient in these things, but other might be not, so i'll leave my thoughts about it here. I see two options to achieve it.

    First idea would be to use PulseAudio to control the DACs by` loading the module-alsa-sink multiple times, once per DAC. Appropriate parameters (ALSA-)device and sink_name can be appended here. The given sink_name should then be set in brutefir-config as device: alsa-output.sink_name.

    A second option could be to configure BruteFIR to output to ALSA directly. This should result in a lower latency. For this to work PulseAudio's alsa-module shouldn't be loaded, as your ALSA-device would be blocked by PulseAudio then.

    Looking forward to hear about your experience,

    HTH, good luck :)

  • Hello chipfunk,

    here's a short update.

    Your Brutefir adaptation works great !

    I did the room correction measurement with REW and created suitable filters with REW and RePhase.

    Replacing the "dirac pulse" with the created new filter .txt files did not work at the beginning. No sound. Later i figured out that i missed to set the filter_length in the .brutefir_config in accordance to the selected filter lenght to 65536 (before 1024). Now it works :) :)

    Did not expect to get it working that fast.

    Next i try to get the external DACs to operate with brutefir.

    Kudos to you and all brutefir contributors.

    best regards

  • Hello chipfunk,

    I think i need support in getting the Usb-Dacs to work together with brutefir.

    Could you please give me some advice? The name of the Usb-Dac Alsa Devices are attached below.

    In the first place there is no need to operate brutefir with hdmi and usb-dac, usb-dac and brutefir alone would be perfectly fine.

    So maybe you can advise some concrete modifications of the existing standard hdmi setup?

    thanks in advance

  • Hi coleb,

    that's just the display-names for the audio-devices, not their identifier. Do you have the possibility to SSH into the machine and run

    Code
    aplay -L

    to find the proper device-id? Because that's the prerequisite for further steps. I think its a good idea to stop the BruteFIR-service before doing so.


    After you found the device-id for ALSA you can start editing the file /storage/kodi/addons/brutefir/bin/startup.sh from

    Code
    pactl load-module module-alsa-sink >> $PULSEAUDIO_MODULES_FILE

    to

    Code
    pactl load-module module-alsa-sink device="ALSA_ID" >> $PULSEAUDIO_MODULES_FILE

    to make pulseaudio take control of the device. That should give you a new PulseAudio-sink named alsa_output.ALSA_ID. You can run pactl list-sinks to verify.


    After that the output-section of BruteFIR-config has to point to the new PulseAudio sink, like so

    Code
    output "left", "right" {
           device: "pulse" {
                   device: "alsa_output.ALSA_ID";


    Restarting the service should play your audio on the new device.


    For more options on how to load PulseAudio-modules please see https://www.freedesktop.org/wiki/Software/…cedrivermodules and https://www.freedesktop.org/wiki/Software/…odule-alsa-sink.


    HTH

    Edited 2 times, last by chipfunk (February 10, 2024 at 1:15 PM).

  • It works!

    I added both USB DAC modules (device_id=USB and device_id=Impacto) to the startup.sh script :

    # Provide ALSA output
    pactl load-module module-alsa-sink device_id=Impacto >> $PULSEAUDIO_MODULES_FILE # Impacto
    pactl load-module module-alsa-sink device_id=USB >> $PULSEAUDIO_MODULES_FILE # AudioBox USB
    pactl load-module module-alsa-sink >> $PULSEAUDIO_MODULES_FILE # Hdmi

    now i can switch between the interfaces HDMI, USB Audio DAC and Impacto DAC via .brutefir.config:

    # module and parameters to put audio
    output "left", "right" {
    device: "pulse" {
    # server: ""; # Host to connect to
    app_name: "BruteFIR 1.0o-pulse module"; # This application name
    # device: "alsa_output.default"; # -> select HDMI
    # device: "alsa_output.Impacto.analog-stereo"; # -> select Impacto USB Dac
    device: "alsa_output.USB.analog-stereo"; # - > select Audio Box USB-DAC
    stream_name: "Output of BruteFIR service";
    };
    sample: "S16_LE"; # sample format
    channels: 2/0,1; # number of open channels / which to use
    mute: false,false; # mute active on startup for each channel


    ´Chipfunk, you are my hero !

    Edited 2 times, last by coleb (February 10, 2024 at 7:00 PM).

  • Hi both,

    I stumbled across this thread while looking up how to do room correction in LibreElec. And it seems like the BruteFIR add-on clearly fills a niche for room correction in LibreElec which is missing.

    I initially thought I would use the https://github.com/wastis/PulseEqualizerGui, but it seems LibreElec doesn't use pulseaudio by default and is missing pulseaudio-equalizer anyway.

    Are either of you still using this add-on ? I wonder if it works on libreelec 12 ?

    coleb I'm curious how you did the room correction with REW, do you need to have REW running on the kodi device ? Or can the playback and measurement be done on two separate devices ? There are so many guides to REW, if you have one in particular I'd be happy to have a recommendation.

    Thanks !

  • Hi surkat ,

    the plugin should be functional, i'm still using it on LE 11, AFAIK coleb successfully built a version for LE 12.

    I plan to provide a version for LE 12 in the coming days or weeks and will notify you when its done.


    HTH

  • Hi both,

    Are either of you still using this add-on ? I wonder if it works on libreelec 12 ?

    coleb I'm curious how you did the room correction with REW, do you need to have REW running on the kodi device ? Or can the playback and measurement be done on two separate devices ? There are so many guides to REW, if you have one in particular I'd be happy to have a recommendation.

    Thanks !

    Hi surkat and chipfunk,

    I can confirm that my aarch64 compiled brutefir addon version works well on LE12 and on latest nightly LE13 (AML S912) too. For whom it may concern it also works very well on my Coreelec-no nightly (AML 905X4).

    For room correction measurement and correction data generation you need a PC or Mac, Micro & SW like REW and RePhase. It takes quiet some time to get the best Workflow. Finally, your device running brutefir just needs the correction data (i.e. textfile) generated by REW and RePhase to do the propper correction. No need to run REW on the brutefir device.

    Currently i'm very busy prior Christmas, but later on i will be happy to provide further support.

    Here‘s the link to my Addonbuilds for Generic Amlogic Devices and a description that helps to work with REW and RePhase. Have fun :)

    brutefir – Google Drive

    The addons work on either installation LE12, LE13 and CE :)

    Edited 12 times, last by coleb: link to repository added (December 23, 2024 at 2:33 PM).