Minimalistic, single-header library for decoding MP3.
Overview
Integration of minimp3 library with FSP RA.
Usage
For detailed usage of minimp3, please visit https://github.com/lieff/minimp3.
ARM Helium Support
Helium (with SIMD support) can be enabled to accelerate the decoding process on devices that support it.
Limitations
minimp3 requires an MCU with a FPU (Floating-Point Unit) to function properly. Devices without FPU capability will not be supported by this library.
How to use
To use minimp3 library, follow the steps below:
- In e2studio, add minimp3 stack by selecting New Stack -> Audio -> Minimp3 Library Source.
- Fix stack constraints and choose Generate Project Content.
- In your source code, remember to include minimp3.h or minimp3_ex.h.
Configuration
Build Time Configurations for Lib
The following build time configurations are defined in fsp_cfg/minimp3/minimp3_config.h:
Configuration | Options | Default | Description |
Float Output |
| Disabled | Output PCM as float instead of short |
SIMD Optimization |
| Disabled | Enable SIMD optimization for MP3 decoding using Arm Helium (MVE). |
Decode MP3 only |
| Disabled | Enable this option to skip MP1/MP2 and only support MP3 decoding. |
Examples
Minimp3 Basic Example
This is a basic example demonstrating minimal usage of the minimp3 library implementation in an application.
void minimp3_basic_example ()
{
uint32_t mp3_offset = 0;
uint32_t pcm_offset = 0;
mp3dec_frame_info_t frame_info;
mp3dec_t mp3dec;
mp3dec_init(&mp3dec);
do
{
int samples = mp3dec_decode_frame(&mp3dec,
g_mp3_buf + mp3_offset,
(int) (MP3_BUFFER_SIZE_BYTES - mp3_offset),
g_pcm_buf + pcm_offset,
&frame_info);
mp3_offset += (uint32_t) (frame_info.frame_bytes);
pcm_offset += (uint32_t) (samples * frame_info.channels);
} while (MP3_BUFFER_SIZE_BYTES != mp3_offset);
}
Minimp3 Streaming Example
This example demonstrates streaming usage of the minimp3 library implementation in an application.
void minimp3_streaming_example ()
{
uint8_t * p_mp3_feed_pos;
uint32_t mp3_feed_size;
mp3d_sample_t pcm_data[MINIMP3_MAX_SAMPLES_PER_FRAME];
mp3dec_frame_info_t frame_info;
mp3dec_t mp3dec;
mp3dec_init(&mp3dec);
do
{
mp3_read(&p_mp3_feed_pos, &mp3_feed_size);
int samples = mp3dec_decode_frame(&mp3dec, p_mp3_feed_pos, (int) mp3_feed_size, pcm_data, &frame_info);
uint32_t pcm_size = (uint32_t) (samples * frame_info.channels);
pcm_progress(pcm_data, pcm_size);
} while (mp3_feed_size);
}