Implementation of Goertzel algorithm written in Rust
Project description
fastgoertzel
A Python implementation of the Goertzel algorithm built using Rust
for improved run time and efficiency on large datasets and loops.
To-Do:
- Improved speed.
- Implement benchmarking for speed comparison
- add IIR and k-th FTT implementation of Goertzel.
- Add support for sampling rate.
Installation
You can install using two methods:
Using pip install
:
$ pip install fastgoertzel
Using maturin
after cloning repository:
$ git clone git://github.com/0zean/fastgoertzel.git
$ cd fastgoertzel
$ maturin develop
Usage
import numpy as np
import pandas as pd
import fastgoertzel as G
def wave(amp, freq, phase, x):
return amp * np.sin(2*np.pi * freq * x + phase)
x = np.arange(0, 512)
y = wave(1, 1/128, 0, x)
amp, phase = G.goertzel(y, 1/128)
print(f'Goertzel Amp: {amp:.4f}, phase: {phase:.4f}')
# Compared to max amplitude FFT output
ft = np.fft.fft(y)
FFT = pd.DataFrame()
FFT['amp'] = np.sqrt(ft.real**2 + ft.imag**2) / (len(y) / 2)
FFT['freq'] = np.fft.fftfreq(ft.size, d=1)
FFT['phase'] = np.arctan2(ft.imag, ft.real)
max_ = FFT.iloc[FFT['amp'].idxmax()]
print(f'FFT amp: {max_["amp"]:.4f}, '
f'phase: {max_["phase"]:.4f}, '
f'freq: {max_["freq"]:.4f}')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for fastgoertzel-0.1.0-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93b6d17ccb2e7b987f0976d53a42234918e906195b73090e973a7e97ccbf207e |
|
MD5 | dc7ada5dad05aae8c3102b6f873ce957 |
|
BLAKE2b-256 | 3d8e64ec09d2f197c769e92c4a7a3b7ff380628943f6912b63811d3c3ce50f5d |