Add invert phase DSP filter

This commit is contained in:
Niccolò Izzo 2021-06-27 19:00:06 +02:00 committed by Silvano Seva
parent be21364b30
commit 3439f3a497
2 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,15 @@ void dsp_pwmCompensate(audio_sample_t *buffer, size_t length);
*/
void dsp_dcRemoval(audio_sample_t *buffer, size_t length);
/*
* Inverts the phase of the audio buffer passed as paramenter.
* The buffer will be processed in place to save memory.
*
* @param buffer: the buffer to be used as both source and destination.
* @param length: the length of the input buffer.
*/
void dsp_invertPhase(audio_sample_t *buffer, uint16_t length);
#ifdef __cplusplus
}

View File

@ -57,9 +57,11 @@ void dsp_applyFIR(audio_sample_t *buffer,
uint16_t length,
std::array<float, order> taps)
{
for(int i = length - 1; i >= 0; i--) {
for(int i = length - 1; i >= 0; i--)
{
float acc = 0.0f;
for(uint16_t j = 0; j < order; j++) {
for(uint16_t j = 0; j < order; j++)
{
if (i >= j)
acc += buffer[i - j] * taps[j];
}