Aubio Usage Guide
This project exposes aubio through Lua/Fennel submodules plus a set of Fennel helpers that compose common workflows. There is no aggregate aubio module; require the specific module you need.
Module Map
Registered via package.preload in src/lua_aubio.cpp:
aubio/vec: vector/matrix types + math utilitiesaubio/spectral: FFT/PVoc/MFCC/etc.aubio/temporal: pitch/onset/tempo/filters/resampleraubio/io: source/sink I/Oaubio/synth: sampler/wavetableaubio/utils: parameters, conversions, logging, audio-input bridging
Fennel convenience helpers live under assets/lua/aubio/helpers/ and are required as :aubio/helpers/... to avoid clashing with the C++ module names.
Quick Start
Pitch Detection (helper pipeline)
fennel
(local aubio-vec (require :aubio/vec))
(local pitch-helper (require :aubio/helpers/pitch))
(local hop 512)
(local input (aubio-vec.FVec hop))
(local pipeline (pitch-helper.new {:method "yin"
:buf 1024
:hop hop
:samplerate 44100}))
(pipeline:push input)
(local result (pipeline:result))Onset Detection From File
fennel
(local aubio-stream (require :aubio/helpers/stream))
(local onset-helper (require :aubio/helpers/onset))
(local hop 512)
(local stream (aubio-stream.from-source {:uri "assets/sounds/on.wav"
:hop hop}))
(local onset (onset-helper.new {:method "default"
:buf 1024
:hop hop
:samplerate (. stream :samplerate)}))
(local (read buf) ((. stream :iter)))
(when (> read 0)
(onset:push buf))
((. stream :source):close)Low-Overhead Microphone Routing
fennel
(local aubio-vec (require :aubio/vec))
(local aubio-utils (require :aubio/utils))
(local audio-input (require :audio-input))
(local input (aubio-vec.FVec 512))
(local mic (audio-input.AudioInput {:channels 1 :frames-per-buffer 512}))
(mic:start)
(local read (aubio-utils.audio-input-into-fvec mic input 512))Helper Modules
Use these helpers for common pipelines; they keep hot loops in C++ where possible.
aubio/helpers/vecmixdown-equal,mixdown-weightednormalize-peak,normalize-rmsapply-window
aubio/helpers/sourcestreamandloopiterators foraubio/io.Source
aubio/helpers/presetsvoice,musicsamplerate/buf/hop defaults
aubio/helpers/pitchnewreturns:push/:resultwith:value+:confidence
aubio/helpers/onsetnewreturns:push/:resultwith:onset+ timestamps
aubio/helpers/temponewreturns:push/:resultwith:beat,:bpm,:period
aubio/helpers/streamfrom-sourcereturns{ :iter :buffer :source :samplerate }from-audio-inputreturns{ :iter :buffer :input :frames :channels }
Direct Module Usage
If you need complete control, call aubio directly from the C++ modules:
aubio/temporal.Pitch|Onset|Tempofor detectorsaubio/io.Source|Sinkfor file I/Oaubio/vec.FVec|FMatfor buffersaubio/utilsfor logging, conversions, andaudio-input-into-fvec
Logging Control
fennel
(local aubio-utils (require :aubio/utils))
(local log-levels (. aubio-utils :log-levels))
(aubio-utils.log-set-level (. log-levels :err)
(fn [level name message]
(print (.. "aubio[" name "] " message))))
(aubio-utils.log-reset)Performance Notes
- Streaming reads and detector work are already in C++ via aubio bindings.
- Mixdown and normalization helpers call C++
aubio/vecfunctions. - If a new helper does per-sample loops in Fennel, consider moving it into
aubio/vec.
Tests
Helpers and integration tests live in:
assets/lua/tests/test-aubio.fnlassets/lua/tests/test-aubio-helpers.fnlassets/lua/tests/test-aubio-pipelines.fnlassets/lua/tests/test-aubio-stream.fnl
Audio input tests are gated behind SPACE_TEST_AUDIO_INPUT and skipped when SPACE_DISABLE_AUDIO=1.
