MP3 Player without external hardware MP3 Player without external hardware. A software based MP3 player based on a modified version of libmad. Mono output (at the moment) via AnalogOut. Files are read from an USB drive. This is a demo program, it plays only one file at the moment. Documentation is in "main.cpp" and "config.h"
lpc1768_mem.cpp@2:f28cf0afd021, 2010-11-27 (annotated)
- Committer:
- Gruenfrosch
- Date:
- Sat Nov 27 17:27:33 2010 +0000
- Revision:
- 2:f28cf0afd021
Version 3:
* moved another memory block into AHB RAM, giving more room for
* stereo buffer.
* moved content of decode() to main()
* decoding is now safe to be called multiple times (bug in older versions)
* Output routine now fills stereo buffer, DAC output sums channels,
* just for demonstration that stereo output could go here
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gruenfrosch | 2:f28cf0afd021 | 1 | #include "mbed.h" |
Gruenfrosch | 2:f28cf0afd021 | 2 | #include "config.h" |
Gruenfrosch | 2:f28cf0afd021 | 3 | |
Gruenfrosch | 2:f28cf0afd021 | 4 | static char *free_ptr = (char *)AHBMEM; |
Gruenfrosch | 2:f28cf0afd021 | 5 | static int free_sz = AHBMEMSIZE; |
Gruenfrosch | 2:f28cf0afd021 | 6 | void reset_ahb_mem(void) |
Gruenfrosch | 2:f28cf0afd021 | 7 | { |
Gruenfrosch | 2:f28cf0afd021 | 8 | free_ptr = (char *)AHBMEM; |
Gruenfrosch | 2:f28cf0afd021 | 9 | free_sz = AHBMEMSIZE; |
Gruenfrosch | 2:f28cf0afd021 | 10 | } |
Gruenfrosch | 2:f28cf0afd021 | 11 | void *mad_malloc(unsigned int sz) |
Gruenfrosch | 2:f28cf0afd021 | 12 | { |
Gruenfrosch | 2:f28cf0afd021 | 13 | unsigned int nsz = ((sz >> 3) + 1) << 3; // align to 8 byte |
Gruenfrosch | 2:f28cf0afd021 | 14 | if(nsz < free_sz) |
Gruenfrosch | 2:f28cf0afd021 | 15 | { |
Gruenfrosch | 2:f28cf0afd021 | 16 | char *p = free_ptr; |
Gruenfrosch | 2:f28cf0afd021 | 17 | free_ptr += nsz; |
Gruenfrosch | 2:f28cf0afd021 | 18 | free_sz -=nsz; |
Gruenfrosch | 2:f28cf0afd021 | 19 | return(p); |
Gruenfrosch | 2:f28cf0afd021 | 20 | } |
Gruenfrosch | 2:f28cf0afd021 | 21 | else |
Gruenfrosch | 2:f28cf0afd021 | 22 | { |
Gruenfrosch | 2:f28cf0afd021 | 23 | return(malloc(sz)); |
Gruenfrosch | 2:f28cf0afd021 | 24 | } |
Gruenfrosch | 2:f28cf0afd021 | 25 | } |