PaulStoffregen / Audio

Teensy Audio Library
http://www.pjrc.com/teensy/td_libs_Audio.html
1.08k stars 401 forks source link

AnalyzeFFT256 is not completely ready for usage with BLOCK_SAMPLE=64 #379

Open CorBer opened 3 years ago

CorBer commented 3 years ago

Description

In the analyze_fft256 library some code seems to be missing to make this library work also with audio_block_samples of 64. The outputflag is NOT set and thus the routine never reports "available".

Steps To Reproduce Problem

Change #define AUDIO_BLOCK_SAMPLES to 64 in audioStream.h Any program that uses an AudioAnalyzeFFT256 will never get an FFT.available() report as the routine never sets the outputflag to TRUE.

Proposed changes

Minor changes are necessary in analyze_FFT256.cpp library to solve this:

line114 count = 2; <<<<<<<<<<<<<<<<< THIS SHOULD BE ZERO !! const uint32_t p = (uint32_t )buffer; for (int i=0; i < 128; i++) { uint32_t tmp = p++; int16_t v1 = tmp & 0xFFFF; int16_t v2 = tmp >> 16; output[i] = sqrt_uint32_approx(v1 v1 + v2 * v2); } outputflag=true; <<<<<<<<<<<<<<<<< THIS NEEDS TO BE ADDED

CorBer commented 3 years ago

Additionally line 109 of analyzeFFT256.cpp also has a mistake. This now reads: copy_to_fft_buffer(buffer+256, prevblocks[1]->data); but it should be copy_to_fft_buffer(buffer+256, prevblocks[0]->data);