MP3 Player With Network Interface By Michael Somersmith School of Information Technology and Electrical Engineering, University of Queensl
By the completion of the thesis, the player was operating as you would hope it to. It can play MP3s that are stored anywhere on the network, whether
Appendix D – Decoder interface Source code /* * Copyright (C) 2001-2002 by egnite Software GmbH. All rights reserved. * * Redistribution and use i
* First pre-release with 2.4 stack * */ /* * MP3 player with network interface. * The Ethernut code * Engineering Thesis 2002 * Modified
*/ if(tx_ptr == wr_ptr) { empty = 1; tx_act = 0; break; } /*
* Set data line. */ if(data & mask) sbi(VS_SI_PORT, VS_SI_BIT); else cbi(VS_SI_PORT, VS
{ /* * Set BSYNC high. */ sbi(VS_BSYNC_PORT, VS_BSYNC_BIT); outp(b, SPDR); asm volatile("nop\n\tnop\n\tnop\n\tnop\n\tn
u_char on[] = { 0x53, 0xEF, 0x6E, 56 }; u_char off[] = { 0x45, 0x78, 0x69, 0x74 }; on[3] += (fsin & 7) * 9; for(i = 0; i <
100 */ sbi(VS_SI_DDR, VS_SI_BIT); /* * Set SS to output for SPI master mode. */ sbi(VS_SS_DDR, VS_SS_BIT); /* *
Chapter 4 explains how the development platform was chosen for the project. The development platform for this project was a microcontroller based sol
Chapter 2 – Background 2.1 What are MP3s? MP3 stands for MPEG Audio Layer 3. MPEG is the name of a working group established under the joint directi
2.2 The TCP/IP protocol. TCP/IP stands for Transmission Control Protocol/Internet Protocol. It is frequently referred to as a “stack” because of the
2.3 Current MP3 players with a network interface. As mentioned in the introduction the inspiration for the topic predominantly came from the AudioTr
Figure 3 Functional diagram of the AudioTron [3] To operate the AudioTron the user must install software to enable interaction with the Windows file
the PC software for it to operate, reduce the autonomy of the device. The SimpleFi’s main advantage is that it can transmit the data wirelessly. Spec
Chapter 3 – Specifications The main requirement for the player to be implemented is the ability to able provide similar functionality to the AudioT
To achieve the above specifications the product was broken up into the components shown in figure 5. CentralProcessingPlay ListManagementFile transfe
Chapter 4 – The development platform When planning how to implement this device it quickly became apparent that it would require far too much time (
Abstract Compressing raw audio with the MP3 standard can reduce the storage space required by approximately one twelfth. [17] This has made it possib
physical layer was primarily based on one that is compatible with the microcontroller. Important factors when deciding on a microcontroller and an op
without worrying about handling the threads related to handling the network protocol. The operating system would then handle the stack management and
development boards combined with TCP/IP development kits exceed US$500. And this is only for the networking side of the project. The obvious alterna
The hardware features of the Ethernut kit are as follow: Atmel ATmega 103 processor running at 3.6864 Mhz Realtek IEEE 802.3 compliant Ethernet c
4.2.5 Embedded MP3 decoding technology The available MP3 decoder technology seems rather simple compared to the networking solutions. Most of the chi
Figure 7 The MP3 decoder board [19] 19
Chapter 5 - Implementation of software Before a decision had been reached about the Ethernut an investigation was carried out for other embedded TCP/
It appears that most of the TCP/IP software discussed on the internet seemed to use TCP/IP with an operating system due to ease of development and al
5.3 Software development 5.3.1 Accessing Windows file system from a remote embedded environment When this project was started it was comprehensible
Windows provide an application protocol above TCP/IP called Server Message Block (SMB) or common internet file sharing protocol (CIFS), as it is call
through standard track controls: play/pause, stop, next and previous track. The player decodes these and sends them as commands to the server which w
The design question then turned from how to implement SMB on the player to how to implement it on the PC. How does one write a Windows program that
MP3 decoderBufferNetworking The playerMicrosoftWindowsGraphicalUser interfaceServer programComputer Figure 9 Overall design revision two The pl
if they are called the thread will stop and will only continue once they are complete. The second way is to create what the Nut OS calls a SoStream (
5.3.3 Sending files from the PC to the Ethernut To test whether the Ethernut can transfer files successfully, the server program on the PC first has
5.3.3.2 Sending files over TCP with the Ethernut To test whether the same could happen through the Ethernut, the Ethernut was added into the loop. T
5.3.4.1 The buffer system A 20 Kbyte ring buffer was implemented on the Ethernut. This translates to about 1-2 seconds worth of audio. It doesn’t sou
Transmitpointer*Receivepointer*End Addressof the bufferStarting Addressof the bufferMemoryaddresses Figure 13 The ring buffer The buffer works by us
Open fileRead file dataSend packetProcess 1Create fileWrite data tofileReceivepacketProcess 2Read data fromsostreamWrite data tosostreamEthernutRing
Before running the code, the piggy back board was connected to the Ethernut. The 12 connection are outlined in table 3. Piggy back connection Functio
Select thecommandregisterDisable theAtmel SPImoduleWrite each bitto the dataline and togglethe clockEnable theAtmel SPImoduleSelect thedata register
Acknowledgements Rebecca Somersmith for her love and support. Peter Sutton for allowing me to take on a thesis topic that I enjoyed, and providing
To test the connections of the bus and the functionality of the decoder board, the decoder was sent the test sine wave. To do this the decoder had t
5.3.6 Playing MP3 data To play the MP3 data that is stored in the buffer through the MP3 decoder, the transfer needs to be at one byte at a time. The
This function is the interrupt service routine that is called when the DREQ line of the VLSI goes high. This pin goes high whenever the buffer in the
Receive MP3data fromserverIncrement thereceivepointerReset thepoin ter if it ispast the bufferboundaryIs thebuffer setto refillIs it fullStart thedec
the OS indicating which interrupt you want to trigger. Once the interrupt has been triggered, the transmission of data to the decoder will start. If
Receive MP3data fromserverIncrement thereceivepointerRes et thepointer if it ispast the bufferboundaryIs thebuffer setto refillIs it fullStart thedec
5.3.7.1 Speeding up the network transfer Small changes to try to optimize the code were made while monitoring the buffer size that was being output
recovered nearly immediately so it was close to being fast enough. At this stage it was decided to change from using a 128kbbs test file to a larger
long or intense, indicating that the clicks were definitely something to do with the pointers at the end of the allocated space. The second problem
was just a text file that listed each file to be open on separate lines with their path in front of the filename. For example: C:\mp3\The Whitlams\Et
Table of Contents Chapter 1 – Introduction ... 2 1.1 Moti
It reads this play list file counting the number of character returns. When the number of character returns is one less than the song number, it read
button was pressed. The tests showed that de-bounce and the interrupts worked but the buffer for the MP3 data kept emptying. This was surprising, bec
Receive MP3data fromserverIncrement thereceivepointerReset thepo inter if it ispast the bufferboundaryIs thebuffer setto refillIs it fullStart thedec
failing. The pause button was then pressed again to undo pause and the player stated producing music from the point it left off. The first test pro
number as previously. This resets the file handler back to the start of the file, ready to play from the start when play is pressed. The results of
to the upper limit that was passed to the function. It returned before the full 1.5Kbyte packet was received, normally at 536 bytes. This was while t
Receive MP3data fromserverIncrement thereceivepointerReset thepo inter if it ispast the bufferboundaryIs thebuffer setto refillIs it fullStart thede
management. How was it possible that the GAP can be put into the middle of old data in the buffer? It did not make sense, for a long time the Nut OS
song from the play list without buttons being pressed. This would allow the buffer to be unaffected by the GAP and discarding of data algorithms. The
The LCD has three control lines, Read/Write, enable and register select. It has a processor on board with two registers that are accessed via its bus
5.3.6 Playing MP3 data... 35 5.3.7 Making the music sound as
Figure 25 The initialisation of the LCD [23] The values at (1), (2), (3), (4), and (5) are the configuration data written to the LCD module using t
Goto position0,0Stringpointer =NULLPrint pointer atcursor positionon the LCDIncrementpointerPosition ofnext character> LCDcolumnsGoto position1,0T
5.3.8.2 Extracting the song name To get the song name to the LCD from the filename, it was necessary to extract the required string from the songs e
There are two buffers represented in the flow chart. The path buffer is the buffer the openMP3 function creates to store the path and filename in and
Initial tests with the Ethernut showed that the web server functions that it provided were very useful. Commands could easily be passed to the web se
would in turn talk to Windows to get the required information about files and then pass this on to the GUI. At the same time it was decided that the
#EXTINF:322,Jeff Buckley - Grace C:\mp3\Jeff Buckley\Grace\02 - Grace.mp3 #EXTINF:275,Jeff Buckley - Last Goodbye C:\mp3\Jeff Buckley\Grace\03 - Last
Chapter 6 - Design evaluation The evaluation of the design for this player is unfortunately quite a subjective one. How does one assess whether they
The player can successfully play MP3s, up to and including 250kbbs, data rates with perfect audio quality. The test for this specification was to cre
quickly navigate the play list while the player is in playback mode. Playback does not resume until the user finally takes their finger off the butto
List of figures Figure 1 The network layers [1] ... 7 Figure 2 T
6.2 Fulfilling the subtle requirements The finer details of an audio device are also worth mentioning. The user controls on the player are very easy
decisions that were significant for finishing the product on schedule. The decision to implement a server program on a PC, instead of implementing an
Chapter 7 - Future Improvements The previous chapters have outline how the idea for the thesis came about and how the idea was developed in to full
7.2 Extensions to the Current Design. After developing the user interface on the player itself there are a wide range of extra features that could be
Chapter 8 - Conclusion The outcome of this thesis was to produce an MP3 player that solved the problem with the current MP3 player solutions. The p
also extracts the song name of the file selected to play and sends it the Ethernut which displays it on the LCD. The buttons connected to the Ethernu
References 1. Sutton, P. ‘COMS3200, Lecture 2’, University of Queensland, URL:http://www.itee.uq.edu.au/~coms3200/, (Sept, 2002) 2. ‘Music across
17. ‘MP3’, (1999), Webopedia, URL:http://www.webopedia.com/TERM/M/MP3.html, (Sept, 2002) 18. Nullsoft Winamp Home Page, http://www.winamp.com/, (Sep
Appendices Appendix A – The Player Source code /* * MP3 player with network interface. * The Ethernut code * Engineering Thesis 2002 * by Mic
static HANDLE q_stop = 0; static HANDLE q_next = 0; static HANDLE q_previous = 0; char button = 0; char first = 1; /* * Pause button ISR */ static
Chapter 1 – Introduction 1.1 Motivation MP3s are quickly becoming a very popular format for audio storage. As a result, the number of MP3 players av
/* Signal to debounce that a button has been pressed */ button = 1; /* change mode to stop */ play = 0; /* This will discard all transfer u
/* * debounce thread */ THREAD(debounce, arg) { while(1){ /* Wait for button press */ NutSleep(100); if (button){ /* Re -
* Nut/OS automatically calls this entry after initialization. */ THREAD(NutMain, arg) { TCPSOCKET *sock; int bytes; int buffer_in = 0; int
*/ NutRegisterDevice(&devEth0, 0x8300, 5); /* * Configure lan interface. * */ NutNetIfConfig("eth0", ma
/* Reset the decoder */ VsReset(0); discard = 0; /* * Place the transmit pointer to
/* If set the buffer is set to refill */ if(first){ /* If the buffer is full again */ if(buffer_in >
Appendix B – Server Source code /* * MP3 player with network interface. * Server software * Engineering Thesis 2002 * by Michael Somersmith
/* place the number in the string */ while(length>0){ tmp = length - 1; power = 1; while( tmp > 0 ){ power *=
/* Add the song number to the start of the song name */ song_to_send_ptr += add_number_song_name(song_count, &song_name_to_send
* and to write to */ song_name_ptr = &song_name[0]; songs_ptr = &songs[0]; ReadFile (PlayList, &songs[0], 100000, &bytes,
ideal for playback as a stream of data remote from where they are stored. This is not a new idea; it is commonly done on a PC, where people can play
} else { /* close old MP3 file */ CloseHandle(FileHandle); /* send the new song name to the ethernut */ send_song_name(song_no, &am
song_no++; open_MP3(song_no); reopen = 1; if(stop == 0){ go = 1; } /* NEXT decrements the song count and opens th
/* Set up the network information structures */ server.sin_family = AF_INET; server.sin_port = htons(iPort); server.sin_addr.s_addr
printf("connecting\n"); if (connect(song_Server, (struct sockaddr *)&song_server, sizeof(song_server)) == SOCKET_ERROR) {
printf("Done\r\n"); } /* Send the MP3 data to the ethernut */ bytes_sent = send(Server, &buffer[0],
Appendix C – LCD interface source code /* * MP3 player with network interface. * The Ethernut LCD code * Engineering Thesis 2002 * by Michael
} /* clear the rest of line 1 and line 2 */ if(line == 0){ while(counter < NO_COL){ counter++; putch(' ');
delay2 (40); control(0x02); // 4 bit control(0x08); // 2 lines delay2 (40); control(0x00); //display on, cursor off, blink off
char temp; u_char priority; /* Set the thread priority to the highest */ priority = NutThreadSetPriority(10); LCD_RS(1); // select the d
printxy(0,0," "); printxy(1,0," "); } 93
Comments to this Manuals