Hello,
I want to do a windowed overlap-add fft/ifft but apparently I have to transmit the audio block directly every time update gets called
I can't hold to it and release it when I want, I get hashed signal on the scope, only one block appears
with a 256 points fft/ifft buffer = [first 128 points][second 128 points][256 points overlapp]
- set the first 128 points on arrival of the first block
- set the second half of the 128 points when I receive the second audio block
- window the first 256 points
- calc the 256 points fft/ifft and return the two audio blocks
how can I achieve that ?
regards
I want to do a windowed overlap-add fft/ifft but apparently I have to transmit the audio block directly every time update gets called
I can't hold to it and release it when I want, I get hashed signal on the scope, only one block appears
with a 256 points fft/ifft buffer = [first 128 points][second 128 points][256 points overlapp]
- set the first 128 points on arrival of the first block
- set the second half of the 128 points when I receive the second audio block
- window the first 256 points
- calc the 256 points fft/ifft and return the two audio blocks
how can I achieve that ?
regards
Code:
// 2x128 [-----INPUT DATA-----------]
#define FFT_INPUT_LENGTH AUDIO_BLOCK_SAMPLES*2 // 256
// 2x256 [-----FFT OUTPUT REAL------][-----FFT OUTPUT COMPLEX------]
#define FFT_OUT_LENGTH FFT_INPUT_LENGTH*2 // 512
// 1024 [-----FFT OUTPUT REAL------][-----FFT OUTPUT COMPLEX------][------------OVERLAP ADD----------------------------------]
#define FFT_OUT_OVERLAP_LENGTH FFT_OUT_LENGTH*2 // 1024
float32_t fft_buffer[FFT_OUT_LENGTH]; // fft need double cheese buffer -> 256 samples
arm_cfft_radix4_instance_f32 fft;
arm_cfft_radix4_instance_f32 ifft;
uint32_t doBitReverse = 1;
audio_block_t *blockHigh;
audio_block_t *blockLow;
void Filter::calcFFT(boolean high, audio_block_t *block)
{
if(!high)
{
blockLow = block;
//-------------------------------- fill first 128 bytes
for(int i=0;i<AUDIO_BLOCK_SAMPLES;i++)
{
int32_t signedValue = block->data[i];
fft_buffer[i]=0.5+((float32_t)(signedValue))/(float32_t)65535;
}
}
else
{
blockHigh = block;
//-------------------------------- fill second 128 bytes
for(int i=0;i<AUDIO_BLOCK_SAMPLES;i++)
{
int32_t signedValue = block->data[i];
fft_buffer[i+AUDIO_BLOCK_SAMPLES]=0.5+((float32_t)(signedValue))/(float32_t)65535;
}
//---------------------------------------- fill overlap add (256 bytes)
for(int i=0;i<FFT_INPUT_LENGTH;i++)
{
fft_buffer[i+FFT_INPUT_LENGTH]=0;
}
//----------------------------------------- ready for fft/ifft
//apply_window_to_fft_buffer(fft_buffer, window);
// fft here ...
// ...
// ifft here ...
transmit(blockLow);
transmit(blockHigh);
}
}
void Filter::update()
{
audio_block_t *block;
block = receiveWritable();
if (block) {
calcFFT(flipflop, block);
flipflop=!flipflop;
release(block);
}
}
Last edited: