Browse Source

Merge pull request #11 from robsoles/master

fix for compounding/cascading filters
dds
Paul Stoffregen 11 years ago
parent
commit
3fdd2654b5
2 changed files with 15 additions and 11 deletions
  1. +10
    -9
      filter_biquad.cpp
  2. +5
    -2
      filter_biquad.h

+ 10
- 9
filter_biquad.cpp View File

@@ -34,7 +34,6 @@ void AudioFilterBiquad::update(void)
uint32_t in2, out2, aprev, bprev, flag;
uint32_t *data, *end;
int32_t *state;

block = receiveWritable();
if (!block) return;
data = (uint32_t *)(block->data);
@@ -73,19 +72,26 @@ void AudioFilterBiquad::update(void)
*state++ = sum | flag;
*(state-2) = bprev;
*(state-3) = aprev;
data = (uint32_t *)(block->data); // needs to be reset, may as well be done here
} while (flag);
transmit(block);
release(block);
}

void AudioFilterBiquad::updateCoefs(int *source, bool doReset)
void AudioFilterBiquad::updateCoefs(uint8_t set,int *source, bool doReset)
{
int32_t *dest=(int32_t *)definition;
int32_t *src=(int32_t *)source;
while(set)
{
*dest+=7;
if(!(*dest&0x80000000)) return;
*dest++;
set--;
}
__disable_irq();
for(uint8_t index=0;index<5;index++)
{
*dest++=*src++;
*dest++=*source++;
}
if(doReset)
{
@@ -96,8 +102,3 @@ void AudioFilterBiquad::updateCoefs(int *source, bool doReset)
__enable_irq();
}

void AudioFilterBiquad::updateCoefs(int *source)
{
updateCoefs(source,false);
}


+ 5
- 2
filter_biquad.h View File

@@ -36,8 +36,11 @@ public:
: AudioStream(1, inputQueueArray), definition(parameters) { }
virtual void update(void);
void updateCoefs(int *source, bool doReset);
void updateCoefs(int *source);
void updateCoefs(uint8_t set,int *source, bool doReset);

void updateCoefs(uint8_t set,int *source) { updateCoefs(set,source,false); }
void updateCoefs(int *source, bool doReset) { updateCoefs(0,source,doReset); }
void updateCoefs(int *source) { updateCoefs(0,source,false); }
private:
int *definition;
audio_block_t *inputQueueArray[1];

Loading…
Cancel
Save