chipaudette / OpenAudio_ArduinoLibrary

Arduino Library for OpenAudio Hacking
120 stars 32 forks source link

FFT sizes greater than 512 cause the Teensy to crash. #24

Open ReeceKetley opened 5 months ago

ReeceKetley commented 5 months ago

When using the formant shifter setting sample size greater than 128 (256) which equates to 512 in the FFT size the Teensy crashes when trying to create the FFT object?

This is on a teensy 4.0 oveclocked to 712mhz

Is 512 the max I can get?

chipaudette commented 5 months ago

Hi Reece,

Due to constraints on how the Teensy Audio Library / Tympan_Library processes audio, you are forced to do an FFT (of whatever length) every time an audio block fills. By default, the audio block length inherited from the Teensy Audio library is 128 points long (per channel). If you use my Tympan FFT routines with an overlap of 75%, your maximum FFT size will indeed by 4*128 = 512 points. So, you can't go longer than this as long as your block size is only 128 points.

There are two solutions to you to get you more FFT resolution:

Even with these longer audio blocks, the Tympan_Library is still dependent upon the FFT quirks inherited from the Teensy Audio Library, which are somehow related to how they included the FFT functions from the ARM CMSIS libraries. I think that the maximum FFT size ends up being something like 4096 points, but I'm not sure. Beware!

If you still have trouble, please post a link to your code and I can maybe help you.

Chip

ReeceKetley commented 5 months ago

Hi Chip,

Thanks for the quick response! Ultimately, I'm trying to increase the quality of the formant shifting, which after some tweaking I have managed to staying within the 128 point restriction.

The formant shifter is to be used with only vocals, I was getting this weird aliasing, which I assumed was the FFT size. Anyway one of the solutions I came up with was to shift the frequency bands I'm processing (i.e. not from 20hz-20k) and only process where the vocals sit which has given me more bins which seems on the face of it to have made a difference.

Whenever I tried to set audio_block_samples higher than 128 points, it would just flat out crash when trying to create the FFT. But your explanation has cleared that up! Tympan Library is something I never stumbled across, I may need to check that out!

chipaudette commented 5 months ago

Oh, this is the OpenAudio library! Sorry! I got confused. I thought that you were posting on the Tympan_Library.

I created OpenAudio library first and then I created the Tympan_Library started. The OpenAudio library was then picked up and maintained by others (still in my GitHub account). So the two libraries share a lot of DNA, but each has had new developments that are independent of each other.

It's all confusing...even to me!