bmc0 / dsp

An audio processing program with an interactive mode.
ISC License
219 stars 31 forks source link

Can't get plugin load to work #66

Closed JesperWe closed 1 year ago

JesperWe commented 1 year ago

This is most likely me doing something wrong but I have been staring at this for a whole day now, hoping for some tips...

Running on a RPi / Debian 11, it has a USB and an I2S DAC installed.

$ ./configure
enabled dsp
[dsp] disabled ladspa_host.o
[dsp] enabled sndfile.o (sndfile)
[dsp] enabled ffmpeg.o (libavcodec libavformat libavutil)
[dsp] enabled resample.o fir.o fir_p.o hilbert.o (fftw3)
[dsp] enabled zita_convolver.o
[dsp] enabled alsa.o (alsa)
[dsp] enabled ao.o (ao)
[dsp] enabled mp3.o (mad)
[dsp] disabled pulse.o (libpulse-simple)
enabled ladspa_dsp
[ladspa_dsp] disabled ladspa_host.o
[ladspa_dsp] enabled fir.o fir_p.o hilbert.o (fftw3)
[ladspa_dsp] enabled zita_convolver.o
[ladspa_dsp] enabled sndfile.o (sndfile)
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: S3 [Sound Blaster Play! 3], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: DAC [I-Sabre Q2M DAC], device 0: I-Sabre Q2M DAC i-sabre-codec-i2c.1-0048-0 [I-Sabre Q2M DAC i-sabre-codec-i2c.1-0048-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

/etc/asound.conf

pcm.dsp {
    type plug
    slave {
        format FLOAT
        rate unchanged
        channels unchanged
        pcm {
            type ladspa
            path "/usr/lib/ladspa"
            playback_plugins [{
                label "ladspa_dsp"
            }]
            slave.pcm {
                type plug
                slave {
                    pcm "hw:CARD=DAC,DEV=0"
                    rate unchanged
                    channels unchanged
                }
            }
        }
    }
}

pcm.!default {
    type copy
    slave.pcm "dsp"
}

pcm.dsp_ute {
    type plug
    slave {
        format FLOAT
        rate unchanged
        channels unchanged
        pcm {
            type ladspa
            path "/usr/lib/ladspa"
            playback_plugins [{
                label "ladspa_dsp:ute"
            }]
            slave.pcm {
                type plug
                slave {
                    pcm "hw:CARD=S3,DEV=0"
                    rate unchanged
                    channels unchanged
                }
            }
        }
    }
}

/etc/ladspa_dsp/config

effects_chain=eq 255 6 -10.3 eq 176 6q -16 eq 1k 1q -3 eq 75 3q 4 eq 3k 3q -4

/etc/ladspa_dsp/config_ute

effects_chain=eq 100 1q 4 eq 250 3q -8 highshelf 9k 0.7q -6

The plugin is installed:

$ ldd /usr/lib/ladspa/ladspa_dsp.so
    linux-vdso.so.1 (0x0000007fa4a96000)
    libzita-convolver.so.4 => /lib/aarch64-linux-gnu/libzita-convolver.so.4 (0x0000007fa4a27000)
    libfftw3.so.3 => /lib/aarch64-linux-gnu/libfftw3.so.3 (0x0000007fa495c000)
    libsndfile.so.1 => /lib/aarch64-linux-gnu/libsndfile.so.1 (0x0000007fa48cb000)
    libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007fa46f3000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fa4648000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fa44d3000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007fa44ad000)
    libfftw3f.so.3 => /lib/aarch64-linux-gnu/libfftw3f.so.3 (0x0000007fa4364000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fa4333000)
    /lib/ld-linux-aarch64.so.1 (0x0000007fa4a66000)
    libFLAC.so.8 => /lib/aarch64-linux-gnu/libFLAC.so.8 (0x0000007fa42ef000)
    libvorbis.so.0 => /lib/aarch64-linux-gnu/libvorbis.so.0 (0x0000007fa42b6000)
    libvorbisenc.so.2 => /lib/aarch64-linux-gnu/libvorbisenc.so.2 (0x0000007fa4204000)
    libopus.so.0 => /lib/aarch64-linux-gnu/libopus.so.0 (0x0000007fa41a6000)
    libogg.so.0 => /lib/aarch64-linux-gnu/libogg.so.0 (0x0000007fa418c000)

Playing an audio file works fine (plays on correct device with DSP processing):

$ aplay -Ddsp audio.wav
Playing WAVE 'audio.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

But trying to use it from the player I want fails:

$ snapclient -l
0: null Discard all samples (playback) or generate zero samples (capture)
1: lavrate Rate Converter Plugin Using Libav/FFmpeg Library
2: samplerate Rate Converter Plugin Using Samplerate Library
3: speexrate Rate Converter Plugin Using Speex Resampler
4: jack JACK Audio Connection Kit
5: oss Open Sound System
6: pulse PulseAudio Sound Server
7: upmix Plugin for channel upmix (4,6,8)
8: vdownmix Plugin for channel downmix (stereo) with a simple spacialization
9: dsp
10: default
11: dsp_ute
12: hw:CARD=Headphones,DEV=0
...etc...

$ LADSPA_PATH="/usr/lib/ladspa" snapclient -s 9
2022-12-17 16-28-19.679 [Info] (Snapclient) Version 0.26.0, revision e30a9f33
2022-12-17 16-28-19.694 [Info] (Avahi) (Browser) NEW: service 'Snapcast' of type '_snapcast._tcp' in domain 'local'
2022-12-17 16-28-19.694 [Info] (Avahi) (Browser) NEW: service 'Snapcast' of type '_snapcast._tcp' in domain 'local'
2022-12-17 16-28-19.695 [Info] (Avahi) (Browser) CACHE_EXHAUSTED
2022-12-17 16-28-19.695 [Info] (Avahi) Service 'Snapcast' of type '_snapcast._tcp' in domain 'local':
2022-12-17 16-28-19.695 [Info] (Avahi)  raspberrypi.local:1704 (192.168.1.10)
2022-12-17 16-28-19.696 [Info] (Controller) Found server 192.168.1.10:1704
2022-12-17 16-28-19.696 [Info] (Connection) Resolving host IP for: 192.168.1.10
2022-12-17 16-28-19.696 [Info] (Connection) Connecting
2022-12-17 16-28-19.697 [Notice] (Connection) Connected to 192.168.1.10
2022-12-17 16-28-19.697 [Info] (Connection) My MAC: "e4:5f:01:7d:97:d6", socket: 8
2022-12-17 16-28-19.799 [Info] (Controller) ServerSettings - buffer: 1000, latency: 0, volume: 33, muted: 0
2022-12-17 16-28-19.799 [Info] (Controller) Codec: flac, sampleformat: 44100:16:2
2022-12-17 16-28-19.799 [Info] (Player) Player name: alsa, device: dsp, description: <none>, idx: 9, sharing mode: unspecified, parameters: <none>
2022-12-17 16-28-19.799 [Info] (Player) Mixer mode: software, parameters: <none>
2022-12-17 16-28-19.799 [Info] (Player) Sampleformat: 44100:16:2, stream: 44100:16:2
2022-12-17 16-28-19.799 [Info] (Alsa) Using default buffer_time: 80 ms, default fragments: 4
ALSA lib pcm_ladspa.c:1509:(snd_pcm_ladspa_add_plugin) Unable to find or load plugin 'ladspa_dsp' ID 0, path '/usr/lib/ladspa'
2022-12-17 16-28-19.801 [Error] (Alsa) Exception: Can't open dsp, error: No such file or directory, code: -2
2022-12-17 16-28-19.801 [Fatal] (Snapclient) Exception: Can't open dsp, error: No such file or directory
2022-12-17 16-28-19.801 [Notice] (Snapclient) Snapclient terminated.

Can't figure what is wrong... Anything else I could check?

bmc0 commented 1 year ago

I was not familiar with snapcast, so I built and installed it to test. So far, I can't reproduce this problem, unfortunately. Snapclient runs fine and audio plays correctly. I can't imagine why it would work for you with aplay, but not with snapclient. Doesn't appear to be a locale-related problem as snapclient uses the default "C" locale (doesn't call setlocale(), in other words).

Weirdly, it doesn't work if I try to use the default device but it works fine if I specify the dsp device by name or index.

JesperWe commented 1 year ago

Thanks a lot for confirming that I have not completely lost my marbles :-) Any pointers on additional debugging I could do?

(Snapcast is beautiful tool for vendor independent multi-room audio with latency compensation)

JesperWe commented 1 year ago

so I built and installed it to test

Made me think... So I went ahead and built it myself instead of using the release download. Works.

bmc0 commented 1 year ago

The fact that aplay works on your end but alsalib claims the plugin doesn't exist when you use snapclient is very odd. Is it possible that one is a 32-bin executable and the other is 64-bit? I'm not sure off hand whether Debian supports multilib on ARM, but you could try running

$ file $(which aplay snapclient)

to confirm. Install the file package if it isn't already installed.

bmc0 commented 1 year ago

Good to hear it works if you build snapcast yourself.