arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
HeaderParserMP3 Class Reference

MP3 header parser to check if the data is a valid mp3 and to extract some relevant audio information. We try to find some valid frames with a valid sync in the beginning and the end. See https://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx. More...

#include <HeaderParserMP3.h>

Public Member Functions

int findSyncWord (const uint8_t *buf, size_t nBytes, uint8_t synch=0xFF, uint8_t syncl=0xF0)
 Finds the mp3/aac sync word.
 
int getBitRate () const
 
FrameHeader getFrameHeader ()
 
int getFrameLength ()
 Determines the frame length.
 
const char * getLayerStr () const
 
size_t getPlayingTime (size_t fileSizeBytes)
 
uint16_t getSampleRate () const
 
const char * getVersionStr () const
 
bool isValid (const uint8_t *data, int len)
 parses the header string and returns true if this is a valid mp3 file
 

Protected Types

enum class  FrameReason {
  VALID , INVALID_BITRATE_FOR_VERSION , INVALID_SAMPLERATE_FOR_VERSION , INVALID_MPEG_VERSION ,
  INVALID_LAYER , INVALID_LAYER_II_BITRATE_AND_MODE , INVALID_EMPHASIS , INVALID_CRC
}
 

Protected Member Functions

bool contains (const uint8_t *data, const char *toFind, size_t len)
 
void readFrameHeader (const uint8_t *data)
 
int seekFrameSync (const uint8_t *str, size_t len)
 
bool validate (const uint8_t *data, size_t len)
 
FrameReason validateFrameHeader (const FrameHeader &header)
 

Protected Attributes

FrameHeader header
 

Detailed Description

MP3 header parser to check if the data is a valid mp3 and to extract some relevant audio information. We try to find some valid frames with a valid sync in the beginning and the end. See https://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx.

Author
Phil Schatzmann

Member Function Documentation

◆ getPlayingTime()

size_t getPlayingTime ( size_t  fileSizeBytes)
inline

Provides the estimated playing time in seconds based on the bitrate of the first segment


The documentation for this class was generated from the following file: