Building a realtime spectral frame in RNBO (fftstream~ + Gen Data/Poke): best practice?
Hi everyone,
I'm working on a reusable spectral analysis framework in RNBO that will eventually become the frontend of a realtime adaptive DSP processor based on psychoacoustic descriptors (roughness, spectral centroid, spread, flux, peak detection, etc.).
The idea is to compute the STFT only once and then share the spectral data among multiple analysis modules.
At the moment I'm trying to build what I call a SpectralFrame, i.e. a memory structure containing the magnitude spectrum of the current FFT frame.
My intended processing chain is approximately:
Audio input → fftstream~ → real / Imaginary coefficients → magnitude (sqrt(real² + imag²)) → SpectralFrame (Data) → feature extraction modules
For now I'm only interested in storing magnitudes (not phase), since all the first features I plan to implement only require spectral magnitude.
In the current implementation I'm using:
fftstream~ (FFT size = 1024)
a Gen patch where I compute magnitude from the real and imaginary outputs
Data
poke
peek
The third outlet ("ramp") from fftstream~ is used as the write index.
The idea is simply:
Data[index] = magnitude
and later read any bin using peek.
But I'm currently facing several issues:
The ramp output from fftstream~ is difficult to inspect.
number~ mostly shows 0.
Using snapshot~ I can see the index quickly ramping through the expected values, so I assume the ramp itself is working correctly.
I cannot validate that Data is actually being written.
Initially peek always returned what looked like constant values for every bin.
After reopening the patch, peek now always returns 0 regardless of the selected index.
I also tried the equivalent approach using buffer~ + poke~ outside Gen, but I couldn't get any data written there either.
My questions:
Is Data + poke + peek inside Gen the correct approach for implementing a realtime spectral frame?
Is there a recommended or idiomatic way in RNBO to store one FFT frame so that it can later be accessed by other analysis algorithms?
Is fftstream~ the appropriate object for this purpose, or is there another workflow that is generally preferred for spectral analysis in RNBO?
Ultimately I'd like to build a modular spectral analysis library that can later be exported from RNBO (or even ported to Faust/C++), so I'm trying to choose the most robust architecture before implementing all the feature extraction modules.
I've attached screenshots of:
the RNBO patch
the Gen subpatch
Any advice or suggestions would be greatly appreciated.
Thanks!

