Audio spectrum with 128×32 display

Audio-Spektrum mit 128x32 Display

If a 8×8 LED matrix audio level meter is ​​insufficient for you, I’ll show you in this article how to use a small 128×32 display to view an audio spectrum.

How the visual representation of the spectrum should look like, you can set yourself. My version is a bar graph.

What you need

The hardware you need is the display itself. But in the I2C version with the driver IC SSD1306.

128x64 display for the audio spectrum
Example of a 128×64 display with SSD1306 driver IC

Like the 8×8 LED matrix there is needed a component of TMS software to control the 128×32 display. How to install it in Lazarus, I described in the article 8×8 LED matrix with Raspberry and Lazarus.

The components of TMS have been developed for the hardware of Adafruit. But it also works with other manufacturers.

I’m using a display with 128×64 pixels. Which unfortunately can be addressed only for 32 lines. But the result looks pretty useful too.

The great thing is that the program works just as you learned at the audio level meter article.

The connection to the display is done via the component TTMSLCLAdaDispl128x32. In the app sample I use the instance display, so that the amount of writing is a little smaller.

component TTMSCLCAdaDispl128x32 for visualizing the audio spectrum
Component TTMSLCLAdaDispl128x32

Initializing works very similar to the 8×8 LED matrix. The address for the I2C is hexadecimal 3C (or as decimal number: 60).


You can use the command i2cdetect -y 1 in a shell to get the address of your device.


The basic functions of the MP3 processing are the same as in the previous article. For the MP3 output the BASS library of is used again.

Audio spectrum

Example App created with Lazarus

The visualization of the audio spectrum is triggered by a timer event. As timer interval I use 100 ms.

In order to get the appropriate data in parallel to the sound output, the BASS library provides the function ChannelGetData.

 BASS_ChannelGetData(Channel, @FFTData, 1024);

With a few instructions, an audio spectrum can be generated from the data.

//Clear bitmap for screen output 

if CheckboxFilled.Checked=true then Bitmap.Canvas.Brush.Color:=clWhite;

if j*SpinEditColWidth.Value>127 then j:=j-1;
for i := 0 to j do begin

if YPosI>MaxBar then MaxBar:=YPosI;
if YPos>SpecHeight then YPos:=SpecHeight;
if YPos>=FFTPeacks[i] then FFTPeacks[i]:=YPos
else FFTPeacks[i]:=FFTPeacks[i]-PeakFall;
if YPos>=FFTFallOff[i] then FFTFallOff[i]:=YPos
else FFTFallOff[i]:=FFTFallOff[i]-LineFall;

if (SpecHeight-FFTPeacks[i])>SpecHeight then FFTPeacks[i]:=0;
if (SpecHeight-FFTFallOff[i])>SpecHeight then FFTFallOff[i]:=0;

//128x32 display output
if CheckboxFilled.Checked=true then

//screen output

//show screen

//show display

For your first tests it’s best to download the sample app and have a look at my spectrum display.

Have fun experimenting!


Source code of the sample app Miniplayer2
(with a directly executable application miniplayer2)


BASS library for Lazarus:

The basic routine for my app is based of the example Spectrum Visualyzation of Alessandro Cappellozza. Which is part of the BASS library.

Website of TMS Software:

TMS package on github:

Article 8×8 LED-Matrix with Raspberry and Lazarus

The MP3 sample files come from FRAMETRAXX : GEMA-free music

Lesen Sie diesen Artikel in Deutsch