You are on page 1of 20

TABLE OF CONTENTS

1. Abstract
2. Introduction
3. Problems
4. Solution
5. Result
6. References
1. Abstract:
The TMDX5515eZDSP is a
small form factor, very low-cost
USB-powered DSP development
tool which includes all the hardware
and software needed to evaluate the
industry’s lowest power 16-bit
DSP: TMS320C5515. This tool is
similar to TMDX5505eZdsp in the
form factor but provides more
evaluation options such as USB 2.0
and SD interface. The USB port
provides enough power to operate the ultra-low-power C5515 so no external
power supply is required. This ultra- low-cost tool allows quick and easy
evaluation of the advanced capabilities of the C5515, C5514, C5505A and
C5504A processors. This tool has embedded XDS100 emulator for full source
level debug capability and supports Code Composer Studio4.0™ integrated
development environment (IDE) and eXpressDSP™ software which includes
the DSP/BIOS™ kernel. The TMDX5515eZDSP has a range of signal
processing applications, including voice recorder, musical instruments, portable
medical solutions and other consumer electronics in industrial and security
applications.

1
2. Introduction:
Sound is essentially vibrating waves (usually in air), and one of the most
fundamental units of sound is frequency. The human ear is capable of
hearing the sound frequency range from 20Hz to 20kHz (frequencies
ranging from 20 to 20,000 times / second). And for easy determination,
people often divide this audio frequency range into 3 basic frequency
ranges, which are Bass, Mid and Treble. Frequencies that go beyond the
20Hz to 20kHz limit are referred to as infrasound (below 20Hz) and

ultrasound (higher than 20kHz).


The fact that our cars, rooms, and speakers are in various shapes, sizes,
and configurations, the same note from the same instrument can sound
completely different. For example, some venues will respond better to bass
frequencies, so the EQ can be turned down on that end to prevent feedback
and turned slightly up on the higher end to even things out. In general, you
equalize for the physical space, to account for the particular combination of
the room and equipment. That’s why we need equalizer.
Equalizers are software or hardware filters that adjust the loudness of
specific frequencies. In the field of audio electronics, the term
"equalization" (or "EQ") has come to include the adjustment of frequency
responses for practical or aesthetic reasons, often resulting in a net response
that is not actually "flat". The term EQ specifically refers to this variant of

2
the term. In this topic, we will adjust the loudness of the signal on 3 specific
bands: 400hz, 1600hz, 4000hz.

3
3. Problem:

3 bands equalizer with


f 01=400 Hz , f 02=1600 Hz , f 03=4000 Hz

4. Solution:
In this report, we will use the MATLAB Simulink to implement the
3-band-equalizer (f1=400hz, f2=1600hz, f3=4000hz). We need some
spectrum scopes to observe the frequency spectrum of the signals and we
will use the digital filter design to filter, which we need 3 pieces.
The config of each piece is shown as below:

The config of the 400hz bandpass filter.

4
The config of the 1600hz bandpass filter.

5
The config of the 4000hz bandpass filter.

6
This is the whole equalizer on 3 bands: 400hz, 1600hz, 4000hz.

7
Programming code:
#include "equlizer.h"
#include "equlizer_private.h"
/* Block signals (default storage) */
B_equlizer_T equlizer_B;
/* Block states (default storage) */
DW_equlizer_T equlizer_DW;
/* Real-time model */
RT_MODEL_equlizer_T equlizer_M_;
RT_MODEL_equlizer_T *const equlizer_M = &equlizer_M_;
/* Model step function */
void equlizer_step(void)
{
char_T *sErr;
void *audio;
int32_T k;
real_T acc1;
real_T acc2;
int32_T i;
int32_T j;
int32_T statesOffset;
int32_T samplesOffset;
/* S-Function (sdspwmmfi2): '<Root>/From Multimedia File' */
sErr = GetErrorBuffer(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
audio = (void *)&equlizer_B.FromMultimediaFile[0U];
LibOutputs_FromMMFile(&equlizer_DW.FromMultimediaFile_HostLib[0U],
GetNullPointer(), audio, GetNullPointer(),
GetNullPointer(), GetNullPointer());
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);
rtmSetStopRequested(equlizer_M, 1);
}
/* End of S-Function (sdspwmmfi2): '<Root>/From Multimedia File' */
/* DiscreteFir: '<S3>/Digital Filter' */
for (k = 0; k < 2; k++) {
statesOffset = k * 697;
samplesOffset = k << 10;
/* Consume delay line and beginning of input samples */
for (i = 0; i < 697; i++) {
acc1 = 0.0;
for (j = 0; j < i + 1; j++) {
acc2 = equlizer_B.FromMultimediaFile[(samplesOffset + i) - j] *
equlizer_P.DigitalFilter_Coefficients[j];

8
acc1 += acc2;
}
for (j = 0; j < 697 - i; j++) {
acc1 += equlizer_P.DigitalFilter_Coefficients[(i + j) + 1] *
equlizer_DW.DigitalFilter_states[statesOffset + j];
}
equlizer_B.DigitalFilter[samplesOffset + i] = acc1;
}
/* Consume remaining input samples */
for (i = samplesOffset + 697; i < samplesOffset + 1024; i++) {
acc1 = 0.0;
for (j = 0; j < 698; j++) {
acc2 = equlizer_B.FromMultimediaFile[i - j] *
equlizer_P.DigitalFilter_Coefficients[j];
acc1 += acc2;
}
equlizer_B.DigitalFilter[i] = acc1;
}

/* Update delay line for next frame */


for (i = 0; i < 697; i++) {
equlizer_DW.DigitalFilter_states[(statesOffset - i) + 696] =
equlizer_B.FromMultimediaFile[(samplesOffset + i) + 327];
}
}
/* End of DiscreteFir: '<S3>/Digital Filter' */
/* Gain: '<Root>/Gain3' */
for (i = 0; i < 2048; i++) {
equlizer_B.Gain3[i] = equlizer_P.Gain3_Gain * equlizer_B.DigitalFilter[i];
}
/* End of Gain: '<Root>/Gain3' */
/* DiscreteFir: '<S1>/Digital Filter' */
for (k = 0; k < 2; k++) {
statesOffset = k * 697;
samplesOffset = k << 10;
/* Consume delay line and beginning of input samples */
for (i = 0; i < 697; i++) {
acc1 = 0.0;
for (j = 0; j < i + 1; j++) {
acc2 = equlizer_B.FromMultimediaFile[(samplesOffset + i) - j] *
equlizer_P.DigitalFilter_Coefficients_j[j];
acc1 += acc2;
}

9
for (j = 0; j < 697 - i; j++) {
acc1 += equlizer_P.DigitalFilter_Coefficients_j[(i + j) + 1] *
equlizer_DW.DigitalFilter_states_k[statesOffset + j];
}
equlizer_B.DigitalFilter[samplesOffset + i] = acc1;
}
/* Consume remaining input samples */
for (i = samplesOffset + 697; i < samplesOffset + 1024; i++) {
acc1 = 0.0;
for (j = 0; j < 698; j++) {
acc2 = equlizer_B.FromMultimediaFile[i - j] *
equlizer_P.DigitalFilter_Coefficients_j[j];
acc1 += acc2;
}
equlizer_B.DigitalFilter[i] = acc1;
}
/* Update delay line for next frame */
for (i = 0; i < 697; i++) {
equlizer_DW.DigitalFilter_states_k[(statesOffset - i) + 696] =
equlizer_B.FromMultimediaFile[(samplesOffset + i) + 327];
}
}
/* End of DiscreteFir: '<S1>/Digital Filter' */
/* Gain: '<Root>/Gain1' */
for (i = 0; i < 2048; i++) {
equlizer_B.Gain1[i] = equlizer_P.Gain1_Gain * equlizer_B.DigitalFilter[i];
}
/* End of Gain: '<Root>/Gain1' */
/* DiscreteFir: '<S2>/Digital Filter' */
for (k = 0; k < 2; k++) {
statesOffset = k * 871;
samplesOffset = k << 10;
/* Consume delay line and beginning of input samples */
for (i = 0; i < 871; i++) {
acc1 = 0.0;
for (j = 0; j < i + 1; j++) {
acc2 = equlizer_B.FromMultimediaFile[(samplesOffset + i) - j] *
equlizer_P.DigitalFilter_Coefficients_n[j];
acc1 += acc2;
}
for (j = 0; j < 871 - i; j++) {
acc1 += equlizer_P.DigitalFilter_Coefficients_n[(i + j) + 1] *

10
equlizer_DW.DigitalFilter_states_c[statesOffset + j];
}
equlizer_B.DigitalFilter[samplesOffset + i] = acc1;
}
/* Consume remaining input samples */
for (i = samplesOffset + 871; i < samplesOffset + 1024; i++) {
acc1 = 0.0;
for (j = 0; j < 872; j++) {
acc2 = equlizer_B.FromMultimediaFile[i - j] *
equlizer_P.DigitalFilter_Coefficients_n[j];
acc1 += acc2;
}
equlizer_B.DigitalFilter[i] = acc1;
}
/* Update delay line for next frame */
for (i = 0; i < 871; i++) {
equlizer_DW.DigitalFilter_states_c[(statesOffset - i) + 870] =
equlizer_B.FromMultimediaFile[(samplesOffset + i) + 153];
}
}
/* End of DiscreteFir: '<S2>/Digital Filter' */
/* Sum: '<Root>/Sum' incorporates:
* Gain: '<Root>/Gain2'
*/
for (i = 0; i < 2048; i++) {
equlizer_B.Sum[i] = (equlizer_B.Gain3[i] + equlizer_B.Gain1[i]) +
equlizer_P.Gain2_Gain * equlizer_B.DigitalFilter[i];
}
/* End of Sum: '<Root>/Sum' */

/* S-Function (saudioToAudioDevice): '<Root>/Audio Device Writer' */


sErr =
GetErrorBuffer(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
LibUpdate_Audio(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U],
&equlizer_B.Sum[0U], 0, 1024, 0U);
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);
rtmSetStopRequested(equlizer_M, 1);
}
/* End of S-Function (saudioToAudioDevice): '<Root>/Audio Device Writer' */
/* Matfile logging */
rt_UpdateTXYLogVars(equlizer_M->rtwLogInfo, (&equlizer_M-
>Timing.taskTime0));

11
/* signal main to stop simulation */
{
/* Sample time: [0.023219954648526078s, 0.0s] */
if ((rtmGetTFinal(equlizer_M)!=-1) &&
!((rtmGetTFinal(equlizer_M)-equlizer_M->Timing.taskTime0) >
equlizer_M->Timing.taskTime0 * (DBL_EPSILON))) {
rtmSetErrorStatus(equlizer_M, "Simulation finished");
}
}
/* Update absolute time for base rate */
/* The "clockTick0" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick0"
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
* overflow during the application lifespan selected.
* Timer of this task consists of two 32 bit unsigned integers.
* The two integers represent the low bits Timing.clockTick0 and the high bits
* Timing.clockTickH0. When the low bit overflows to 0, the high bits
increment.
*/
if (!(++equlizer_M->Timing.clockTick0)) {
++equlizer_M->Timing.clockTickH0;
}
equlizer_M->Timing.taskTime0 = equlizer_M->Timing.clockTick0 *
equlizer_M->Timing.stepSize0 + equlizer_M->Timing.clockTickH0 *
equlizer_M->Timing.stepSize0 * 4294967296.0;
}
/* Model initialize function */
void equlizer_initialize(void)
{
/* Registration code */
/* initialize non-finites */
rt_InitInfAndNaN(sizeof(real_T));
/* initialize real-time model */
(void) memset((void *)equlizer_M, 0,
sizeof(RT_MODEL_equlizer_T));
rtmSetTFinal(equlizer_M, -1);
equlizer_M->Timing.stepSize0 = 0.023219954648526078;
/* Setup for data logging */
{
static RTWLogInfo rt_DataLoggingInfo;
rt_DataLoggingInfo.loggingInterval = NULL;
equlizer_M->rtwLogInfo = &rt_DataLoggingInfo;

12
}
/* Setup for data logging */
{
rtliSetLogXSignalInfo(equlizer_M->rtwLogInfo, (NULL));
rtliSetLogXSignalPtrs(equlizer_M->rtwLogInfo, (NULL));
rtliSetLogT(equlizer_M->rtwLogInfo, "");
rtliSetLogX(equlizer_M->rtwLogInfo, "");
rtliSetLogXFinal(equlizer_M->rtwLogInfo, "");
rtliSetLogVarNameModifier(equlizer_M->rtwLogInfo, "rt_");
rtliSetLogFormat(equlizer_M->rtwLogInfo, 4);
rtliSetLogMaxRows(equlizer_M->rtwLogInfo, 1000);
rtliSetLogDecimation(equlizer_M->rtwLogInfo, 1);
rtliSetLogY(equlizer_M->rtwLogInfo, "");
rtliSetLogYSignalInfo(equlizer_M->rtwLogInfo, (NULL));
rtliSetLogYSignalPtrs(equlizer_M->rtwLogInfo, (NULL));
}
/* block I/O */
(void) memset(((void *) &equlizer_B), 0,
sizeof(B_equlizer_T));
/* states (dwork) */
(void) memset((void *)&equlizer_DW, 0,
sizeof(DW_equlizer_T));
/* Matfile logging */
rt_StartDataLoggingWithStartTime(equlizer_M->rtwLogInfo, 0.0,
rtmGetTFinal
(equlizer_M), equlizer_M->Timing.stepSize0,
(&rtmGetErrorStatus(equlizer_M)));
{
char_T *sErr;
/* Start for S-Function (sdspwmmfi2): '<Root>/From Multimedia File' */
sErr = GetErrorBuffer(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
CreateHostLibrary("frommmfile.dll",
&equlizer_DW.FromMultimediaFile_HostLib[0U]);
createAudioInfo(&equlizer_DW.FromMultimediaFile_AudioInfo[0U], 1U, 1U,
44100.0, 32, 2, 1024, 0, GetNullPointer());
createVideoInfo(&equlizer_DW.FromMultimediaFile_VideoInfo[0U], 0U, 0.0,
0.0,
"", 0, 0, 0, 0, 1U, 0, 0, GetNullPointer());
if (*sErr == 0)
{
LibCreate_FromMMFile(&equlizer_DW.FromMultimediaFile_HostLib[0U], 0,
(void*)
"C:\\Users\\HAFO\\Desktop\\Sicko Mode - Travis Scott_ Drake.mp3", 1,

13
"C:\\ProgramFiles\\MATLAB\\R2018a\\toolbox\\shared\\multimedia\\bin\\win6
4\\audio\\audiofilemfreaderplugin.dll",
"C:\\ProgramFiles\\MATLAB\\R2018a\\toolbox\\shared\\multimedia\\bin\\
win64\\audioslconverter",
&equlizer_DW.FromMultimediaFile_AudioInfo[0U],
&equlizer_DW.FromMultimediaFile_VideoInfo[0U],0U,1U,1U,0U,0U,1U);
}
if (*sErr == 0)
{
LibStart(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
}

if (*sErr != 0) {
DestroyHostLibrary(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);
rtmSetStopRequested(equlizer_M, 1);
}
}
/* End of Start for S-Function (sdspwmmfi2): '<Root>/From Multimedia File' */
/* Start for S-Function (saudioToAudioDevice): '<Root>/Audio Device Writer'
*/
sErr =
GetErrorBuffer(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
CreateHostLibrary("hostlibaudio.dll",
&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
if (*sErr == 0)
{
LibCreate_Audio(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U], 0,
"Default", 1, 1, 2, 44100.0, 3, 1024, 10240, 1024, 0, NULL);
}
if (*sErr != 0)
{
DestroyHostLibrary(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);
rtmSetStopRequested(equlizer_M, 1);
}
}
/* End of Start for S-Function (saudioToAudioDevice): '<Root>/Audio Device
Writer' */
}
{

14
int32_T i;
/* InitializeConditions for S-Function (sdspwmmfi2): '<Root>/From
Multimedia File' */
LibReset(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
for (i = 0; i < 1394; i++) {
/* InitializeConditions for DiscreteFir: '<S3>/Digital Filter' */
equlizer_DW.DigitalFilter_states[i] =
equlizer_P.DigitalFilter_InitialStates;
/* InitializeConditions for DiscreteFir: '<S1>/Digital Filter' */
equlizer_DW.DigitalFilter_states_k[i] =
equlizer_P.DigitalFilter_InitialStates_f;
}
/* InitializeConditions for DiscreteFir: '<S2>/Digital Filter' */
for (i = 0; i < 1742; i++) {
equlizer_DW.DigitalFilter_states_c[i] =
equlizer_P.DigitalFilter_InitialStates_k;
}
/* End of InitializeConditions for DiscreteFir: '<S2>/Digital Filter' */
}
}

/* Model terminate function */


void equlizer_terminate(void)
{
char_T *sErr;
/* Terminate for S-Function (sdspwmmfi2): '<Root>/From Multimedia File' */
sErr = GetErrorBuffer(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
LibTerminate(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);
rtmSetStopRequested(equlizer_M, 1);
}
LibDestroy(&equlizer_DW.FromMultimediaFile_HostLib[0U], 0);
DestroyHostLibrary(&equlizer_DW.FromMultimediaFile_HostLib[0U]);
/* End of Terminate for S-Function (sdspwmmfi2): '<Root>/From Multimedia
File' */
/* Terminate for S-Function (saudioToAudioDevice): '<Root>/Audio Device
Writer' */
sErr =
GetErrorBuffer(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
LibTerminate(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);
if (*sErr != 0) {
rtmSetErrorStatus(equlizer_M, sErr);

15
rtmSetStopRequested(equlizer_M, 1);
}
LibDestroy_Audio(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U], 1,
1);
DestroyHostLibrary(&equlizer_DW.AudioDeviceWriter_AudioDeviceLi[0U]);

/* End of Terminate for S-Function (saudioToAudioDevice): '<Root>/Audio


Device Writer' */
}

16
5. Result:

The comparison between the input and output signal.

This is the spectrum scope of the 400hz bandpass filter comparing to the input

17
This is the spectrum of the 1600Hz bandpass filter comparing to the input

Conclusion:
From the result we can see that only 3 specific frequency of filter are going
through. All other frequencies are rejected. After doing this project, we can
learn deeper about the application of filter. There are many approaches to do
this project, like using FFT/DFT, compressor, limiter. However, due to
limitation of our knowledge, we use an easy way to achieve the goals of this
project, combining 3 different bandpass filters to create an equalizer.

18
6. References:
[1] Texas Instruments, C5515 eZdsp USB Stick Development Tool description and features,
http://www.ti.com/tool/tmdx5515ezdsp, retrieved on October, 19th 2020.
[2] Sensorasia,TMS320C5515_eZdip_USBstick.MP4,http://www.youtube.com/watch?
v=ZFnvH1iZoY8, retrieved on October, 19th 2020.
[3] Detailed instructions are taken from the SSD1306.pdf acquired from
www.adafruit.com/datasheets/SSD1306.pdf.Illustrating images of C5515 eZdsp USB
Stick Development Tool are taken from http://www.ti.com.
[4] All source codes in this report are taken from the usbstk5515_v1 library associated with
C5515 eZdsp USB Stick Development Tool, provided by Spectrum Digital Inc.

19

You might also like