|
arduino-audio-tools
|
Classes | |
| struct | EchoState_ |
| Internal echo canceller state structure. More... | |
| struct | fft_state< Allocator > |
| FFT state management structure with custom allocator support. More... | |
| class | MDFEchoCancellation< Allocator > |
| Acoustic echo canceller using MDF algorithm. More... | |
Typedefs | |
| typedef struct EchoState_ | EchoState |
| using | FloatAllocator = typename std::allocator_traits< Allocator >::template rebind_alloc< float > |
Functions | |
| constexpr | echo_float_t (int16_t mantissa=0, int16_t exponent=0) |
| fft_state (int size, AudioFFTBase *drv, const Allocator &alloc=Allocator()) | |
| Construct FFT state with specified size and driver. | |
| MDFEchoCancellation (int filterLength, AudioFFTBase &fftDriver, const Allocator &alloc=Allocator()) | |
| MDFEchoCancellation (int filterLength, int nbMic, int nbSpeakers, AudioFFTBase &fftDriver, const Allocator &alloc=Allocator()) | |
| ~MDFEchoCancellation () | |
| void | cancel (const echo_int16_t *rec, const echo_int16_t *play, echo_int16_t *out) |
| void | capture (const echo_int16_t *rec, echo_int16_t *out) |
| int | control (int request, void *ptr) |
| template<typename Allocator = std::allocator<uint8_t>> | |
| void | echo_fft (void *table, echo_word16_t *in, echo_word16_t *out) |
| Perform forward FFT. | |
| template<typename Allocator = std::allocator<uint8_t>> | |
| void | echo_fft_destroy (void *table) |
| Destroy FFT state and release resources. | |
| template<typename Allocator > | |
| void * | echo_fft_init (int size, AudioFFTBase *driver, const Allocator &alloc) |
| Initialize FFT state. | |
| template<typename Allocator = std::allocator<uint8_t>> | |
| void | echo_ifft (void *table, echo_word16_t *in, echo_word16_t *out) |
| Perform inverse FFT. | |
| template<typename T > | |
| T * | echoAlloc (size_t count) |
| Allocate memory for array of type T using custom allocator. | |
| void | echoCancellationImpl (EchoState *st, const echo_int16_t *in, const echo_int16_t *far_end, echo_int16_t *out) |
| Core echo cancellation implementation. | |
| void | echoFatal (const char *str) |
| template<typename T > | |
| void | echoFree (T *ptr, size_t count=0) |
| Deallocate memory using custom allocator. | |
| EchoState * | echoStateInitMc (int frame_size, int filter_length, int nb_mic, int nb_speakers) |
| Initialize multi-channel echo canceller state. | |
| void | echoWarning (const char *str) |
| void | ensureInitialized () |
| Ensure echo canceller is initialized (lazy initialization) | |
| void | filterDcNotch16 (const echo_int16_t *in, echo_word16_t radius, echo_word16_t *out, int len, echo_mem_t *mem, int stride) |
| Apply DC notch filter to remove DC offset. | |
| int | getFilterLength () |
| int | getFrameSize () |
| void | getImpulseResponse (echo_int32_t *response) |
| int | getImpulseResponseSize () |
| int | getMicChannels () |
| int | getSamplingRate () |
| int | getSpeakerChannels () |
| EchoState * | getState () |
| void | mdfAdjustProp (const echo_word32_t *W, int N, int M, int P, echo_word16_t *prop) |
| Adjust proportional adaptation weights. | |
| echo_word32_t | mdfInnerProd (const echo_word16_t *x, const echo_word16_t *y, int len) |
| Compute inner product of two vectors. | |
| echo_float_t | operator* (const echo_float_t &other) const |
| echo_word32_t | operator* (int16_t scalar) const |
| echo_word32_t | operator* (int32_t scalar) const |
| void | playback (const echo_int16_t *play) |
| void | powerSpectrum (const echo_word16_t *X, echo_word32_t *ps, int N) |
| Compute power spectrum from FFT output. | |
| void | powerSpectrumAccum (const echo_word16_t *X, echo_word32_t *ps, int N) |
| Accumulate power spectrum from FFT output. | |
| void | reset () |
| void | setFFTDriver (AudioFFTBase &fftDriver) |
| void | setFilterLength (int len) |
| void | setMicChannels (int num) |
| void | setSamplingRate (int rate) |
| void | setSpeakerChannels (int num) |
| void | spectralMulAccum (const echo_word16_t *X, const echo_word32_t *Y, echo_word16_t *acc, int N, int M) |
| Accumulate spectral multiplication across multiple frames. | |
| float | spxCos (float x) |
| Compute cosine function. | |
| float | spxExp (float x) |
| Compute exponential function. | |
| echo_int16_t | spxIlog2 (echo_uint32_t x) |
| float | spxSqrt (float x) |
| void | weightedSpectralMulConj (const echo_float_t *w, const echo_float_t p, const echo_word16_t *X, const echo_word16_t *Y, echo_word32_t *prod, int N) |
| Compute weighted spectral multiplication with conjugate. | |
Variables | |
| int | adapted |
| Allocator | allocator |
| echo_word16_t | beta0 |
| echo_word16_t | beta_max |
| int | C |
| int | cancel_count |
| echo_word32_t | Davg1 |
| echo_word32_t | Davg2 |
| AudioFFTBase * | driver |
| echo_float_t | Dvar1 |
| echo_float_t | Dvar2 |
| int16_t | e |
| echo_word16_t * | e |
| echo_word16_t * | E |
| echo_word32_t * | Eh |
| AudioFFTBase * | fft_driver |
| void * | fft_table |
| int | filter_length |
| echo_word16_t * | foreground |
| int | frame_size |
| bool | initialized = false |
| echo_word16_t * | input |
| int | K |
| echo_word16_t * | last_y |
| echo_word16_t | leak_estimate |
| int16_t | m |
| int | M |
| echo_word16_t * | memD |
| echo_word16_t * | memE |
| echo_word16_t * | memX |
| int | N |
| int | nb_mic |
| int | nb_speakers |
| echo_mem_t * | notch_mem |
| echo_word16_t | notch_radius |
| echo_float_t | Pey |
| echo_word32_t * | PHI |
| echo_int16_t * | play_buf |
| int | play_buf_pos |
| int | play_buf_started |
| echo_word32_t * | power |
| echo_float_t * | power_1 |
| echo_word16_t | preemph |
| echo_word16_t * | prop |
| echo_float_t | Pyy |
| echo_word32_t * | Rf |
| echo_int32_t | sampling_rate |
| int | saturated |
| int | screwed_up |
| echo_word16_t | spec_average |
| EchoState * | state = nullptr |
| echo_word32_t | sum_adapt |
| std::vector< float, FloatAllocator > | temp_img |
| std::vector< float, FloatAllocator > | temp_real |
| echo_word32_t * | W |
| echo_word16_t * | window |
| int | window_size |
| echo_word16_t * | wtmp |
| echo_word16_t * | x |
| echo_word16_t * | X |
| echo_word32_t * | Xf |
| echo_word16_t * | y |
| echo_word16_t * | Y |
| echo_word32_t * | Yf |
| echo_word32_t * | Yh |
Friends | |
| echo_word32_t | operator* (int32_t scalar, const echo_float_t &f) |
This is the acoustic echo canceller module.
| using FloatAllocator = typename std::allocator_traits<Allocator>::template rebind_alloc<float> |
Rebound allocator for float vectors
|
inline |
Construct FFT state with specified size and driver.
| size | FFT size (number of points) |
| drv | Pointer to FFT driver implementation |
| alloc | Allocator instance for memory management |
|
inline |
Initialize echo canceller with single channel (mono)
| filterLength | Length of echo cancellation filter in samples |
| fftDriver | FFT driver instance from AudioFFT |
| alloc | Allocator instance (optional) |
|
inline |
Initialize echo canceller with multiple channels
| filterLength | Length of echo cancellation filter in samples |
| nbMic | Number of microphone channels |
| nbSpeakers | Number of speaker channels |
| fftDriver | FFT driver instance from AudioFFT |
| alloc | Allocator instance (optional) |
|
inline |
Destructor
|
inline |
Perform echo cancellation
| rec | Recorded signal (with echo) |
| play | Playback signal (reference) |
| out | Output signal (echo removed) |
|
inline |
Process captured audio with buffered playback
| rec | Recorded signal |
| out | Output signal (echo removed) |
|
inline |
Control/query echo canceller parameters
| request | Request type (ECHO_GET_FRAME_SIZE, etc.) |
| ptr | Pointer to parameter value |
|
inline |
Perform forward FFT.
| Allocator | Custom allocator type (must match the one used in echo_fft_init) |
| table | Opaque pointer to FFT state |
| in | Input time-domain signal (size N) |
| out | Output frequency-domain signal in packed format (size N) Format: [DC, real1, imag1, real2, imag2, ..., Nyquist] |
|
inline |
Destroy FFT state and release resources.
| Allocator | Custom allocator type (must match the one used in echo_fft_init) |
| table | Opaque pointer to FFT state returned by echo_fft_init |
|
inline |
Initialize FFT state.
| Allocator | Custom allocator type for memory management |
| size | FFT size (number of points) |
| driver | Pointer to FFT driver implementing AudioFFTBase interface |
| alloc | Allocator instance for memory management |
|
inline |
Perform inverse FFT.
| Allocator | Custom allocator type (must match the one used in echo_fft_init) |
| table | Opaque pointer to FFT state |
| in | Input frequency-domain signal in packed format (size N) Format: [DC, real1, imag1, real2, imag2, ..., Nyquist] |
| out | Output time-domain signal (size N) |
|
inlineprotected |
Allocate memory for array of type T using custom allocator.
| T | Type of objects to allocate |
| count | Number of objects to allocate |
|
inlineprotected |
Core echo cancellation implementation.
Implements the complete MDF echo cancellation algorithm including:
| st | Echo state structure containing all internal state |
| in | Input signal from microphones (interleaved if multi-channel) |
| far_end | Reference signal from speakers (interleaved if multi-channel) |
| out | Output signal with echo removed (interleaved if multi-channel) |
|
inlineprotected |
Deallocate memory using custom allocator.
| T | Type of objects to deallocate |
| ptr | Pointer to memory to deallocate |
| count | Number of objects (currently unused but kept for API compatibility) |
|
inlineprotected |
Initialize multi-channel echo canceller state.
| frame_size | Number of samples per frame |
| filter_length | Total filter length in samples |
| nb_mic | Number of microphone channels |
| nb_speakers | Number of speaker channels |
|
inlineprotected |
|
inline |
Get filter length
|
inline |
Get frame size
|
inline |
Get impulse response
| response | Buffer to store impulse response (must be pre-allocated) |
|
inline |
Get impulse response size
|
inline |
Get number of microphone channels
|
inline |
Get sampling rate
|
inline |
Get number of speaker channels
Get underlying state (for advanced usage)
|
inlineprotected |
Adjust proportional adaptation weights.
| W | Filter weights in frequency domain |
| N | FFT size |
| M | Number of filter blocks |
| P | Number of channels |
| prop | Output proportional weights (normalized) |
|
inlineprotected |
Compute inner product of two vectors.
| x | First input vector |
| y | Second input vector |
| len | Length of vectors |
|
inline |
Buffer playback signal for later processing
| play | Playback signal to buffer |
|
inlineprotected |
Compute power spectrum from FFT output.
| X | FFT output in packed format |
| ps | Output power spectrum |
| N | FFT size |
|
inlineprotected |
Accumulate power spectrum from FFT output.
| X | FFT output in packed format |
| ps | Accumulated power spectrum (updated in place) |
| N | FFT size |
|
inline |
Reset echo canceller state
|
inline |
Set FFT driver (must be called before first use)
| fftDriver | Reference to FFT driver instance |
|
inline |
Set filter length (must be called before first use)
| len | Length of echo cancellation filter in samples |
|
inline |
Set number of microphone channels (must be called before first use)
| num | Number of microphone channels |
|
inline |
Set sampling rate
| rate | Sampling rate in Hz |
|
inline |
Set number of speaker channels (must be called before first use)
| num | Number of speaker channels |
|
inlineprotected |
Accumulate spectral multiplication across multiple frames.
| X | Input spectrum (M frames) |
| Y | Filter weights in frequency domain |
| acc | Output accumulated result |
| N | FFT size |
| M | Number of frames to accumulate |
|
inlineprotected |
Compute cosine function.
| x | Input angle in radians |
|
inlineprotected |
Compute exponential function.
| x | Input value |
|
inlineprotected |
Compute weighted spectral multiplication with conjugate.
| w | Weight array for each frequency bin |
| p | Global scaling factor |
| X | First input spectrum |
| Y | Second input spectrum (conjugated) |
| prod | Output product |
| N | FFT size |
Allocator instance for memory management
| AudioFFTBase* driver |
Pointer to FFT driver implementation
|
protected |
Pointer to FFT driver instance
|
protected |
Length of echo cancellation filter
| int frame_size |
Number of samples processed each time
|
protected |
Lazy initialization flag
| int K |
Number of input channels (microphones)
| int N |
FFT size
|
protected |
Number of microphone channels
|
protected |
Number of speaker channels
| echo_int32_t sampling_rate |
Number of output channels (loudspeakers)
Pointer to internal echo canceller state
| std::vector<float, FloatAllocator> temp_img |
Temporary buffer for imaginary components
| std::vector<float, FloatAllocator> temp_real |
Temporary buffer for real components