RA Flexible Software Package Documentation  Release v6.2.0

 
Minimp3 Library

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 a MCU with 32KB of RAM size or more to function properly.

Minimum stack usage is 18KB that must be considered the stack size under BSP configuration tab to ensure provide enough stack for the software operation.

This library uses floating-point numbers in its operation, therefore it shall be used on MCUs that have FPU. Non-FPUs are still able to use this library but the performance will be significantly degraded.

How to use

To use minimp3 library, follow the steps below:

Configuration

Build Time Configurations for Lib

The following build time configurations are defined in fsp_cfg/minimp3/minimp3_config.h:

ConfigurationOptionsDefaultDescription
Float Output
  • Enabled
  • Disabled
Disabled Output PCM as float instead of short
SIMD Optimization
  • Enabled
  • Disabled
Disabled Enable SIMD optimization for MP3 decoding using Arm Helium (MVE).
Decode MP3 only
  • Enabled
  • Disabled
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;
/* Initialize for decoding a new position */
mp3dec_init(&mp3dec);
/* Decode MP3 data frame by frame */
do
{
/* Decode a frame */
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);
/* Update position offset of MP3 and PCM data */
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;
/* Initialize for decoding a new position */
mp3dec_init(&mp3dec);
/* Stream MP3 data frame by frame */
do
{
/* Update MP3 data position and MP3 data size.
* This is a user-defined function for providing continuous MP3 data for streaming. */
mp3_read(&p_mp3_feed_pos, &mp3_feed_size);
/* Decode one frame */
int samples = mp3dec_decode_frame(&mp3dec, p_mp3_feed_pos, (int) mp3_feed_size, pcm_data, &frame_info);
/* Get PCM data output size. */
uint32_t pcm_size = (uint32_t) (samples * frame_info.channels);
/* Handle PCM data output.
* This is a user-defined function for handling PCM data output after each frame is decoded. */
pcm_progress(pcm_data, pcm_size);
} while (mp3_feed_size);
}