Select Page

Music Visualizer

ABSTRACT
This report contains the concept and way to implement music visualizer on TIVA-TM4C123G Board with Neo-pixel LEDs array and
BOOSTER-K350QVG display.

INTRODUCTION
Music Visualizer is a very useful tool to analyse the different frequency component present in the sound waves. It is also used
to detect the noise component and helps in desigining appropriate filters to remove it. It is also used as a decoration on speakers
these days. The algorithm behind the working of this is discrete fourier transform.

DISCRETE F OURIER T RANSFORM
Discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence
of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency. The
interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence. The DFT of a sequence xn is given
below:

 

 

 

 

 

 

 

 

where W = e(− j2π/N) and W = W 2N … =1.
But the time complexity of DFT is N 2 which is not good for real time applications.
So, a variant of DFT is used which is called Fast Fourier Transform.
III
FAST F OURIER T RANSFORM
The fast Fourier transform is a method that allows O(nlogn) computing the DFT in time. The basic idea of the FFT is to apply
divide and conquer. We divide the coefficient vector of the polynomial into two vectors, recursively compute the DFT for each
of them, and combine the results to compute the DFT of the complete polynomial. So let there be a polynomial with degree n-1
, where n is a power of 2, and n>1,
F(x) = a0 + a1 x + ……. + an−1 xn−1
We divide it into two smaller polynomials, the one containing only the coefficients of the even positions, and the one con-

taining the coefficients of the odd positions:
n
F0 (x) = a0 + a2 x2 …… + an−2 x 2 −1
n
F0 (x) = a1 + a3 x2 …… + an−1 x 2 −1
Then it is easy to write

F(x) = F0 (x2 ) + x1 F(x2 )
If yk is the DFT of F(x) then it can be written as below:
yk = y0k + wkn y1k
where, k = 0,1,….. 2n − 1
and
yk+n/2 = y0k − wkn y1k
where, k = 0,1,…… n2 − 1
Thus, FFT takes O(nlogn) time.

 

 

 

 

 

 

 

 

IV
S ETUP
In this project, TIVA TM4C123G is used for all the fft computation, sampling and LED matrix driving. LEDs are Neo-Pixel
LEDs which are addresseable LEDs. A waveshare mic is used for sampling the audio. Song’s 1024 samples are sampled at
8192Hz and then given to 64 points FFT algorithm. The output is then averaged in 8 bins and then given to Neo-Pixel array of 8
lines. The setup configuration is given below:

 

 

 

 

 

 

 

 

4.1
INDIAN I NSTITUTE OF S CIENCE
Neo-Pixel LEDs
Neo-pixel LEDs come in form of an array and one LEDs Data out is connected to Data in of next LED in the array. The data
transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller,
the first pixel collect initial 24bit data then sent to the internal data latch, the other data which reshaping by the internal signal
reshaping amplification circuit sent to the next cascade pixel through the DO port.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4.1.1
Neo-Pixel LEDs wave generation
Waves are generated by writing “nop” after making pulse high and then pulling it to low. All the experiments done and verified
on Digital Oscilloscope. Waveforms are given in Figure 8 and Figure 9.

Figure 8: Zero Pulse Timing

 

 

 

 

 

 

 

 

 

 

Figure 9: One Pulse Timing

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4.2
Waveshare Mic
Waveshare mic provides analog and digital output. There are separate pins for both options.

Figure 10: Waveshare Mic

 

 

 

 

 

 

 

 

 

 

The pin configuration is given below:
VCC ↔ 3.3V ˜ 5.3V
GND ↔ power supply ground
AOUT ↔ MCU.IO (analog output)
DOUT ↔ MCU.IO (digital output)

4.3
Tiva TM4C123G Board
The TM4C123G LaunchPad Evaluation Kit is a low-cost evaluation platform for Arm Cortex-M4F based microcontrollers. Fea-
turing a 80-MHz Arm Cortex-M4F CPU, 256kB of flash, and 32kB of SRAM, the TM4C123GH6PM MCU provides integrated
USB 2.0 support for USB Host/Device/OTG and two 12-bit ADC modules. The TM4C123GH6PM also includes a multitude
of serial communication channels such as UART, SPI, I2C, and CAN. The design of the TM4C123G LaunchPad highlights the
TM4C123GH6PM USB 2.0 device interface and additional device features such as the hibernation and PWM modules.

Figure 11: TM4C123G

 

 

 

 

 

 

 

 

4.4
Booster-K350QVG Display by Kentec
This booster lcd display works on SPI communication, and is very handy for touch screen applications. There is a library
provided by Tivaware called Grlib.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

RESULTS
The FFT is algorithm is written for any number of n(multiple of 2). The result of this FFT algorithm is accurate and compared
with MATLAB’s FFT algorithm.

Figure 14: FFT comparision with MATLAB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The output shown on LED matrix is shown in the figure 15.

 

 

 

 

 

 

 

 

 

 

 

 

 

KENTEC DISPLAY S ETUP AND RESULT
For this demo, 100 arrays each having 16 elements is stored in the microcontroller. Then, it is passed to the FFT function and
16 values generated by FFT function is then converted to absolute values. These values are displayed on the display in form of
vertical slider with no active touch option. The demo snapshot is shown in figure 16.

Figure 16: FFT result on Kentec Display

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CONCLUSION:
There is a timing problem in LED Matrix at high sampling rate which can be solved by increasing the operating frequency of the
microcontroller. So, with faster microcontroller board, bigger FFT can be done and shown on the LED matrix. Further the LED
matrix can be controlled using SPI protocol by controlling its clock frequency which matches 1 and 0 of the neo-pixel timing.

Code: 

ESD_MINIPROJ_CODES

Kentec_display_demo_code

Demo: demo video