3641 views|2 replies

224

Posts

0

Resources
The OP
 

Use the MP3 decoding library provided by ST [Copy link]

Hardware platform: STM32F746G-DISC

Development platform: KEIL_5.29

I will not introduce the detailed structure of MP3 files here , but only introduce how to use the MP3 decoding library. If you need to know more about MP3 files, you can refer to this website : https://www.cnblogs.com/ranson7zop/p/7655474.html

This decoding library can be downloaded from the ST company's official website by searching for the keyword " x-cube-audio ". After downloading and decompressing, enter this path: STM32CubeExpansion_Audio_V1.1.1\Middlewares\ST\STM32_Audio\Codecs , and you can see that there are two folders, as shown in the figure below:

Enter the directory of the decoding library, there will be 3 folders, as shown below:

Enter the lib folder, there will be 3 decoding libraries, corresponding to different platforms

I am using STM32F7 here , and of course I choose the lib file of the M7 platform .

Next, create a KEIL project, debug the SD card driver and the audio chip WM8994 driver first, then copy the SpiritDSP_MP3_Dec folder to the project directory, add the lib file in keil , and set the include path, then the MP3 decoding library is added.

Next, let's explain the functions used for MP3 decoding, which can be found in the spiritMP3Dec.h file.

1. void SpiritMP3DecoderInit(

TSpiritMP3Decoder *pDecoder,

fnSpiritMP3ReadCallback* pCallbackFn,

fnSpiritMP3ProcessCallback *pProcessFn,

void * token )

Function: Initialize the MP3 decoder. After each decoding, before decoding a new MP3 file, you must call this function again to complete the initialization of the MP3 decoder.

parameter:

TSpiritMP3Decoder *pDecoder :

Pointer to the decoder structure to be initialized. All decoder variables are stored in this structure. The decoder does not use non-constant static or global variables, so all functions are reentrant.

fnSpiritMP3ReadCallback* pCallbackFn :

Pointer to callback function, the decoder will use this function to retrieve the input mp3 data.

fnSpiritMP3ProcessCallback *pProcessFn :

Callback function pointer. The decoder will use this function to process MDCT coefficients when decoding Layer3 files . This function is not needed at present, so set it to NULL .

void * token

Optional arguments passed to the callback function.

2. typedef unsigned int (fnSpiritMP3ReadCallback)

(

void * pMP3CompressedData,

unsigned int nMP3DataSizeInChars,

void * token

)

Function: The decoder uses it to read MP3 file data, this function must be implemented.

parameter:

void * pMP3CompressedData

Store the read mp3 data.

unsigned int nMP3DataSizeInChars :

The size of the MP3 data to be read .

void * token

Optional parameters for the callback function.

3. unsigned int SpiritMP3Decode (

TSpiritMP3Decoder *pDecoder,

short *pPCMSamples,

unsigned int nSamplesRequired,

TSpiritMP3Info * pMP3Info

);

Function: Decode each frame of MP3 data and store the decoded data in pPCMSamples . If the return value of this function is less than nSamplesRequired , the file pointer has reached the end of the MP3 file and the MP3 file decoding is complete, otherwise continue to call this function for decoding.

parameter:

TSpiritMP3Decoder *pDecoder :

Pointer to an initialized decoder structure.

short *pPCMSamples :

Stores the decoded output PCM data.

unsigned int nSamplesRequired :

The number of samples per audio frame in an MP3 file

TSpiritMP3Info * pMP3Info :

After decoding is completed, the decoding information of the current audio frame is stored. The IsGoodStream member in the TSpiritMP3Info structure is used to determine whether the decoding of the current audio frame is successful. If the decoding is successful, it is 1 , and if it fails, it is 0 .

Here is an introduction to the usage process of the decoding library. For specific codes, please refer to my program.

使用ST公司提供的MP3解码库.docx

117.11 KB, downloads: 51

Audio.zip

4.85 MB, downloads: 243

This post is from stm32/stm8

Latest reply

Thank you for sharing~~ Not bad~   Details Published on 2020-5-24 16:49
 

6040

Posts

204

Resources
2
 

Nice, thanks for sharing

This post is from stm32/stm8
 
 

1w

Posts

204

Resources
3
 

Thank you for sharing~~ Not bad~

This post is from stm32/stm8
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list