Adjust formatting

feature_setBlockSize
Chip Audette 8 years ago
parent 103614d0c9
commit 23d83ff444
  1. 24
      AudioEffectGain_F32.h
  2. 25
      AudioFilterFIR_F32.h

@ -24,18 +24,18 @@ class AudioEffectGain_F32 : public AudioStream_F32
//here's the method that does all the work
void update(void) {
//Serial.println("AudioEffectGain_F32: updating."); //for debugging.
audio_block_f32_t *block;
block = AudioStream_F32::receiveWritable_f32();
if (!block) return;
//apply the gain
//for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it
arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed!
//transmit the block and be done
AudioStream_F32::transmit(block);
AudioStream_F32::release(block);
//Serial.println("AudioEffectGain_F32: updating."); //for debugging.
audio_block_f32_t *block;
block = AudioStream_F32::receiveWritable_f32();
if (!block) return;
//apply the gain
//for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) block->data[i] = gain * (block->data[i]); //non DSP way to do it
arm_scale_f32(block->data, gain, block->data, block->length); //use ARM DSP for speed!
//transmit the block and be done
AudioStream_F32::transmit(block);
AudioStream_F32::release(block);
}
//methods to set parameters of this module

@ -36,6 +36,12 @@ class AudioFilterFIR_F32 : public AudioStream_F32
if (coeff_p && (coeff_p != FIR_F32_PASSTHRU) && n_coeffs <= FIR_MAX_COEFFS) {
arm_fir_init_f32(&fir_inst, n_coeffs, (float32_t *)coeff_p, &StateF32[0], block_size);
configured_block_size = block_size;
Serial.print("AudioFilterFIR_F32: FIR is initialized. N_FIR = "); Serial.print(n_coeffs);
Serial.print(", Block Size = "); Serial.println(block_size);
//} else {
// Serial.print("AudioFilterFIR_F32: *** ERROR ***: Cound not initialize. N_FIR = "); Serial.print(n_coeffs);
// Serial.print(", Block Size = "); Serial.println(block_size);
// coeff_p = NULL;
}
}
void end(void) { coeff_p = NULL; }
@ -59,7 +65,7 @@ class AudioFilterFIR_F32 : public AudioStream_F32
void AudioFilterFIR_F32::update(void)
{
audio_block_f32_t *block, *b_new;
audio_block_f32_t *block, *block_new;
block = AudioStream_F32::receiveReadOnly_f32();
if (!block) return;
@ -75,22 +81,29 @@ void AudioFilterFIR_F32::update(void)
// Just passthrough
AudioStream_F32::transmit(block);
AudioStream_F32::release(block);
//Serial.println("AudioFilterFIR_F32: update(): PASSTHRU.");
return;
}
// get a block for the FIR output
b_new = AudioStream_F32::allocate_f32();
if (b_new) {
block_new = AudioStream_F32::allocate_f32();
if (block_new) {
//check to make sure our FIR instance has the right size
if (block->length != configured_block_size) {
//doesn't match. re-initialize
Serial.println("AudioFilterFIR_F32: block size doesn't match. Re-initializing FIR.");
begin(coeff_p, n_coeffs, block->length); //initialize with same coefficients, just a new block length
}
//apply the FIR
arm_fir_f32(&fir_inst, (float32_t *)block->data, (float32_t *)b_new->data, block->length);
AudioStream_F32::transmit(b_new); // send the FIR output
AudioStream_F32::release(b_new);
arm_fir_f32(&fir_inst, block->data, block_new->data, block->length);
//Serial.print("AudioFilterFIR_F32: update(): fir_inst: ");
//Serial.print(fir_inst.numTaps); Serial.print(", ");
//Serial.print(fir_inst.pState[10]*1000.f); Serial.print(", ");
//Serial.print(fir_inst.pCoeffs[10]*1000.f); Serial.println();
AudioStream_F32::transmit(block_new); // send the FIR output
AudioStream_F32::release(block_new);
}
AudioStream_F32::release(block);
}

Loading…
Cancel
Save