Thmp3/Devblog

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
(background)
(background)
Line 4: Line 4:
 
==background==
 
==background==
 
The thmp3 lib uses Helix mp3 decoder, which is a free open source mp3 decoder lib with special optimizations for the ARM series of CPUs. The decoding is done in the ARM7 cpu while the ARM9 fetches data from files and commands the ARM7.
 
The thmp3 lib uses Helix mp3 decoder, which is a free open source mp3 decoder lib with special optimizations for the ARM series of CPUs. The decoding is done in the ARM7 cpu while the ARM9 fetches data from files and commands the ARM7.
 +
 +
==New Features==
 +
The following new features are added:
 +
* mp3Swap - this function allows swapping an active stream while maintaining the position of the previous stream. In this way one stream may be effectively 'paused' while another one plays.
 +
* mp3Pause - this is obvious :P
 +
* mp3StopSync - normally mp3Stop will just issue the command to stop, however if start is requested before stop is completed errors or missed requests may occur.
 +
 +
==Todo==
 +
The following features need adding:
 +
* mp3SeekTo(int ms) ~ seek to position
 +
 +
==Bugs==
 +
Need 2 fix :|
 +
* mp3Pause - it works the first time but then screws up apon restart.
  
 
==2009.06.22 ~ Rate Switching==
 
==2009.06.22 ~ Rate Switching==

Revision as of 05:19, 23 June 2009

Contents

Whats this?

Blog regarding functionality of the mp3 player. This was start almost a year after original release since there were major changes.

background

The thmp3 lib uses Helix mp3 decoder, which is a free open source mp3 decoder lib with special optimizations for the ARM series of CPUs. The decoding is done in the ARM7 cpu while the ARM9 fetches data from files and commands the ARM7.

New Features

The following new features are added:

  • mp3Swap - this function allows swapping an active stream while maintaining the position of the previous stream. In this way one stream may be effectively 'paused' while another one plays.
  • mp3Pause - this is obvious :P
  • mp3StopSync - normally mp3Stop will just issue the command to stop, however if start is requested before stop is completed errors or missed requests may occur.

Todo

The following features need adding:

  • mp3SeekTo(int ms) ~ seek to position

Bugs

Need 2 fix :|

  • mp3Pause - it works the first time but then screws up apon restart.

2009.06.22 ~ Rate Switching

Almost done! :D Finally have enabled mp3 rate switching midstream with continious playback.

Basically using the PCM playback position indicator which is implemented as follows: A timer is set to interrupt every samplerate/1152 (1152 = number of samples in a typical mp3 frame, this may vary rarely but for this purpose it works), every timer interrupt PCM position indicator is incremented by 1152 (position contained in mp3Ipc->mfram within code), the timer is started and stopped simultaneously with PCM playback. This was in the last release and used to indicate the time in ms intended to be used in rhythm games. Further you may tell the approx playback position by mp3Ipc->mfram % PCMBUF_SAMPLES.

2009.06.17

Was decided to use a state machine on both sides (the arm7 actually has two state machines for decoding and playback of pcm). Among other things state machines allow different states' (sometimes also called stages or steps), each stage has actions to perform and/or conditions to check for. If the proper conditions are met the machine will move to another stage, perform other actions, wait for other conditions.

For instance, the mp3 player has states such as READY, PLAYING, and PAUSED. it actually has a few more, but for illustration, these will do.

In this example can see operation of simple state machine, as the machine receives commands, depending on the current state it will perform different actions and

switch(state) {
   case STOPPED:
      if(cmd==PLAY) {
       startPlaying();
       state=PLAYING;
     break;
   case PLAYING:
      select(cmd) {
       case STOP:
        state=STOPING;
        break;
       case PAUSE:
        pausePlaying();
        state=PAUSED;
        break;
      };
     break;
   case STOPING:
        stopPlaying();
        state=STOPPED;
     break;
   case PAUSED:
     select(cmd) {
      case PLAY:
        startPlaying();
        state=PLAYING;
      case STOP:
        state=STOPING;
        break;
     }; 
     break;
 }

Most of the old control code was replaced with state machine design patterns. Making it more stable, and easier to read among other things. More stable because now ARM9 waits for the other CPU to acknowledge completion of a command before changing its own state, much better than sending commands and hoping it worked.. :P

Another useful thing here with state machines on a single process system, the SM's code can be called over and over in a loop and it wont change state untill the proper conditions have been met. >:D

Personal tools
irssi scripts
eggdrop scripts