Volumio 2 and brutefir

DRC is something I had experimented 2 years ago using folve and a RPI B… https://volumio.org/forum/dsp-with-raspberry-hifiberry-and-volumio-drc-folve-t672.html It was working, but with the lack of power of the RPI, cpu was nearly 100% of use giving clic and other problem. And with folve, only flac files were used.
Now, with the RPI 2 and RPI3, we’ve got enough power to think seriously DRC !
So I started to have a look on how to use it with Volumio2, using this https://volumio.org/forum/volumio-with-mpd-pipe-out-and-brutefir-t3635.html
Here are the steps :

  • making it working ( I’ve got a problem because mpd stop working when using brutefir, but it could be due to a wrong config)
  • writing a plugin to easily install it and enable it ( using the WIP about that, see on github).
    What do you think of that.
1 Like

Hello,
I’ve managed to run brutefir with Volumio v1.5 via alsa loopback plugin. It works flawlessly except longer boot time (70 seconds compared to 35 seconds without brutefir/loopback). I use it in the car, so shorter boot time matters.

I’m not really sure if mpd pipe option is better/faster/more stable compared to loopback.

Jack is definitely not an option because it does not support I2S dacs on pi.

Hi!
I’m really interested by your config. Could you give more details about it. IE your mpd.conf, brutefir config etc… Thank you

I did some test with a loopback device, and it works ! The very interesting thing is that you just have to choose “loopback” as output in webUI. Nothing to be changed in mpd.conf :smiley:
Now I have to test with true filter (I use dirac pulse for my first test).
I’ll keep you in touch !

Well, it’s nearly working as expected…even if there is still some problems.
What I did

  • install brutefir

sudo apt-get update sudo apt-get install brutefir

  • adding a loopback device in /etc/modules (for testing you can also enter “sudo modprobe snd_aloop”
snd_bcm2835
snd_aloop 
  • launch brutefir to create config file and quit
  • go in /home/volumio and edit the created file
nano .brutefir_config

and change input and output section to match your config. Mine is like

    sampling_rate: 44100;
    filter_length: 4096,16;
    overflow_warnings: true;
    float_bits: 32;
    convolver_config: "~/.brutefir_convolver"; # location of convolver config file
    logic: "cli" { port: 3002; };

 coeff "left" {
 #           filename: "/home/volumio/lr.pcm"; #filterl
           filename: "dirac pulse";
            format: "FLOAT_LE";
            attenuation: 0.0;
    };

    coeff "right" {
  #            filename:"/home/volumio/lr.pcm"; #filterr
             filename: "dirac pulse";
            format: "FLOAT_LE";
            attenuation: 0.0;
     };

    input "left", "right" {
            device: "alsa" {device: "hw:Loopback,1";};
            sample: "S16_LE";   # sample format
            channels: 2;            # number of open channels / which to use
            delay: 0,0;             # delay in samples for each channel
            maxdelay: -1;           # max delay for variable delays
            mute: false,false;      # mute active on startup for each channel
    };

    output "left", "right" {
            device: "alsa" {device: "hw:2,0";};
#           device: "file" {path: "/dev/stdout";};
            sample: "S16_LE";   # sample format
            channels: 2;        # number of open channels / which to use
            delay: 0,0;         # delay in samples for each channel
            maxdelay: 100;      # max delay for variable delays
            mute: false,false;  # mute active on startup for each channel
            dither: false;      # no dither for 32 bit output
    };

# factor 0.4 to avoid clipping
filter "M direct" {
        from_inputs: "left"//0.4, "right"//0.4;
        to_filters: "left direct", "right direct";
        coeff: -1;
        crossfade: false;
};

# here 0.8 instead of 0.4 because the filter "in average" multiplies with 0.5
# (one could make 0.8 a bit larger/smaller to obtain a wider/narrower
# stereo image, but better use RACE for this)
filter "S filter" {
        from_inputs: "left"//0.8, "right"//-0.8;
        to_filters: "left direct", "right direct";
        #coeff: "S channel";
        coeff: -1;
        crossfade: false;
};

filter "left direct" {
        from_filters: "M direct"//1.0, "S filter"//1.0;
        to_outputs: "left"/0.0;
        #coeff: "left_default";
        coeff: -1;
        crossfade: false;
};

filter "right direct" {
        from_filters: "M direct"//1.0, "S filter"//-1.0;
        to_outputs: "right"/0.0;
        #coeff: "right_default";
        coeff: -1;
        crossfade: false;
};

If you don’t have a pcm file for coeff section, use dirac pulse to test.
If you want to access brutefir using CLI you have to change the port from 3000 to a other (3002) because 3000 is used by volumio.
Now, in the webUI, choose Loopback as output device.
In a console, launch brutfire and in the webUI play a track.
It should works… If you kill brutefir the sound stops…
Work to be done :
-starting brutefir at boot time
-I add a software mixer to Loopback device. I can select it in the webUI and when I change volume it changes in alsamixer, but the sound level stay the same…

  • I have to create a filter for DRC but I haven’t a good mic…
    Some other information
    I use a RPI2 and a Iqaudio DAC.
    With a floats_bits set to 32 and a filter_lenght 4096,16, cpu usage reported by “top” is 12% by brutefir when playing a flac file 44.1/16. I think it’s low enough to avoid problem.

I cleaned up my .brutefir_config :

[code] sampling_rate: 44100;
filter_length: 4096,16;
overflow_warnings: true;
float_bits: 32;
convolver_config: “~/.brutefir_convolver”; # location of convolver config file
logic: “cli” { port: 3002; };

coeff “left” {

filename: “/home/volumio/lr.pcm”; #filterl

       filename: "dirac pulse";
        format: "FLOAT_LE";
        attenuation: 4.0;
};

coeff "right" {

filename:"/home/volumio/lr.pcm"; #filterr

         filename: "dirac pulse";
        format: "FLOAT_LE";
        attenuation: 4.0;
 };

input "left_in", "right_in" {
        device: "alsa" {device: "hw:Loopback,1";};
        sample: "S32_LE";   # sample format
        channels: 2;            # number of open channels / which to use
};

output "left_out", "right_out" {
        device: "alsa" {device: "hw:2,0";};

device: “file” {path: “/dev/stdout”;};

        sample: "S32_LE";   # sample format
        channels: 2;        # number of open channels / which to use
};

FILTER DEFAULTS

filter “left_fil” {
from_inputs: “left_in”/5.0;
to_outputs: “left_out”/0.0;
coeff: “left”;
};

filter “right_fil” {
from_inputs: “right_in”/5.0;
to_outputs: “right_out”/0.0;
coeff: “right”;
};
[/code]

A screenshot of “top” command showing volumio playing a 44,1/16 flac file through brutefir with filter_length 4096,16 . As value are changing it is just a snap… But we can see a low cpu usage… :mrgreen:
RPI 2 + audiophonics PCM5122 dac / amp http://www.audiophonics.fr/fr/raspberry-pi/st-400-module-hat-ampli-class-d-ampli-casque-dac-pcm5122-24bit192khz-p-10248.html
mpdbrutefir.png

balbuze,
my volumio 1.5 configuration looks similar to what you’ve described.
Can you comment on startup time (from power on to playing sound) with your current configuration vs. one without loopback and brutefir engaged?
On my RPI B with volumio 1.5 image startup time actually doubled from 35 sec. to 75 sec. when I switched to loopback and brutefir.
I tried clean install of Volumio 2 RC1 to see if it is faster and nope, it is not! It is actually slower to boot! Also for some reason web interface of Volumio 2 is laggy compared to 1.5

For now, I launch by “hand” brutefir as the target is to use a plugin…
What I can say is that brutefir starts in less than one second.
Which command do you use ? What about filter length ? Do you use a RPI 2 ?

I am using original rpi b, not rpi 2.
I launch brutefir with -daemon option during startup. It takes about 5 secs.
I use 16k taps filters for two channels and it results in 30% CPU load for brutefir processes.
I noticed that simply the fact of loopback usage in alsa config file slows down startup by ~30 secs.

Can you provide sytemd startup statistics of your setup? I can’t do this on my setup as it does not use systemd.

Can anybody help to test brutefir? I don’t know How to install in volumio 2, I think to put it the sd card and after… ?
it’s the first time …

Hi!
A very conveneint way is to use this : github.com/balbuze/volumio-plug … a/brutefir
Just download burtefir.zip file on your computer. In volumioUI go in plugins / plugins upload and select the file. After install you have to reboot and select Loopback as output device in volumio. Then go in plugins, enable the plugin and go in setting. You 'll propbaly have to change the output device. Save. At this point you should be able to play music ! But brutefir is useless if you don’t have filters to use ! You have to generate them with software such as REW or /and rephase or any other able to do that… Some example filter are installed by the plugin. But don’t expect quality improvement. They are just here to show that it works and the sound is changed !

thanks I try to install … it s ok but i can save the settings. when I enter in setting I read that the first (equalizer) is disabled, so I go to brute fir advanced setting, I try to write the name of the filter for left and right (your filter ex. flat.wav) after try to save but the system don’t seem to save (the only that work to save it’s the first (equalizer). and then I come back in main page and the plugin is with red point where is write that it’s disable … naturally i changed to loopback…but nothing . where I made wrong?

Hi,
You don’t need to give a filter name to test. When empty a Dirac pulse is used.
Check If you set the good output device in advanced settings. Use aplay -l to determine the right value.

Hi there,

I have been waiting very long for such plugin easy to use solution…Thanks for your efforts on this!

I tried the plugin yesterday with my Pi 3 and Hifiberry DAC + pro. I was not able to get it work…

Here my findings:

  • As described before, plugin shows red point for “inaktive” even when switched on in plugin menue
  • List of DACs to select in brutefir advanced settings does not show Hifiberry DAC pro…after several savings and trials even no DAC appeared anymore (only loopback, Audio Jack and HDMI)
  • save function does not work for advanced settings (at least no feedback if saved or not)
  • Deinstall function of plugin does not work
  • What exactly has to be put into “filter left/right” fields in advanced settings? Filter name or filter soring path ( - starting where)? please show example.
  • Play does not work even with disabled plugin after installation (worked before plugin installation)
  • hardware-software volume control is switching all time when selecting different DAC in player setting menue after plugin installation

You must enable i2s dac in volumio playback. Once this done, you should be able to select the dac in plugin setting. When you save settings you have a notification only if everything is ok and brutefir is started.
Filters files are in share folder of volumio. It is just to test. You have to create your own filter. In settings just enter the name + extension : ex anothertest.wav . Please read the readme file.

Edit If you leave empty filter fields, a Dirac pulse is used.

Does it really work on your device doing this?

If I set i2S in playback options, the output device switches automatically from loopback to the below choosen DAC (Hifiberry DAC pro) when pushing the “save” botton…

As output device HW in the plugin adv. settings the DAC “Hifiberry DAC” appears, but not the “Hifiberry DAC pro”

I do not get it to play even if no filter is set (all other are default settings)

Maybe a bug with this DAC type?

Hi!
Yes it works with my devices… I use a dev version of volumio. For the dac that appears in plugin, this what is returned by alsa. I think in volumio the list is given to help user to choose the right dac. But plenty of dac use the same overlay (hifierry or iqaudio …). So in plugin it should be ok to select what is proposed…
When the value jump from a device to a other it is due to volumio… . sometimes disabling /enabling i2s solves this.

I made some test. I discovered that it does not work in some case, when label and name are different… ex IqaudIO and IqaudIO DAC. Sorry for that it was ok with both of my test device. I’m looking at that :wink:

I just uploaded a new version that should solve the previous problem.
Let me know
https://github.com/balbuze/volumio-plugins/blob/master/plugins/miscellanea/brutefir/brutefir.zip

But remains the problem of jumping output selector in playback setting. With i2s DAC activated, it is impossible to select a other output. :confused: :frowning: