MP3

Home Up VNC2 Adafruit RGB LED Matrix Visual Spin YModem Wavetable Midi Player Prop EKG Basic Window/Form System PropMonitor 1-Bit Bitmaps 6-Bit Bitmaps DAC Sparkfun Nokia LCD Cameras MP3 Wireless JuiceBox I/O Expansion Via I2C Secure Digital (SD) Card Interface Notes on Graphics_Demo.spin ADC 2-Bit Bitmap App TV Colors Interleaved Character Generator 4-Color Character Applet VGA Colors Applets

bullet

I am looking into the prospects for playing MP3 music files with the Propeller.  At this point, it looks futile, but I'm looking at it closely anyway...  The main issues are amount of RAM and processing speed.

bullet

Goal:  Playback of stereo, 44100-kHz 128-kbps MP3 file from SD card

bullet

Fallback 1:  Play mono or single channel with the option of using 2 Props to play stereo.

bullet

Fallback 2:  Wait for Prop II (coming soon?)

bullet

I've found that the LIBMAD software is well suited for the task because it uses integer (fixed-point) math whereas most others use floating-point routines.  LIBMAD appears to have been used in many embedded projects.

bullet

MP3->WAV converter in SPIN.

bullet

There's no way that real-time MP3 playback could be achieved in SPIN.  But, code in SPIN and PASM (Propeller Assembly) seem to require about the same amount of RAM and the relative speed difference is know to be between 40 and 200.  So, if an MP3 file can be decoded in SPIN in ~100x real time, then the prospects would be good for real-time playback when converted to PASM.

bullet

So far, I am able to decode the first 576 samples of a test MP3 file with two SPIN programs (because it wouldn't fit into 32k).  This represents the first channel of the first granule of the first frame.  The first SPIN program decodes the MP3 data stream and produces time domain samples in the XR array.  The second SPIN program converts the XR array to frequency domain and then synthesizes the PCM samples.

bullet
Program 1:  MP32Wav2A.SPIN
bullet
Requires these files:
bullet
test.mp3
bullet
rq_table.dat
bullet
Huffman Tables
bullet
Program 2:  MP32Wav1B.SPIN
bullet
Requires these files:
bullet
frames.tmp
bullet
d.dat  
bullet

Memory requirements for MP3 playback.

bullet

This is the first hurdle to overcome.  There are several arrays used in LIBMAD that are much to big to fit into the 32kB of the Prop.  Most of them can be reduced by going from 32 to 16 bits.  Also, there are other tricks for some arrays.  Here's a table of big arrays used in LIBMAD and the minimum size I think they could be for the Prop:

bullet

Array Name

Usage

Size in LIBMAD

Min. Size for with Prop

InputBuffer MP3 file input buffer 40 kB perhaps 512 B since using flash
OutputBuffer PCM sample output buffer 8 kB 2.4 kB {word [2*576]  half this for mono}
Main_Data buffer for main data of stream 2.5 kB ~2 kB {maybe a bit less for mono}
xr decode frequency domain data 9.2 kB 2.4 kB {word [2*576]  half this for mono}
rq_table requantization tables 32.8 kB 1.0 kB  {maybe half this for 16 bits?}
Layer3 data   ~4 kB 906 B {much less if only supporting 44100 Hz}
Huffman tables info to uncompress main data ~8 kB 4.4 kB
t temp storage for DCT32 1 kB 354 B
D constants for synthesis 2.2 kB 1.1 kB  {made word sized with no loss}
pcm_samples output samples 9.2 kB 0  {use outputBuffer instead}
sideinfo frame sideinfo storage   234 B
frame_sbsample buffer for time domain data 9.2 kB 1.2 kB  {doing one channel at a time with words}
frame_overlap time domain overlapping data 4.6 kB 2.3 kB (half for mono)
window_l windowing constants 144 B 72 B
synth_filter data for synthesis 4 kB 2 kB (half for mono)
       
TOTAL   a lot ! 21 kB
       

 
bulletHere's a look at the big procedure sizes
bullet
Function SPIN Size (B)
III_huffdecode 1500
synth_full 1411
dct32 4308
imdct36 2894
   
   
   
   
total 8.6 kB