It seems like you've been watched by big brother... NedWatch
This page has a new entrance redirector:
http://go.to/hardwaremp3
This page is moving to a new host:
http://home.hetnet.nl/~victorvanacht/
Hardware MP3-player
This page is still
recent updates are coloured in magenta.
-
On 10-27-1999 this page has been visited more than
1800 times!
-
On 12-21-1999 this page has been visited almost 2500
times!
-
On 02-01-2000 this page has been visited more than
3000 times!
-
On 02-14-2000 (Valentine's day!) this page has been
visited almost 3500 times!
-
On 02-25-2000 this page has been visited more than
3700 times
-
On 03-09-2000 this page has been visited almost 4000
times
-
On 03-31-2000 this page has been visited more than
4600 times
-
On 05-01-2000 this page has been visited more than
5500 times, with an average of more than 30 hits per day
-
On 06-05-2000 this page has been visited more than
6800 times
-
On 06-19-2000 this pages has been visited more than
7300 times
-
On 08-02-2000 this page has been visited more than
9300 times, with an avarge of about 40 hits/day
-
On 09-21-2000 this page has been visited more than
12000 times, with an avarage of more than 50 hits/day
-
On 11-28-2000 this page has been visited more than
17500 times, with an avarge 75 hits/day
-
On 01-01-2001 this page has been visited more than
20000 times
-
On 01-23-2001 this page has been visited moren then
22000 times
-
On 02-06-2001 this page has been visited moren than
23000 times
I started this project in Spring 1997 together with a
friend of mine, in the time that real time audio (de-)compression was
state-of-the-art in electronics. Back then you couldn't buy your personal,
portable MP3-player at every corner of the street, and Intel's Pentium
@ 133MHz was just able to run WinAmp
in high-quality mode. I thought it would be nice (and very interesting)
to build my own stand alone MP3-player, without the drawbacks of a standard
IBM-compatible desktop computer: monitor necessary, harddisk necessary,
keyboard necessary, power consumption, noise of the fan, long boot-time,
etc.
My MP3-player had to meet the following requirements:
-
Able to read the MP3-files from standard recordable CDs, made on
a standard PC.
-
Enough computing power to play the MP3-files real time.
-
Visual user-interface via LCD display
-
Special dedicated keyboard layout
-
Low power (no fan necessary)
-
... and of course a low price
Therefor I chose the following set up:
-
A Texas Instruments digital
signal processor (DSP): TMS320C31.
This 32 bit floating point processor runs at 50 MHz, delivering 25 MIPS
and 50 MFLOPs. It has 2 KByte on chip multi ported RAM memory, a serial
port, two timers, and a DMA controller.
-
256 Kx32bit (=1 MByte) of zero waitstate SRAM memory
-
A standard ATAPI CDROM player
-
A standard 20x4 character LCD-display
-
An Analog Devices AD1859
stereo 18 bit @ 48 KHz Delta/Sigma DAC
-
An Intel 8255A for general
purpose I/O
-
A standard 64KByte 200ns EPROM for the firmware (expandable
to 128KByte). Contents of this (slow) EPROM are shadowed in the SRAM
-
A programmable wait-state generator for different waitstates
and timing for the SRAMs and other components
-
An 18 key dedicated keyboard
-
Some additional electronics, including a stereo analog multiplexer,
analog filters and linear voltage regulators with
power down facility
-
All 'glue-logic' is taken care of by two GALs, programmed
by my self-designed GAL-programmer.
Implementation & Manufacturing
Because Texas Instruments provides DSP
Starter Kits (DSK) for their TMS320C31
floating point digital signal processor, including some development software
such as an assembler and a debugger, I decided to use this Starter Kit.
The additional electronics were to be placed on a daughter board
for this DSK. (actually it looks more like a motherboard without
a processor :-) ).
After choosing the electronic components a Printed Circuit Board (PCB)
has been designed. I used the program 'EdWin' to design the daughter board.
The board itself is approximately 20cm x 30cm, dual sided and has Surface
Mounted Devices (SMD) on it. I manufactured the board my self, in my home-made
photographic etching-tank.
After vigorous visual en electrical testing (and correcting some lay-out
errors :-( ) I could test the daughter board together with the DSP. And
of course... the thing didn't work. It took me three weeks to solve all
timing problems. (Damn 8255 wants adress stable before
!RD or !WR is applied, and !RD and !WR must be deactivated before
the adress is changed. Just like the ATA-interface. Of course the LCD-display
wants just the opposite. Furthermore there were some glitches in the !Ready-line
for the DSP when the waitstate-generator on the daughterboard was taken
over by the waitstate-generator on the DSK. And why are R43 and R44 on
the DSK not mounted?)
But at this moment I believe that the hardware and GAL-software is
pretty much bug-free.
Some changes have been made in the interfacing
between the on-chip serial port of the TMS320C31 and the AD1859 Digital
to Analog Converter, in order to make DMA-controlled WAV-playing possible.
This means that the data can be send to the DAC with zero CPU overhead.
Software
The software for the MP3-player can be devided into several parts:
-
Low-level device drivers for the LCD-display, keyboard, ATA-interface,
ATAPI-devices, DAC, DMA-controller etc.
-
ISO9660 level 2 file-system, with of course the Joliet long filename extention.
-
Realtime MPEG 1 audio layer 1 + 2 + 3 decoder
-
Interrupt handler to send data to DAC on time and read data from
CD on time. Also check for errors during reading
-
User interface
Biggest problem with the software is that some how it has to be multi-tasking
& real-time. One of the big issues in Operating Systems... (For example
when the interrupt handler is reading one sector from the CD it has to
wait for the data, but still the music must continue, so the interrupt
handler must be interruptable(!). And of course while the interrupt handler
is waiting for CDROM-data, the user-interface is not allowed to read from
the CD (for example go into a subdirectory). And vice-versa.)
The main part of the software is programmed in C (using Texas Instruments
optimising C compiler), but the low level device drivers and the MPEG layer
1,2,3 decoder are programmed (or will be programmed)
in
assembly, for speed reasons.
Before I started this project I had allready a little experience
in designing microprocessor boards and ATA/ATAPI device controlling: I
built an audio CD player using standard ATAPI CDROM drives and a Zilog
Z80 microprocessor. This design won the fifth price in "Elektuurs Internationale
Programmeer Wedstrijd" in 1997.
I also did some pre-research in the ISO 9660 filestructure and Joliet
extention: I more or less reprogrammed CDROM.SYS and MSCDEX.EXE on a IBM-compatible
PC for testing. Starting from this file it was very easy to translate it
to the DSP-board.
Furthermore I programmed an MPEG 1 Audio Layer 1+2+3 decoder on a PC,
in C (not real-time) to understand the structure of an MPEG bitstream.
I also wrote the most CPU-intensive parts (namely the IMDCT and the windowing
algorithm) in TMS320C31 assembly (without testing) to check whether this
processor was able to decode an MP3-file in real time.
Most interesting part of the software is of course
the MPEG audio layer 1+2+3 decoder. Although I did not debug and test the
decoder I wrote as a test-case in C (note that no code is taken from other
decoders to program this one!), and are not started yet with programming
the MPEG decoder for the DSP-board, I think I have a pretty good idea of
how it can be implemented. The most CPU-intensive parts of the decoding
process for layer 1 and 2 are some sort of inverse Fourrier transform (called
an Inverse Modified Discrete Cosine Transform (IMDCT)) and a windowing
operation.
-
When the IMDCT is calculated as presented in the
ISO-standard it takes about 2048 multiplications and additions per 32 samples.
This gives 128 floating point operations per sample just for the IMDCT.
However, using the Lee-algorithm the
32x64 matrix-vector multiplication for the IMDCT can be approximated by
two 16x16 matrix-vector multiplications, 64 additions and some data-copying.
But again such a 16x16 matrix-vector multiplication can be approximated
by two 8x8 matrix-vector multiplications and some additions. This iterative
process can lead to a considerable decrease in the number of computations.
However, because every iteration leads to a more complex shuffling of the
input and the output vector this leads to inefficiency in the algorithm.
Currently, the 64x32 matrix vector multiplication is decomposed in one
16x16 matrix vector multiplication and two 8x8 matrix vector multiplications.
Programming the matrix-vector multiplication
routine very time-efficient and with little overhead, you can do the multiplications,
additions and input- and output vector reordering (all floating point)
in about 700 cycles per 32 samples (on the TMS320C31), about six times
faster than with a standard 64x32 matrix-vector multiplication.
-
The windowing operation is to reduce time artefacts
introduced by the finite MDCT operations, and it takes 512 multiplications
and additions per 32 samples. This gives 32 floating point operations per
sample for the windowing.
Again using time-efficient inner-product routines,
this can be done in about 750 cycles per 32 samples.
An other interesting part of the software is the
real-time multi-tasking operating system. Multi-tasking is implemented
as follows:
-
The main program is interrupted on a regular bases
(256Hz) by the multi-tasking dispatcher. The main program can be empty,
if there is no main program necesary.
-
The multi-tasking dispatcher checks in a table if
there are any real-time processes to be executed. If this is the case,
the multi-tasking dispatcher starts with the process with the highest priority.
It also re-enables interrupts so that the multi-tasking processes themselves
can also be interrupted.
-
When a multi-tasking process ends it returns to the
multi-tasking dispatcher. And the multi-tasking dispatcher resets its 'in
execution' flag
-
When a multi-tasking process is interrupted by an
other 256Hz interrupt, the multi-tasking dispatcher is again called, and
calls multi-tasking processes starting with the highest priority. However:
if the multitasking dispatcher finds a process which is already being executed
(by the previous multi-tasking dispatcher) is returns. This makes that
low priority processes can be interrupted by high priority tasks, but not
vice versa.
-
Of course the processes with the highest priority
must be as fast as possible (preferably written in assembly)
-
Some multi-tasking processes have to wait for data
(e.g. reading from CD-ROM) it is prefered that those processes return (to
the main program) and use internal flagging indicating they're waiting
for some periferals. Next time they are called by the dispatcher the data
can be ready, if so continue processing, if not return to the main program
and wait some longer.
The functionality of the MP3 player is now devided
into multi-tasking processes and the main program as follows:
-
The main program takes care of the user interface.
Thus presenting directory-structures, file-information, keyboard-strike
handling etc.
-
All other tasks of the MP3 player are multi-tasking
processes: (with the following order of priority)
-
Updating timers and Real Time Clock counter
-
Keyboard scanning and putting key strikes in the
keyboard buffer
-
Decoding data in the disc buffer to the wav buffer
-
Reading data from CR-ROM to the disc buffer
-
Of course some flagging is necessary between the
main program and the multi-tasking processes and the multi-tasking pocesses
mutually. For example if a multi-tasking process is waiting for data from
CD-ROM, the main program is not allowed to give the CD-ROM player new commands,
corrupting the communication protocol between multi-tasking process and
the CD-ROM player.
The menu oriented user interface is programmed in
such a way that it is implemented very memory-efficient. Using tables which
contain the texts of the menu entries, the adresses of the menu entry handling
routines, and parameters for these handling routines. In this way the complete
code and data of an 'average menu option' takes only about 30 bytes
(10 32bit words).
If you are interested in a document containing information about hardware
& software revisions and bug-fixes, click
here.
-
Hardware designed (especially?) to make this Hardware MP3-player
possible:
-
Feasibilty studies:
-
Actual Hardware MP3-player:
-
Designed the hardware.
-
Designed the PCB layout.
-
Manufactured a prototype of the PCB.
-
Debugged the PCB and hardware design.
-
Implemented low level device drivers for LCD-display, keyboard
and ATA + ATAPI devices
-
Implemented the ISO9660 (level2) and Joliet filesystem on
the DSP-board
-
Started with the user interface
-
Windows9x-explorer-like file browsing
system, including icons, expanding and collapsing directories, scrolling
in all four directions
-
Support of audioCDs (CDDA), multi-session,
mixed mode and multi-session CDDA CDs
-
Implemented low level drivers for the
on-chip serial port (to AD1859 DAC), on-chip timers (for sample-frequency
and multi-tasking), on-chip DMA (for playing WAVs with zero CPU-cycles),
on-chip interrupt controller and on-board AIC (for testing purposes only)
-
Redesigned on-chip serial port -> DAC
interface to make DMA-controlled WAV-playing possible.
-
Implemented DMA-controlled continuous
WAV-player
-
Implemented the real-time multi-tasking
operating system
-
Implemented keyboard control as multi-tasking
process:
scanning for key-strokes, debounce, put in buffer, delay & repeat.
So now if you press a key, it is debounced (no switching noise) and one
keystroke is put in the buffer, untill it is read by the user interface
routines (No missing key strokes). When you hold a key, for some time,
repeated keystrokes are put in the buffer, untill the key is released.
Just like your PC-keyboard interface!
-
10-03-99: The system now reads sectors
from CDROM, puts the data in the disc-buffer, decodes the data in the disc-buffer
to the wav-buffer (WIN95 WAV-file support only) and plays the wav-buffer
via DMA. All this works via real-time multi-tasking processes. So also
the user interface (reading directories etc.) is still up & running
!!!!!
-
Corrected some bugs in the low-level
IDE drivers. Now multiple sectors can be read at once.
-
Increased real-time multi-tasking interrupt
frequency from 100Hz to 256Hz. This boosts the maximum IDE data rate via
interrupt from 100Kbyte/sec to 500Kbyte/sec. That's enough for real-time
stereo 16bit 44KHz WAV-playing.
-
Rewrote the interrupt driven multi-tasking
reading from CDROM. Less delays in main program.
-
Still debugging multi-tasking IDE-reading
-
Still debugging low-level IDE-drivers
<sigh>
-
One again corrected a MAJOR bug in
the low-level ATAPI drivers. Now the interrupt-reason-register is used
to check if a read operation is completed. (As it is supposed to... Why
didn't I see this before in the ATAPI-documents???) Reading multiple sectors
now really works :-)
-
Corrected a minor type-over with MAJOR
consequences in the real-time multi-tasking dispatcher. (Why did this assembler
not give an error??) Real-time processes are now not-re-entrant, as they
should.
-
It is now (again) possible to read
& play WAV-files in multi-tasking and real-time. (Execpt that it doesn't
work properly because of timing problems and buffer overflows & underflows...
still working on that...)
-
Found a bug related to the timing of
the ATA-hardware. I haven't figured out yet, what the problem exactly is,
but I now know that the strange errors in the CDROM-handling probably have
something to do with timing or something like that. I'm discussing these
problems with one of the developers of the ATA-standard: Hale Landis of
IBM.
-
Programmed the menu structured user
interface.
-
Optional alphabetically sorting of
filenames in the directory structures. Directories come before files.
-
Corrected a bug in the sorting algorithm.
Now directory entries in Joliet are correctly sorted, too.
-
Started with the MPEG Audio Layer 1
decoder. Reprogrammed and optimised complete decoder from previous versions.
Also corrected some bugs in this decoder. No testing yet.
-
00-03-20: Finished layer 1+2
decoder. Some bug fixes in the IMDCT algorithm using Lee decomposition,
requantisizing, and Joint_Stereo. IMDCT+windowing runs at 1/6 x real-time
(calculated speed) No testing yet!
-
Trying to figure out how layer 3 works....
-
Tested the IMDCT and windowing operation
for Layer 1 & 2. After some speed optimizations these two operations
now run at 1/6x real time (tested speed!)
-
Started programming the Layer 3 decoder.
-
Implemented layer 3 Huffman decoder
(thanks to Tomislav Uzelac's Amp!!!)
-
Implemented layer 3 Scaling & Requantisation
-
Implemented layer 3 Anti-aliasing butterflies
-
Implemented layer 3 Short window reordering
-
Implemented layer 3 IMDCT9x9 + windowing
-
00-09-01: Took some holidays,
and bought a new computer (Abit KT7-RAID, Athlon Thunderbird 800, 128MB-133MHz,
2 x Maxtor 30GB 7200rpm, Matrox Marvel G400, Iiyama Vision Master 450)
so there has been 'some' delay in the MP3-player... Will continue soon...
-
00-11-28: Preparing to continue the
work on the MP3-player
-
Set up a new entrance redirector for
this site: http://go.to/hardwaremp3
-
Continued to work on the Hardware MP3-player....
-
Designed a video display processor
for graphical LCD displays. (applicable to various resolutions, but designed
for 320x240) To be applied in the MP3-player. Features:
-
320x240 resolution
-
4 grey-levels
-
software dual-ported 32KB SRAM memory
-
hardware scroll in x and y direction
-
overlay scan to 512x256
-
Built using standard 74xxx ICs and
two GALs.
-
Implemented full support for WAV-files.
(AIFF-format)
-
8/16 bits
-
mono/stereo
-
11/22/44 kHz.
-
Implemented support for limited selection
of ID3v2.3 frames
-
artist
-
composer
-
title
-
album
-
date
-
year
-
etc.
-
Started to debug the MPEG audio decoder.
First the layer 1 decoder only....
-
worked around a compiler/linker/DSK3D
bug in relocatable code.
-
corrected some bugs in the GetBits
routine
-
corrected some bugs in the requanitisation/scaling
-
00-01-08: MPEG Layer 1 decoder
is working!!!! Although there are still some hisses, ticks and pops,
music is recognisable and doesn't sound too bad... Ticks and pops caused
by skipped frames. Reading from the bitstrream still doesn't go flawless.
-
Corrected bugs in the requantisation
/ scaling. 2-complement fractional numbers (bit codes) are transformed
to floats correctly now (I hope)
-
Corrected a bug in the windowing. Now
the frames are placed in front of each other in stead of behind each other.
-
Corrected a bug in the hardware around
the DA-converter. The serial control inputs are now connected to ground
(in stead of floating) and the !reset-input is connected to !reset in stead
of +5V. Also some supply decoupling is added. This solves a lot of straaaaange
problems. Still a lot of digital(?) noise audiable, do not know where that
comes from.
-
Due to problems with the server of
the Eindhoven University of Technolgy,
Control Systems Group, I had to move this page to: http://home.hetnet.nl/~victorvanacht/
-
Corrected a bug in the low-level ATAPI-drivers.
Now reading multiple secors works correctly. (An extra 16bits word was
inserted between each sector). This makes the Layer 1 decoder work fine.
-
MPEG Layer 2 decoder is working (more
or less) for most (some?) bitrate/sampling frequency combinations. Still
some Layer 2 debugging to do... :-( Also some speed optimisations, as the
Layer 2 decoder is a bit too slow. Reading from the bitstream (programmed
mostly in C) takes most of the CPU-time (in stead of the audio-processing,
programmed in assembly) so optimisation shouldn't be a problem...
-
Future work
-
Finish MPEG audio layer 1,2,3 decoder
-
Finish user-interface
-
...and some vigorous testing and debugging...
Note:
Beware that downloading any of the files on this page is strictly for personal,
non commercial use only!!!
Photographs
Via E-mail, I received some requests for photographs
of the current MP3-player-project. Click here for more
pictures.
I borrowed a digital camera and made some more
pictures of the Hardware MP3-player project
The DSP-daughter-board (component side) with
the Texas Instruments 'C31 DSK (component side) mounted.
On the DSP-daughter-board are clearly visible:
-
The stereo 18bits 48KHz DAC and some analog electronics
(bottom right)
-
1 MByte 0 waitstate SRAM (under DSK)
-
Adres decoder and waitstate generator in two GALs
(top left)
-
Adresbus and databus buffers, 8255A, IDE-port, keyboard-connector,
LCD-display connector and EPROM (not mounted) (left of DSK)
-
The powersupply (top right) is not finished yet
|
|
|
The MP3-player under development:
On the left the computer I use for writing the
software. Next to it the (temporary) power supply for the DSP. On top of
that an ATAPI-CDROM-player, and on top of that the keyboard. Next to that
the DSP daughterboard with the DSK-board mounted. Also notice the uploading
connector (LPT-port) in the DSK.
Further more al kind of things are visible in
the background such as a soldering iron, audio power amplifier, alarm clock,
and some other (un)useful stuff. |
Again, more pictures of the project can be found
here!!!
Documents and Sources
I was asked to put all the sources
of the Hardware MP3-player on-line. Well... here they are!
Download (parts of) sources of the
Hardware MP3-player:
While designing the hardware and programming
the software for the MP3-player other documents have been used. If you
are interested you can download those documents yourself:
-
ATA-1
The ATA-1 standard. (PDF, 135KB)
Download.
-
ATA-2
The ATA-2 standard. (PDF, 400KB)
Download.
-
ATA-3
The ATA-3 standard. (PDF, 779KB)
Download.
-
ATA/ATAPI-4
The ATA/ATAPI-4 standard. (PDF,
1429KB) Download.
-
ATA/ATAPI-5
The ATA/ATAPI-5 standard. (PDF,
1497KB) Download.
-
ATA/ATAPI-6
The ATA/ATAPI-6 standard (PDF,
1506KB) Download.
-
ATAPI 2r6
This is the ATAPI-2r6 command specification
(Postscript). Click here to download
it. (For people who don't know: ATAPI is the official name for your IDE-CDROM
/ IDE-Tapedrive / IDE-ZIPdisk etc.)
-
ATAPI R/W extension
This is the ATAPI (re-)writable
command specification extension (by Philips) (PDF-file) If you are interested,
you can get all this valuable information by clicking here
(For people who don't know: These are the extra command's used by IDE CD-(re-)writers.)
-
ECMA-119
The ECMA-119 is exactly the same
as the ISO-9660 standard. As the ISO-9660 standard is very expensive
and difficult to obtain, you can better download this
file. It REALLY is exactly the same, litteraly!
-
ISO11172-3
The ISO11172-3
is the MPEG audio layer 1, 2 & 3 standard document. (I thought it was
copyrighted by ISO, but I downloaded it
from The MP3-techpage so apperently no copyrights(???))
-
ISO13818-3
The ISO13818-3
is the MPEG audio layer extension for low bitrates. (Again, I thought it
was copyrighted by ISO...)
-
ID3v2.3
The ID3v2.3 unofficial standard
is used to add contents information etc. to MP3 files. It can be dowloaded
here.
Also visit it's homepage.
-
AC-3 Specification
This is the AC-3 specification (PDF). Comparable to MPEG
1 - layer 2/3. Used in DVD. Download
now!!!
-
Lee's Paper
This is a copy of the original paper by Lee about
his Fast DCT algorithm. Download
[IEEE Conference on acoustics, speech and signal
processing
San Diego, USA, March 1984
P28A.3/1-4 vol 2
CH1954-5/84/0000-0299]
Interesting Links
Really interesting
For comments and questions about this Web-page,
send Email to Victor van Acht
Last changes: 2001-02-06