FFT with micropython

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
zaord
Posts: 96
Joined: Fri Jan 31, 2020 3:56 pm

FFT with micropython

Post by zaord » Thu Apr 16, 2020 5:49 pm

Hi,

I do some research in musical acoustics and I would needs to perfoms FFT for musical multiple tones tuning appllication and I would like to use micropython.
I wants to to implement a FFT made on ADC signal obtain by an electret microphone and I need to find the fundamental frequencies of multiple signals produced for exemple by organ flutes.

Considering that I wants to tune for exemple the beat produced by two different flutes with a frequency slightly different, I wants to have with precision the two fundamental frequencies of those two flute to une them.
I need after all to compare those frequencies with a frequency table giving the frequency I wants in certain musical temperament to perform the tuning because actualy I need to mute one of those two flute but when they play together, there is a vibroacoustic coupling and the frequency is slightily different.

If anyone have the idea how to perform this in python / micropython, I will be so happy because I have some lack of knowledge in computation and coding.

Thanks by advance,

Z.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: FFT with micropython

Post by jimmo » Fri Apr 17, 2020 4:03 am

The two FFT implementations I'm aware of are:
- https://github.com/peterhinch/micropython-fourier (I've used this, it works really well on Pyboard, but looks like you're on ESP32 so unsure how you're going to go here)
- https://github.com/v923z/micropython-ulab (more info at https://micropython-ulab.readthedocs.io/en/latest/ ) (Basically Numpy for MicroPython -- You'll have to build your own firmware to use this on ESP32 I think though).

The authors of both libraries are active on this forum.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: FFT with micropython

Post by pythoncoder » Fri Apr 17, 2020 6:36 am

Mine uses STM assembler so it won't work on ESPx - micropython-ulab is the way to go.
Peter Hinch
Index to my micropython libraries.

zaord
Posts: 96
Joined: Fri Jan 31, 2020 3:56 pm

Re: FFT with micropython

Post by zaord » Fri Apr 17, 2020 3:04 pm

Hi Peter,

Regarding my case, do you have any idea to perform a polyphonic pitch tracking with micropython ?
I wonder if the FFT is really the optimal way to compute this regarding accuracy (0.1 cents).

Regarding this work, https://miracle.otago.ac.nz/tartini/pap ... _Pitch.pdf I wonder if this could be implemented algorythm like Square Difference Functions on micropython ?

I don't know if you have any directions for me to go for go further or if you have any idea or python code exemple to perform polyphonic pitch tracking.

Thanks for all contributions you give to micropython communauty !

Best, Z.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Polyphonic pitch tracking?

Post by pythoncoder » Fri Apr 17, 2020 3:38 pm

I'm afraid that's way outside my experience. I can't recall anyone else asking that question. I'd try a web search for algorithms. As for implementation you might have to port someone's code to MicroPython.
Peter Hinch
Index to my micropython libraries.

Post Reply