• Disclaimer: This Vendor's Forum is a paid-for commercial area. Unlike the rest of diyAudio, the Vendor has complete control of what may or may not be posted in this forum. If you wish to discuss technical matters outside the bounds of what is permitted by the Vendor, please use the non-commercial areas of diyAudio to do so.

LADSPA filters for digital crossovers on the BBB

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Yes, as written your system requires 4 channel input. For stereo input you must process channels 0 and 1 for both lows and highs. This is done using input bindings different from output bindings. So channel 0 can output to 0 in one filter, and to channel 2 in a different one. There are many examples in this thread. Make that adjustment and it seems you will have no other issues. Good luck!

Frank

Thanks for your response, in my crazyness the code that i posted was the one i had in the config which was working "most right".

What you are saying makes a lot of sense and i have tried to follow other examples from the thread. But its not working, perhaps im stupid..

Anyway, for me it makes sense that input.bindings.0/1 binds in case of stereo the full frequency, thus i should be able to load 0/1 twice and pass the filters to them to get my full responce in the output.bindings which works for the quad-file. But i hear nothing in the tweeter with this setup either.

Code:
     {
          0 {
               label RTlr4lowpass
               policy none
               input.bindings.0 "Input"
               output.bindings.0 "Output"
               input { controls [ 400 ] }   # low left [ frequency in Hz (-6dB XO point)]
          }
          1 {
               label RTlr4hipass
               policy none
               input.bindings.0 "Input"
               output.bindings.2 "Output"
               input { controls [ 400 ] }   # high left
          }
        2 {
               label RTlr4lowpass
               policy none
               input.bindings.1 "Input"
               output.bindings.1 "Output"
               input { controls [ 400 ] }   # low right
          }
        3 {
               label RTlr4hipass
               policy none
               input.bindings.1 "Input"
               output.bindings.3 "Output"
               input { controls [ 400 ] }   # high right
          }
     }
}

EDIT: Nvm, i got i to work. Thank you for the help! That little extra push was what i needed to solve this. For some reason my config above wasnt working but this one is:
Code:
     {
          0 {
               label RTlr4lowpass
               policy none
               input.bindings.0 "Input"
               output.bindings.2 "Output"
               input { controls [ 400 ] }   # low left [ frequency in Hz (-6dB XO point)]
          }
          1 {
               label RTlr4hipass
               policy none
               input.bindings.0 "Input"
               output.bindings.0 "Output"
               input { controls [ 400 ] }   # high left
          }
        2 {
               label RTlr4lowpass
               policy none
               input.bindings.1 "Input"
               output.bindings.3 "Output"
               input { controls [ 400 ] }   # low right
          }
        3 {
               label RTlr4hipass
               policy none
               input.bindings.1 "Input"
               output.bindings.1 "Output"
               input { controls [ 400 ] }   # high right
          }
     }
}
 
Last edited:
Yes, the filter order matters... if first you modify channel 0 to remove some frequencies and output back to channel 0, then they will be gone when you use that channel as input for another filter...

Ah, that makes sense. As a noobie with LADSPA this was driving me nuts. Perhaps it should be added somewhere that (i assume) the output.bindings should always be descending? Anyhow, thanks!
 
Member
Joined 2007
Paid Member
@Ivo, here is an ALSA configuration file to test on your Pi. It is just the first step in getting your system up to the level you seek, but it will allow you to verify your hardware. After that you can try to implement JACK and your GUI crossover.

a) Copy this text and place in a file named "asound.conf" in the /etc directory, then reboot.
b) try 'aplay -L'; if no errors, after pulse you should see 'default', 'speaker', and t-table.
c) volume on amp low...
d) try 'speaker-test -c 8'


Code:
pcm.!default {
     type plug
     slave.pcm speaker
}
ctl.!default {
     type hw
     card 0
}
pcm.speaker {
    type plug
    slave {
     pcm "t-table"  
     channels 8
     rate "unchanged"
    }
}
pcm.t-table  {
    type route
    slave {
     pcm "hw:0,0"   # default hardware output destination - may need to be edited
     channels 8
    }
    ttable {
      0.0   1  # read as: left input channel 0 -> output channel 0; 1 = full volume (0 = 'off')
      1.1   1  # right input channel 1 -> default right output
      2.0   1  #left input channel 2 -> output channel 0
      3.7   1  #input channel 3 -> output channel 7
      4.4   1  
      5.5   1  
      6.6   1  
      7.3   0.5  #input channel 7 -> output channel 3; half volume
    }
}

pcm.plughw.slave.rate = "unchanged";

Note that the plugin for routing, 't-table', is configured a bit oddly just for you to understand the syntax and function. You can change it to whatever you like. For example, if you route stereo (channels 0 and 1, L and R) to any other of the 8 channels and then execute 'speaker-test -c 2', you should also hear them in the added channels to which they are routed. Example:
Code:
      0.0   1  
      1.1   1 
      0.2   1
      1.3   1
      0.4   1  
      1.5   1  
      0.6   1  
      1.7   1

Give this asound.conf a try and see what happens... If it fails, it can be that there are problematic characters in the code. That's why I suggest copying and pasting to begin. If VLC's output doesn't reach the default plugin, perhaps try something like this: https://forum.videolan.org/viewtopic.php?t=133301#p442403

If you get no HDMI output, you might need to edit the t-table plug output to 'hw:0,1' or 'hw:1,0' or 'hw:1,1' or 'hw:bcm2835 ALSA, bcm2835 IEC958/HDMI'. best ro reboot after each change to asound.conf. Sorry, I'm not 100% sure about the contents of your aplay -L result.

Good luck,

Frank
 
Last edited:
OK, output from Aplay -L followed by speaker-test. Instead of "default" it says PulseAudio Sound Server. I get similar results with hw:0.1, hw:1.0 and hw:1.1. Speaker-test fails.

I simply copied the code you provided and saved it as asound.conf in a textfile, then copied that to /etc. Did I do that right? What else can I try?

Code:
pi@raspberrypi:~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
speaker
t-table
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
pi@raspberrypi:~ $ speaker-test -c 8

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 8 channels
Using 16 octaves of pink noise
Channels count (8) not available for playbacks: Invalid argument
Setting of hwparams failed: Invalid argument
pi@raspberrypi:~ $
 
Member
Joined 2007
Paid Member
I simply copied the code you provided and saved it as asound.conf in a textfile, then copied that to /etc. Did I do that right? What else can I try?

if you execute 'speaker-test -h' you will see some of the optional parameters.

lets force the output into your ALSA plugs: speaker-test -c 2 -D plug:speaker

if that fails, post the error message that follows.

F.
 
Hmmm...

Code:
pi@raspberrypi:~ $ speaker-test -c 2 -D plug:speaker

speaker-test 1.0.28

Playback device is plug:speaker
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
ALSA lib pcm_params.c:2162:(snd1_pcm_hw_refine_slave) Slave PCM not usable
Broken configuration for playback: no configurations available: Invalid argument
Setting of hwparams failed: Invalid argument
pi@raspberrypi:~ $
 
The above is for hw:0.0. Following is for hw:1.0.

Looks to me (without knowing too much) like hw:0.0 is the right card, but something is wrong with the asound.conf?

Code:
pi@raspberrypi:~ $ speaker-test -c 2 -D plug:speaker

speaker-test 1.0.28

Playback device is plug:speaker
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
Playback open error: -2,No such file or directory
pi@raspberrypi:~ $
 
Member
Joined 2007
Paid Member
I resaved the asound.conf file I made to asoundconf.txt so I could upload is. Is the formatting still OK?

Formatting looks to be OK. However, I suggest you change the t-table to the second one I suggested and then use '-c 2' in the speaker-test command instead of '-c 8'.

Still something is wrong and I am unable to reproduce it because I don't have the same hardware. I think your system is somehow corrupted because it looks like there may be an ALSA loopback function running, and you have a pulse plug for pulse audio. I suggest using chkconfig to turn off any and all unnecessary functions (especially related to JACK) and then reboot.
http://www.thegeekstuff.com/2011/06/chkconfig-examples/
Be sure your ALSA plugs are visible after 'aplay -L', and then see if speaker-test will run. Beyond that, I doubt that I can help. Perhaps revert to an older system? :confused:

Sorry for not understanding the issue here...

Frank
 
I had some issues relating >2 channels when getting my active setup running.
Running stereo audio into ALSA (asound.conf) and trying to "populate" the extra channels in a ROUTE plugin did not work. It's been a while so I can't recall the exact errors.

I instead populated them in the LADSPA plugin. This config seems to work fine through to a 5.1 USB soundcard.

I also played with getting multi-channel sample clips from various sound test sources across the web. Having reliable 4 channel or 6 channel samples demonstrating each channel separately showed that sound could be had from all outputs.... If I could only get the ALSA config to see it that way. :)

J.
 
Member
Joined 2007
Paid Member
In my BBB, plugs of type 'route' are definitely finicky! They only work if fed from a type 'plug'. ...and, I have never had success with routing commands using any other type except the LADSPA wrapper. But, I am confident that the type 'route' plug I posted works on a RPi as long as it doesn't have any problematic characters in it like bad CR/LF, tabs, etc. One other possible cure for the test asound.conf file is to erase and re-enter all of the spaces and returns using nano or other simple screen editor. However, as entered now the file doesn't hang when executing 'aplay -L'.

I think that eliminating any loopback functions and sending the sound to 'hw:0,0' is the best next step.

F.
 
Member
Joined 2007
Paid Member
I think that eliminating any loopback functions and sending the sound to 'hw:0,0' is the best next step.

more specifically, sending the output to hw:0,0 from within the asound.conf file - like this:

Code:
pcm.t-table  {
    type route
    slave {
     pcm "hw:0,0"
     channels 8
    }
    ttable {
      0.0   1
      1.1   1
      0.2   1
      1.3   1
      0.4   1  
      1.5   1  
      0.6   1  
      1.7   1
    }
}

And just to be sure, use nano or vi to replace all of the invisible characters - spaces or returns - and eliminate invisible characters to the right of each line.

...the best I can suggest for now...

F.
 
Member
Joined 2007
Paid Member
I'll try it out when I have some time this week. Maybe tonight.

A couple more things to consider:

Is your kernel fully functional with common ALSA configurations?
What if you try 'speaker-test -c 6 -D surround51'
alsa.opensrc.org

Is your HDMI port truly available? The working systems I'm aware of are 'headless' (no monitor).
https://www.raspberrypi.org/forums/viewtopic.php?t=5062

Will you be happy with a 48kHz frequency cap on each channel?
Playing 96/24 and 192/24 on Raspberry Pi through HDMI

If anything else occurs to me I'll speak up...

F.
 
Aha! This happened:

Code:
E: [pulseaudio] main.c: Failed to kill daemon: No such process
pi@raspberrypi:~ $ pulseaudio
E: [pulseaudio] bluez4-util.c: org.bluez.Manager.GetProperties() failed: org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with signature "" on interface "org.bluez.Manager" doesn't exist

I'll just remove pulseaudio completely first, see what happens then.
 
I have had extremely frustrating times with this. Very nice. ;-)

I used Berryboot to be able to boot multiple operating systems from the same microSD card. I was wondering whether this might complicate matters, so I went to a Noobs/Raspbian install. Not better, so I decided to go to a Noobs/Raspbian Lite install. Since I need a desktop environment, I installed the Pixel desktop (but not the bloatware). If anything, this lightweight version of Raspbian is much quicker to compile a kernel and probably has more capacity for DSP, so that alone was worth it.

I modified the driver and compiled as in the Instrubables tutorial. I tried it without asound.conf to start with. Running speakertest for 8 channels worked, no errors. I only have two loudspeakers connected to my AV-receiver, and it downmixes at its current settings, but at least speakertest was not confused.

Then I started Qjackctl with all standard settings. I started the jackserver and it ran without errors. In the patchbay, the default soundcard presented 8 output channels! I tried different numbers of output channels, from that point on starting Jack failed every time. However, when I started Patchage (a different piece of software, more basic but a better GUI for making connections in Jack) it also started Jack. Strangely, it showed the last number of output channels that worked with Jack (4 channels), no matter what settings I use in Qjackctl.

Then I made the asound.conf, didn't change anything. After a reboot or two, Qjackctl manages to start Jack again, but it doesn't care how many output channels I configure. Patchage shows me 4 and that's that. I have patchbay persistence turned off in Qjackctl and Patchage itself is not persistent, so I have no idea what causes that channel modification to stick so much.

I tried to kill PulseAudio, but the response said there was no such process active.

So at least I know that modifying and compiling the kernel worked. I have seen Jack working with it and just right now it's been running stable for about an hour now. I don't get sound output from the receiver now, though.

I'm wondering whether anyone knows of Jack messing with alsa configurations, long term? Is there a file that's been altered by Jack?

For now, I think I'll try and see if I get any sound from alsa the standard way. And check if it really did output 8 channels that were downmixed by my amp. If those two are fixed, I should probably move to a Jack thread for Raspberry Pi.

While there is still a lot I don't know, I'm really glad you suggested I try some alsa stuff out, Frank! Very interesting.
 
Member
Joined 2007
Paid Member
Sorry it has been such a struggle. Those of us who are satisfied with command line interfaces do have the advantage of simplicity. The commands 'aplay' and 'speaker-test' are similar. 'aplay' offers good feedback for debugging if you use the verbose setting. Check all of the command line options using 'aplay --help'.

Then, as for ALSA... Realize that it is a somewhat poorly documented audio system in which there are standard defaults but it can be highly customized within programmable user space. Not many people are writing custom configurations now because (as I see it) the GUI programs intended for laptop and desktop systems are much simpler, while our SOC development boards like RPi and BBB are still not widely accepted as audio appliances. it could be that the work it takes to make your favorite programs run on the RPi itself is MUCH greater than the work to translate filter slopes and Qs, etc. into LADSPA plugins, such as James has done on the RPi. Perhaps that's an intermediate goal that would get you enjoying sound while the other issues are sorted out with less anguish?
One thing for sure, I can't help you further except to achieve such an intermediate solution - using ACDf filters in ALSA on the RPi.

Good luck, though! It would be great to hear of your successes if and when they are realized!

Frank
 
Hi Frank, I have a well functioning system and a minidsp for immediate tweaking, so there's no problem in it taking some time. Windows XP was reallly a desktop and a mouse pointer to me. Ubuntu gave me a slightly more indepth understanding, but now I have seen some of the actual code. Educational and entertaining.

I will check out the LADSPA -stuff, but I will keep at the Jack stuff too. In the long run, the on the fly GUI stuff suits me best.

Thanks so far and you WILL hear more.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.