FFT, PSD and spectrogram plots
Inspect physical frequency bins and explicit spectral units, then export native charts.
// Deterministic CPU FFT, physical units and immutable native plots; no device.
import aner.audio
import aner.signal
import aner.tensor
import aner.plot
// 1024 samples, 64 exact cycles; the one-sided bin amplitude is 0.5.
let clip = audio.tone(seconds: 0.125, rate: 8192, frequency: 512.0, amplitude: 0.5)
let spectrum = signal.fft(clip, window: "rectangular")
print(signal.frequency(spectrum, 64))
print(signal.magnitude(spectrum, 64))
print(signal.power(spectrum, 64))
let reconstructed = signal.ifft(spectrum)
print(tensor.dim(reconstructed, 0))
print(tensor.dim(reconstructed, 1))
// Native min/max previews preserve narrow peaks without building sample Lists.
// Fresh filenames are required; exports never overwrite an existing file.
audio.waveform(clip, max_points: 256).title("Synthetic 512 Hz tone").save("signal-waveform.svg")
signal.spectrum_plot(spectrum, kind: "psd").save("signal-psd.svg")
Make it your experiment.
Use Aner 0.1.0 or newer. Save this program as examples/media/signal_spectrum.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/media/signal_spectrum.aner
aner run examples/media/signal_spectrum.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.1.0 or newer. Native PCM/WAV, synthesis, FFT and speech activity are available independently of optional FFmpeg and model backends. Decoding, resampling or local transcription requires the corresponding capability and separately supplied inputs or weights.
aner check examples/media/signal_spectrum.aner
aner run examples/media/signal_spectrum.anerBundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution