Skip to main content

AI-based Fourier Analysis using sinusoidal neural networks

Project description

AI-Based Fourier Analysis (aifourier)

aifourier_logo

“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,abs_amplitudes=True,optimizer='adam')
  • audio_path : Path to audio file.
  • max_modes : Number of sinusoidal components.
  • epochs : Training iterations (higher = better approximation).
  • use_phase_shift : If this set to False, all phase shifts are set to zero.
  • learning_rate : Learning rate of NN.
  • save_model : Path to save learned model.
  • verbose : Modes to show training behavior, which can be set to 0,1,2.
  • positive_freqs_only : If this set to True, this will keep the positive frequencies and delete the negative ones.
  • abs_amplitudes : If this set to True, all negative amplitudes will be positive-valued.
  • optimizer : The optimizer for training.

📁 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:

Spectrum of bird.mp3


⚖️ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aifourier-3.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aifourier-3.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file aifourier-3.0.0.tar.gz.

File metadata

  • Download URL: aifourier-3.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for aifourier-3.0.0.tar.gz
Algorithm Hash digest
SHA256 df5512697efac410052e3dce5c3eea7d0d1d30e0fff82c4868d0be207accef6e
MD5 60dbcfaf37682da68ca2706fb9f89a5f
BLAKE2b-256 c253e655766b3a6224fb109896954a5c673d00cefba0daecf98dba634e14058a

See more details on using hashes here.

File details

Details for the file aifourier-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: aifourier-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for aifourier-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f82e34aaebbf574793f1a02f2dd4e62b89072f870da80116ffdee17b67af9263
MD5 d48a614dd699bcebce135f808b2f6745
BLAKE2b-256 643da5b79868a0d289fa9b042ebd1588894b0b50c366e484be0f808f22c08359

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page