Make realtime Discrate fournier transform from i2S mic
Re: Make realtime Discrate fournier transform from i2S mic
This should works because the 2 fondamentals are far higher than the beating frequency.
1) Do I need to do a hilbert transform before doing what you proposed me ?
2) How can I do low pass filter with micropython ?
3) Thanks a LOT
1) Do I need to do a hilbert transform before doing what you proposed me ?
2) How can I do low pass filter with micropython ?
3) Thanks a LOT
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Make realtime Discrate fournier transform from i2S mic
- No
- See micropython-filters
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Make realtime Discrate fournier transform from i2S mic
Gosh, I don't know assembler
I will have a look. Thanks a lot !
I will have a look. Thanks a lot !
Re: Envelope extraction
Could I start from this file ?
https://github.com/peterhinch/micropyth ... ter/lpf.py
https://github.com/peterhinch/micropyth ... ter/lpf.py
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Make realtime Discrate fournier transform from i2S mic
That imports fir.py which uses STM Assembler, so will only run on Pyboards and similar. I suggest you read up on FIR filtering: it really is very simple - just a weighted moving average. Writing a Python version of fir.py would be easy.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Make realtime Discrate fournier transform from i2S mic
I never learn assembler at school
I will try to make it with your comments !
In all the case I will need the table with the coefficient right ?
I will try to make it with your comments !
In all the case I will need the table with the coefficient right ?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Make realtime Discrate fournier transform from i2S mic
You need two arrays, one containing the data and the other the N coefficients. The result is the sum of the products of matching elements of the two arrays. The one challenge is dealing with moving the data through the array. In a realtime solution such as mine this can be done with a circular buffer. If you're not using realtime data your data array will hold the entire sample set, so you only need to change the array index to point to the next N data values to generate successive filtered results.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Make realtime Discrate fournier transform from i2S mic
My application is realtime
I will use a buffer
I will use a buffer
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Make realtime Discrate fournier transform from i2S mic
Curiosity got the better of me so I simulated this:
with this outcome:
Note that the filtering is a crude single pole IIR design: trivial to code but not too effective.
Code: Select all
from math import sin, cos, pi
from array import array
import matplotlib.pyplot as plt
length = 800
a = array('f', (0 for _ in range(length)))
b = array('f', (0 for _ in range(length)))
f = 0.0 # Filtered result
for n in range(length):
a[n] = sin(n *2 * pi / 20) + 0.9 * sin(n * 2 * pi * 22 /(20 * 20))
if a[n] < 0:
a[n] = -a[n]
f += a[n]
f -= f/20 #IIR single pole filter
b[n] = f
plt.plot(range(length), b)
plt.show()
Note that the filtering is a crude single pole IIR design: trivial to code but not too effective.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Make realtime Discrate fournier transform from i2S mic
Good !
How to find the fundamental frequency of this output in micropython with a realtime optimization ? i should double it due to absolute value opération right ?
You think I should use a fft ?
Best
Ewen
How to find the fundamental frequency of this output in micropython with a realtime optimization ? i should double it due to absolute value opération right ?
You think I should use a fft ?
Best
Ewen