LADSPA plugin programming for Linux audio crossovers

MPD & Rune

Hi,

I got Rune up and running and playing a stereo file through the SoundPro. I am accessing the Odroid from my office computer over the network.

I actually edited the mpd.conf file in RuneAudio to make the SoundPro the default soundcard. It is working.

Now, I need to see if I can edit the mpd.conf file further to invoke using ecasound.

Any suggestions?

James
 
Hi,

I got Rune up and running and playing a stereo file through the SoundPro. I am accessing the Odroid from my office computer over the network.

I actually edited the mpd.conf file in RuneAudio to make the SoundPro the default soundcard. It is working.

Now, I need to see if I can edit the mpd.conf file further to invoke using ecasound.

Any suggestions?

James

Instead of sending the mpd output to alsa you can use a pipe output and as part of specify a command to run. This should allow you to pipe the audio output of mpd to ecasound and then from there output to the DACs.

It's in the documentation for mpd:
The Music Player Daemon - User's Manual
look under "output options".
 
mpd

Is this a sane command?

audio_output {
type “pipe”
name “DSP crossover/eq”
format “44100:32:2″
mixer_type “software”
command “ecasound -q -z:nodb -z:mixmode,sum
-a pre1 -f:s32_le,2,44100 -i:stdin -o:loop,1
-a pre2,woofer -i:loop,1 \
-a:mid,tweeter -i:loop,2 \
-a pre2 -o loop,2 \
-a:woofer -pf:/etc/woofer.ecp -chorder:0,0,0,0,1,2 \
-a:mid -pf:/etc/mid.ecp -chorder:1,2,0,0,0,0 \
-a:tweeter -pf:/etc/tweeter.ecp -chorder:0,0,1,2,0,0 \
-a:woofer,mid,tweeter -f:16,6,44100 -o:alsa,surround51:Audio
 
Is this a sane command?

audio_output {
type “pipe”
name “DSP crossover/eq”
format “44100:32:2″
mixer_type “software”
command “ecasound -q -z:nodb -z:mixmode,sum
-a pre1 -f:s32_le,2,44100 -i:stdin -o:loop,1
-a pre2,woofer -i:loop,1 \
-a:mid,tweeter -i:loop,2 \
-a pre2 -o loop,2 \
-a:woofer -pf:/etc/woofer.ecp -chorder:0,0,0,0,1,2 \
-a:mid -pf:/etc/mid.ecp -chorder:1,2,0,0,0,0 \
-a:tweeter -pf:/etc/tweeter.ecp -chorder:0,0,1,2,0,0 \
-a:woofer,mid,tweeter -f:16,6,44100 -o:alsa,surround51:Audio

Looks like you are missing the closing quotation on the command text string. You may need to remove all of the backslashes and put it all on one loooooong line, but try it like it is first.

Also, not sure why you are choosing to output 32 bit data from mpd if, in the end, you are outputting 16 bit data to your DAC. That just results in twice as much data streaming through ecasound... only to be truncated to 16 bits in the final step. I would just use 16 bits out of mpd and keep that all the way through. Up to you.
 
Per your and R. Taylor's discussion I thought: "It’s essential to keep at least 24-bit resolution all the way through the processing chain. When I pipe audio from mpd to ecasound I pass the samples as 32-bit floats so there’s no re-quantization in the middle of the chain." Dither and ecasound | Richard's Stuff

What's your thoughts on this? Just trying to learn. For some reason I also thought that ecasound always converted the signal to 32 for internal processing regardless of input and output setting. Is this correct or will it change based on the input?
 
Per your and R. Taylor's discussion I thought: "It’s essential to keep at least 24-bit resolution all the way through the processing chain. When I pipe audio from mpd to ecasound I pass the samples as 32-bit floats so there’s no re-quantization in the middle of the chain." Dither and ecasound | Richard's Stuff

What's your thoughts on this? Just trying to learn. For some reason I also thought that ecasound always converted the signal to 32 for internal processing regardless of input and output setting. Is this correct or will it change based on the input?

The problem is that there is no native 24-bit alsa bit depth. Your choices include 16 bit data, e.g. S16_LE, or 32 bit data, e.g. S32_LE, and that's it.

I believe what you are referring to is the "internal" bit depth in ecasound/LADSPA. Within these programs the fixed formats are converted to floats. You need to use double precision (64 bits) when calculating the transfer functions in LADSPA to avoid the roundoff errors. This is because you are calculating ratios of numbers that are very near 1.0, so the extra mantissa bits are helpful. But coming into, and going out of, ecasound it is fine to use 16 bit representation IMHO. The incoming audio signal is converted to single precision float (32-bit) values, but in my LADSPA code I do the transfer calculations in 64 bit precision before converting back to single precision when passing the data back to ecasound. The overhead is minimal.

I think our (Rtaylor and me) discussion was about dithering. That's used to suppress/reduce noise during truncation of fixed point signals. I think that only applies if you are e.g. truncating S32_LE to S16_LE. I should probably go back and re-read those posts on his web page. At the time I was just leaning how to navigate and control ALSA, so it could have been that I had some odd conversions going on without realizing it at the time. I have come a long way since then...
 
@jmccanna - thanks for the follow-up. I was going to suggest installing volumio since they have an odroid build to get going with mpd. I never tried Rune since I'm not so familiar with Arch. I use moode on the raspberry pi which has a common orign. Just be careful with changing anything in gui once you have everything set-up since it wipes all the manual mpd.conf settings.
 
Interestingly, I made substantial changes to the Rune mpd.conf file and it made no difference. I changed it to use ecasound in a 5.1 setup but the player still outputs only stereo.

The sound is good for stereo!

I am going to try using a regular Odroid version of Jessie and see if I can free up how mpd works. More later.
 
Hi, That is a really good question. I do not know. In RuneAudio it is already compiled and they warn not to do anything to it. I did put in the pipe command and it did not object after a reboot.

Perhaps that is why the changes have no effect?

I have installed mpd on my Jessie system but maybe I need to delete it and reinstall by compiling it with pipe enabled? I wonder how one does that?

James
 
There is another option to using a pipe to ecasound for MPD output. You can create a virtual device (aka loopback device) in ALSA and send MPD output to it. Then configure ecasound to read from the virtual device and output to a hardware device. It worked for me a while back but the method didn't do everything I wanted (auto sample rate adjustment) so I found another solution. Thus, unfortunately, I don't have specific notes on the loopback setup nor ecasound syntax.

An introduction to loopback in ALSA can be found here: Matrix:Module-aloop - AlsaProject
 
The problem is that there is no native 24-bit alsa bit depth. Your choices include 16 bit data, e.g. S16_LE, or 32 bit data, e.g. S32_LE, and that's it.

Alsa has a native 24-bit format (in 3 bytes), widely used - S24_3LE .

From what I understand it is mpd which does not accept this 3-byte output format: Configuring audio outputs

The following values are valid for bits: 8 (signed 8 bit integer samples), 16, 24 (signed 24 bit integer samples padded to 32 bit), 32 (signed 32 bit integer samples), f (32 bit floating point, -1.0 to 1.0).

If it did, you could configure the equivalent s24_le in ecasound Ecasound / Mailing Lists

Nevertheless it would be converted from/to internal MPD/ecasound formats anyway...
 
Or there is yet another option - the alsa file plugin can pipe the stream to another process by prepending a pipe character to the command string ALSA project - the C library reference: PCM (digital audio) plugins . Since stream params are available as keys (%r, %c, %b, %f), the configuration can easily support various ecasound parameters for various samplerates, formats, channel counts etc. (e.g. configured in a script).

I have not tested this option with MPD but it worked in other players for resampling in SoX (before the libsoxr library came to existence).
 
Well It works

Hi,
It works after a fashion. I modified the mpd.conf file in RuneAudio despite all the dire warnings that it might break the system. The result? No change - it still plays in stereo but everything else works.

I can see my FiiO X3 2 as a USB source and play files directly off of it.

This may be a limitation with Rune Audio so I may install mpd on my other setup running Debian Jessie with mods and see if I can get it to play in surround51.

Or, I could just be happy I got this far. Pretty dang cool to control it from my office PC.
 
I would suggest to troubleshoot in simple steps, going from your soundcard up the playback chain.

What is your soundcard? Please post output of aplay -l

It is possible the default definition of surround51 in alsa configs is not correct for your card. Cards have stereo and multichannel devices under various indices, the default does not have to work in your case.

The diagnostics tool to use is

Code:
speaker-test -c 6 -D yourdevice

where -c 6 means 6 channels - 5.1

You have to identify the device which outputs all 6 channels correctly. Then such device config string should go to ecasound params instead of surround51.
 
Odroid update

Hi,

Well, where to start? I am using a Jessie OS for the Odroid downloaded from the hardkernel.com site. I autoremoved pulseaudio. I installed ecasound and all relevant alsa parts. I have edited the mpd.conf per the command above including putting the ecasound command in one long line. The only audio_output I am using in the mpd.conf file is "pipe".

GMPC sees the music I downloaded into a file. It plays fine but it does not employ the crossover instructions. That is: I get six channels of audio through my USB SoundPro card but they are all full-spectrum. I checked my LADSPA_PATH and made sure it pointed to the ladspa files too.

If someone can point me where I am wrong please help. Here is the command which is in one very long line between the quotation marks:

audio_output {
type “pipe”
name “DSP crossover/eq”
format “44100:32:2″
mixer_type “software”
command “ecasound -q -z:nodb -z:mixmode,sum -a pre1 -f:s32_le,2,44100 -i:stdin -o:loop,1 -a pe2,woofer -i:loop,1 -a:mid,tweeter -i:loop,2 -a pre2 -o loop,2 -a:woofer -pf:/etc/woofer.ecp -chorder:0,0,0,0,1,2
-a:mid -pf:/etc/mid.ecp -chorder:1,2,0,0,0,0 -a:tweeter -pf:/etc/tweeter.ecp -chorder:0,0,1,2,0,0 -a:woofer,mid,tweeter -f:16,6,44100 -o:alsa,surround51:Audio"
}

I get no errors at all and it actually works really smoothly.
 
Last edited:
Hi,

Well, where to start? I am using a Jessie OS for the Odroid downloaded from the hardkernel.com site. I autoremoved pulseaudio. I installed ecasound and all relevant alsa parts. I have edited the mpd.conf per the command above including putting the ecasound command in one long line. The only audio_output I am using in the mpd.conf file is "pipe".

GMPC sees the music I downloaded into a file. It plays fine but it does not employ the crossover instructions. That is: I get six channels of audio through my USB SoundPro card but they are all full-spectrum. I checked my LADSPA_PATH and made sure it pointed to the ladspa files too.

If someone can point me where I am wrong please help. Here is the command which is in one very long line between the quotation marks:

audio_output {
type “pipe”
name “DSP crossover/eq”
format “44100:32:2″
mixer_type “software”
command “ecasound -q -z:nodb -z:mixmode,sum -a pre1 -f:s32_le,2,44100 -i:stdin -o:loop,1 -a pe2,woofer -i:loop,1 -a:mid,tweeter -i:loop,2 -a pre2 -o loop,2 -a:woofer -pf:/etc/woofer.ecp -chorder:0,0,0,0,1,2
-a:mid -pf:/etc/mid.ecp -chorder:1,2,0,0,0,0 -a:tweeter -pf:/etc/tweeter.ecp -chorder:0,0,1,2,0,0 -a:woofer,mid,tweeter -f:16,6,44100 -o:alsa,surround51:Audio"
}

I get no errors at all and it actually works really smoothly.

Instead of a pipe you could use a fifo (that you create for this purpose) as output from mpd. Then in a separate bash script you call ecasound with the named fifo as input instead of stdin. There is an example in post #3 of this thread:
https://bbs.archlinux.org/viewtopic.php?id=174188

You might be able to get better debug info on ecasound that way. You can run it from the command line as well when set up like this.

I have no personal experience with piping mpd output via pipe or fifo, but thought I would let you know what I have seen posted.