voice-engine / ec

Echo Canceller, part of Voice Engine project
GNU General Public License v3.0
240 stars 69 forks source link

ec_hw blocking Recording on Respeaker6 #24

Open fdjohnston opened 2 years ago

fdjohnston commented 2 years ago

I have tried to get ec_hw working with a Respeaker6 on a Pi4 running Raspbian Bullseye 32 bit without any luck. Whenever I run ec_hw it appears to block audio play back and recording.

I have installed the Respeaker6 using the instructions here () and have installed ec and ec_hw using the instructions in this repo. When I run arecord -L I get this output:

# arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
default
    Playback/recording through the PulseAudio sound server
ac108
dmixer
ac101
usbstream:CARD=b1
    bcm2835 HDMI 1
    USB Stream Output
usbstream:CARD=Headphones
    bcm2835 Headphones
    USB Stream Output
sysdefault:CARD=seeed8micvoicec
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Default Audio Device
dmix:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct sample mixing device
dsnoop:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct sample snooping device
hw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Direct hardware device without any conversions
plughw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard, bcm2835-i2s-ac10x-codec0 ac10x-codec0-0
    Hardware device with all software conversions
usbstream:CARD=seeed8micvoicec
    seeed-8mic-voicecard
    USB Stream Output

Running any of the following appears to block all audio on my pi:

./ec_hw -i "hw:CARD=seeed8micvoicec,DEV=0" -c 8 -l 7 -m 0,1,2,3

./ec_hw -i "sysdefault:CARD=seeed8micvoicec" -c 8 -l 7 -m 0,1,2,3

./ec_hw -i ac108 -c 8 -l 7 -m 0,1,2,3

My /etc/asound.conf is the default created by the Respeaker installation process:

# The IPC key of dmix or dsnoop plugin must be unique
# If 555555 or 666666 is used by other processes, use another one

# use samplerate to resample as speexdsp resample is broken
defaults.pcm.rate_converter "samplerate"

pcm.!default {
    type asym
    playback.pcm "dmixer"
    capture.pcm "ac108"
}

pcm.ac108 {
    type plug
    slave {
        rate 48000
        format S32_LE
        pcm "hw:seeed8micvoicec"
    }
}

# pcm.multiapps {
#     type plug
#     slave.pcm {
#         type dsnoop
#         slave {
#             rate 48000
#             format S32_LE
#             pcm "hw:seeed8micvoicec"
#         }
#         ipc_key 666666
#     }
# }

pcm.dmixer {
    type plug
    slave {
        pcm {
            type dmix
            ipc_key 555555
            slave {
                pcm "hw:seeed8micvoicec"
                format S32_LE
                channels 8
            }
            bindings {
                0 0
                1 1
                2 2
                3 3
                4 4
                5 5
                6 6
                7 7
            }
        }
        channels 8
        format S32_LE
        rate 48000
    }
    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1
    ttable.0.4 1
    ttable.1.5 1
    ttable.0.6 1
    ttable.1.7 1
}

pcm.ac101 {
    type plug
    slave {
        pcm "hw:seeed8micvoicec"
        channels 8
        format S32_LE
        rate 48000
    }
    ttable.0.0 1
    ttable.1.1 1
    ttable.0.2 1
    ttable.1.3 1
    ttable.0.4 1
    ttable.1.5 1
    ttable.0.6 1
    ttable.1.7 1
}

Any help getting this working would be greatly appreciated.

tuxfoo commented 2 years ago

I see what you mean, I am also struggling to follow it.

I think the documentation needs some work when it comes to the hardware echo cancellation also for the 6 mic array.

From the diagram it outputs the processed audio into /tmp/ec.output; so I am assuming we need to load a source module prior to starting ec_hw and set that new source as default so that other software can use it.

However I am not sure about the sink, when ec_hw is running it locks that sink.