Specifications

CONSTRUCTION
From byte Number Information
of bytes
RIFF chunk:
0 4 Contains the characters ‘RIFF’
4 4 Size of the RIFF chunk
WAVE chunk:
0 4 Contains the characters ‘WAVE’
4 Variable The FORMAT chunk
The normal FORMAT chunk:
0 4 Contains the characters ‘fmt’
4 4 Size of the FORMAT chunk
8 2 Value specifying the scheme
1-PCM, 85-MPEG layer III
10 2 Number of channels
1-mono, 2-stereo, etc.
12 4 Number of samples per second.
This gives us the playback rate.
16 4 Average number of bytes per second.
This field is used to allocate buffers, etc.
20 2 Contains block alignment information.
22 Variable This field contains format-specific data.
For PCM files, this field is 2 bytes long
MPLAYER.CPP
#include “Sounds.h”
void DisplayTip(char *string)
{
text_info tinf;
if(strlen(string)<75)
{
gettextinfo(&tinf);
textbackground(LIGHTGRAY);textcolor(RED);
gotoxy(2,25);
for(int i=0;i<75;i++) cprintf(“ ”);
gotoxy(2,25);
cprintf(string);
textattr(tinf.attribute);
gotoxy(tinf.curx,tinf.cury);
}
return;
}
void Window(int x1,int y1,int x2,int y2,char
*caption,int BackCol,int TextCol)
{
text_info tinfo;
int i,j;
gettextinfo(&tinfo);
textbackground(BackCol);textcolor(TextCol);
for(j=y1;j<=y2;j++){
gotoxy(x1,j);
for(i=x1;i<=x2;i++)
cprintf(“ ”);
}
gotoxy(x1+1,y1);
for(i=x1+1;i<=x2-1;i++)
cprintf(“%c”,205);
gotoxy(x1+1,y2);
for(i=x1+1;i<=x2-1;i++)
cprintf(“%c”,205);
for(j=y1+1;j<=y2-1;j++){
gotoxy(x1,j);
cprintf(“%c”,186);
gotoxy(x2,j);
cprintf(“%c”,186);
}
gotoxy(x1,y1);cprintf(“%c”,201);
gotoxy(x2,y1);cprintf(“%c”,187);
gotoxy(x1,y2);cprintf(“%c”,200);
gotoxy(x2,y2);cprintf(“%c”,188);
if(caption!=NULL){
textcolor(WHITE);
gotoxy(x1+2,y1);
cprintf(“%s”,caption);
}
textattr(tinfo.attribute);
return;
}
void DrawScreen(void)
{
textbackground(LIGHTGRAY);textcolor(BLACK);
clrscr();
Window(1,2,80,24,NULL,BLUE,WHITE);
gotoxy(1,1);cprintf(“ File Effects Operation”);
textcolor(RED);
gotoxy(3,1);cprintf(“F”);
gotoxy(12,1);cprintf(“E”);
gotoxy(24,1);cprintf(“O”);
textbackground(BLUE);textcolor(LIGHTBLUE);
gotoxy(3,10);cprintf(“ ”);
delay(75);
gotoxy(3,11);cprintf(“ ”);
delay(75);
gotoxy(3,12);cprintf(“ ”);
delay(75);
gotoxy(3,13);cprintf(“ ”);
delay(75);
gotoxy(3,14);cprintf(“ ”);
delay(75);
gotoxy(3,15);cprintf(“ ”);
delay(75);
gotoxy(3,16);cprintf(“ ”);
delay(75);
gotoxy(3,17);cprintf(“ ”);
return;
}
void MenuInitialise(void)
{
int i;
// The FILE menu option
Menu[MNU_FILE].nextMenu=MNU_EFFECT;
Menu[MNU_FILE].prevMenu=MNU_OPERATION;
Menu[MNU_FILE].Child=FALSE;
Menu[MNU_FILE].num_items=4;
for(i=0;i<4;i++)
{
Menu[MNU_FILE].Enabled[i]=TRUE;
Menu[MNU_FILE].subMenu[i]=NONE;
Menu[MNU_FILE].String[i]=(char *)malloc(15);
Menu[MNU_FILE].Tip[i]=(char *)malloc(50);
Menu[MNU_FILE].OptionID[i]=1+i;
}
Menu[MNU_FILE].Enabled[1]=FALSE;
strcpy(&(Menu[MNU_FILE].String[0][0]),“Open”);
strcpy(&(Menu[MNU_FILE].String[1][0]),“Save”);
strcpy(&(Menu[MNU_FILE].String[2][0]),“-”);
strcpy(&(Menu[MNU_FILE].String[3][0]),“Exit”);
strcpy(&(Menu[MNU_FILE].Tip[0][0]),“Open the
*.wav file”);
TABLE II
Wave File Format
of target processor. This is one of the
methods to achieve invariance of the play-
back speed over a wide range of proces-
sor speeds available.
The software
can be used to play
with the following
effects:
Play normally
Play with a
different playback
rate, i.e. play it fast
or slow
Fade-in or
fade-out the volume
levels either linearly
or exponentially
Reverse the
wave file and then
play
The menu items
can be selected us-
ing keyboard keys
Alt+F for file, Alt+E
for effects, and
Alt+O for operation.
Apart from the soft-
ware, the hardware
can be used to vary
bass, treble, and volume for the wave file
that is played. Thus, the hardware and
software complement each other to pro-
vide a good music player. The software
does not include mouse support.
Conclusion
We have presented a simple sound card
to playback .wav files with bass and treble
controls. Though the current design
plays only mono files (stereo files are
converted to mono), a stereo file player
can be designed in a similar manner. The
software can be modified to play audio
files other than .wav files without any
change in the hardware circuit. The en-
coding format of the other audio file types
(like .ra, .mp3) is only to be known. With
that, those files can be decoded and raw
digital 8-bit data can finally be sent to the
hardware device. The hardware device can
even be permanently mounted inside the
PC with all the power supplies (+12V, +5V,
and –12V) tapped from the system’s
SMPS.
Note: The complete source code con-
sisting of Mplayer.cpp, Sounds.h,
Globals.h, the executable file Mplayer.exe,
and a sample wave file are likely to be
included in next month’s CD (optional)
accompanying EFY.
Program Listing
77