“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.
-
🔊 Analyze audio signals (
.wav,.mp3,.flac,.ogg) -
🧠 Neural network with sinusoidal activation
-
📊 Extract:
- Angular frequency
- Phase shift
- Amplitude
-
⚡ Simple one-line API
-
📁 Output as Pandas DataFrame
pip install aifourierimport aifourier as aif
df = aif.analyze("audio.mp3", max_modes=128, epochs=300)
print(df.head())The result is a DataFrame containing:
| Column | Description |
|---|---|
| Frequencies | Learned angular frequencies (ω) |
| Phase shift | Phase of each component |
| Amplitudes | Contribution strength of each mode |
The signal is approximated as:
y(t) ≈ Σ Aᵢ sin(ωᵢ t + φᵢ)
Where:
- Aᵢ = amplitude
- ωᵢ = frequency
- φᵢ = phase
These parameters are learned by a neural network instead of computed analytically.
aif.analyze(audio_path, max_modes=128, epochs=64)audio_path: Path to audio filemax_modes: Number of sinusoidal componentsepochs: Training iterations (higher = better approximation)
See the examples/ folder for a complete demo:
cd examples
python example.pyThis will:
- Analyze
bird.mp3 - Generate frequency components
- Save results
- Plot the spectrum
| Method | Approach |
|---|---|
| FFT | Analytical, deterministic |
| aifourier | Learning-based, approximate |
This project explores whether neural networks can discover Fourier structure from data.
- Approximation quality depends on training
- Slower than FFT
- Results may vary between runs
- Signal reconstruction from learned parameters
- FFT comparison mode
- Real-time signal analysis (oscilloscope / radio)
- Complex-valued extensions
Jovan
MIT License
“What Fourier derives analytically, neural networks can approximate through learning.”