Page 1 of 32

Volumio2 and brutefir...

PostPosted: Thu Apr 14 2016 19:32
by balbuze
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.

Volumio2 and brutefir...

PostPosted: Sat Apr 16 2016 12:02
by ansuser
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.

Volumio2 and brutefir...

PostPosted: Sat Apr 16 2016 12:11
by balbuze
Hi!
I'm really interested by your config. Could you give more details about it. IE your mpd.conf, brutefir config etc... Thank you

Volumio2 and brutefir...

PostPosted: Sat Apr 16 2016 14:33
by balbuze
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 :D
Now I have to test with true filter (I use dirac pulse for my first test).
I'll keep you in touch !

Volumio2 and brutefir...

PostPosted: Sun Apr 17 2016 09:43
by balbuze
Well, it's nearly working as expected...even if there is still some problems.
What I did
- install brutefir
Code: Select all
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"
Code: Select all
snd_bcm2835
snd_aloop

- launch brutefir to create config file and quit
- go in /home/volumio and edit the created file
Code: Select all
nano .brutefir_config

and change input and output section to match your config. Mine is like
Code: Select all
                                                                                                                             
    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.

Volumio2 and brutefir...

PostPosted: Sun Apr 17 2016 11:59
by balbuze
I cleaned up my .brutefir_config :
Code: Select all
   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";
};

Volumio2 and brutefir...

PostPosted: Sun Apr 17 2016 19:34
by balbuze
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

Volumio2 and brutefir...

PostPosted: Sun Apr 17 2016 23:28
by ansuser
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

Volumio2 and brutefir...

PostPosted: Mon Apr 18 2016 18:50
by balbuze
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 ?

Volumio2 and brutefir...

PostPosted: Mon Apr 18 2016 20:08
by ansuser
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.