FFT Spectrum Display Demo#
Overview#
The FFT sample in the media chapter has been updated to a real-time audio spectrum display demo. It captures mono audio from AI, uses the FFT HAL for hardware FFT computation, and draws the spectrum bars on the screen through an OSD layer.
Unlike the older sample_fft, which only performed FFT/IFFT regression checks, the current sample focuses on end-to-end media-pipeline bring-up and covers:
audio capture (AI / I2S)
FFT HAL calls
VB/MMZ buffer usage
OSD layer rendering and display output
automatic landscape layout and frequency-axis rendering
If you only want to verify basic FFT HAL correctness, refer to the FFT HAL sample in the peripheral chapter.
Functional Description#
capture audio in real time and run hardware FFT
automatically use the panel in landscape mode to maximize horizontal spectrum resolution
draw the frequency scale and
Hzaxis label at the bottom of the spectrumsupport custom sample rate, FFT points, rotation angle, display size, and display gain
Source Location#
Demo source path: src/rtsmart/examples/mpp/sample_fft_display/main.c
Build and Run#
Build#
After building the firmware from the SDK root, the example ELF is generated in the RT-Smart sample directory.
Run#
After the board starts, enter /sdcard/app/examples/mpp and run:
./sample_fft_display.elf -c <connector_type> [options]
For example, for a 01Studio 480x800 panel:
./sample_fft_display.elf -c 20 -s 44100 -p 512
Parameter Description#
You can run ./sample_fft_display.elf -h to view the help output. The current version supports:
Parameter |
Description |
Default |
|---|---|---|
|
connector type, required, can be checked with |
none |
|
OSD width |
inferred automatically from the rotated panel size |
|
OSD height |
inferred automatically from the rotated panel size |
|
rotation angle, supports |
auto landscape |
|
audio sample rate |
|
|
FFT point count, power of 2 in the range |
|
|
display gain in dB |
|
Runtime Behavior#
After startup, the program prints logs similar to:
./sample_fft_display.elf -c 20 -s 44100 -p 512
FFT Spectrum: connector=20, panel=480x800, OSD=800x480, rotate=90, rate=44100, points=512, gain=0.0 dB
main start connector=20 panel=480x800 osd=800x480 rotate=90 rate=44100 points=512
before drv_fft_open
after drv_fft_open inst=0x7f9f2030
Running... press Ctrl+C to stop
The screen continuously shows:
spectrum bars
a frequency axis at the bottom
a title and live refresh rate at the top
Press Ctrl+C to exit.
Tip
The current sample uses the FFT HAL interface drv_fft_* instead of the legacy kd_mpi_fft* API. For interface details, refer to the FFT API documentation.
