AI-based Fourier Analysis using sinusoidal neural networks
Project description
AI-Based Fourier Analysis (aifourier)
“Machines can learn Fourier analysis.”
A Python library that approximates Fourier decomposition using a sinusoidal neural network.
Instead of explicitly computing Fourier integrals, this library learns the frequency components of a signal through optimization.
✨ Features
-
🔊 Analyze audio signals (
.wav,.mp3,.flac,.ogg) -
🧠 Neural network with sinusoidal activation
-
📊 Extract:
- Frequencies in Hz
- Phase shift
- Amplitude
-
⚡ Simple one-line API
-
📁 Output as Pandas DataFrame
📦 Installation
pip install aifourier
🚀 Usage
import aifourier as aif
df = aif.analyze("audio.mp3")
print(df.head())
📊 Output
The result is a DataFrame containing:
| Column | Description |
|---|---|
| Frequencies | Learned frequencies (Hz) |
| Phase shift | Phase of each component |
| Amplitudes | Contribution strength of each mode |
🧠 How It Works
The signal is approximated as:
y(t) ≈ Σ Aᵢ sin(ωᵢ t + φᵢ)
Where:
- Aᵢ = amplitude
- ωᵢ = angular frequency
- φᵢ = phase
These parameters are learned by a neural network instead of computed analytically.
⚙️ Parameters
aif.analyze(audio_path, max_modes=10000, epochs=256,use_phase_shift=True,learning_rate=0.00001,save_model=None,verbose=2,positive_freqs_only=True)
audio_path: Path to audio filemax_modes: Number of sinusoidal componentsepochs: Training iterations (higher = better approximation)use_phase_shift: If this set toFalse, all phase shifts are set to zero.learning_rate: Learning rate of NNsave_model: Path to save learned modelverbose: Modes to show training behavior, which can be set to 0,1,2.positive_freqs_only: If this set toTrue, this will keep the positive frequencies and delete the negative ones.
📁 Example
See the examples/ folder for a complete demo:
cd examples
python example.py
This will:
- Analyze
bird.mp3 - Generate frequency components
- Save results
- Plot the spectrum
The frequency spectrum of bird.mp3 is shown below:
⚖️ Comparison with FFT
| Method | Approach |
|---|---|
| FFT | Analytical, deterministic |
| aifourier | Learning-based, approximate |
This project explores whether neural networks can discover Fourier structure from data.
🚧 Limitations
- Approximation quality depends on training
- Slower than FFT
- Results may vary between runs
💡 Future Ideas
- Signal reconstruction from learned parameters
- FFT comparison mode
- Real-time signal analysis (oscilloscope / radio)
- Complex-valued extensions
👤 Author
Jovan, 2026
📜 License
MIT License
“What Fourier derives analytically, neural networks can approximate through learning.”
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aifourier-2.0.1.tar.gz.
File metadata
- Download URL: aifourier-2.0.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c45a5c8500bc2c9a678486067d78894e4768c509ee68a00e794a18309054f47e
|
|
| MD5 |
2cb3e74a54b7773f0bc413583c09fc28
|
|
| BLAKE2b-256 |
5a821a63f126b4a06982d17c5091e93f57b363ae3314715cbc9a753977be360a
|
File details
Details for the file aifourier-2.0.1-py3-none-any.whl.
File metadata
- Download URL: aifourier-2.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b408f8c994c37081c2dbc5b8b0ecb4dcf30849080119bbaf42d184577cd254a6
|
|
| MD5 |
e9bb7844cfa3f281022adda70bfaf53c
|
|
| BLAKE2b-256 |
e635e059358b77f6ca8f994feaaa480b96fbb8ad4c58498d71f95701c4a35c64
|