Xeno-rat
Loading...
Searching...
No Matches
NAudio.Wave.Mp3Frame Class Reference

Represents an MP3 Frame. More...

Collaboration diagram for NAudio.Wave.Mp3Frame:

Static Public Member Functions

static Mp3Frame LoadFromStream (Stream input)
 Loads an MP3 frame from the given input stream and returns the frame.
 
static Mp3Frame LoadFromStream (Stream input, bool readData)
 Reads an MP3Frame from a stream.
 

Properties

int SampleRate [get, private set]
 Sample rate of this frame.
 
int FrameLength [get, private set]
 Frame length in bytes.
 
int BitRate [get, private set]
 Bit Rate.
 
byte[] RawData [get, private set]
 Raw frame data (includes header bytes)
 
MpegVersion MpegVersion [get, private set]
 MPEG Version.
 
MpegLayer MpegLayer [get, private set]
 MPEG Layer.
 
ChannelMode ChannelMode [get, private set]
 Channel Mode.
 
int SampleCount [get, private set]
 The number of samples in this frame.
 
int ChannelExtension [get, private set]
 The channel extension bits.
 
int BitRateIndex [get, private set]
 The bitrate index (directly from the header)
 
bool Copyright [get, private set]
 Whether the Copyright bit is set.
 
bool CrcPresent [get, private set]
 Whether a CRC is present.
 
long FileOffset [get, private set]
 Not part of the MP3 frame itself - indicates where in the stream we found this header.
 

Private Member Functions

 Mp3Frame ()
 Constructs an MP3 frame.
 

Static Private Member Functions

static bool IsValidHeader (byte[] headerBytes, Mp3Frame frame)
 Checks if the provided header bytes and Mp3Frame are valid and returns a boolean value indicating the result.
 

Static Private Attributes

static readonly int[,,] bitRates
 
static readonly int[,] samplesPerFrame
 
static readonly int[] sampleRatesVersion1 = new int[] {44100, 48000, 32000}
 
static readonly int[] sampleRatesVersion2 = new int[] {22050, 24000, 16000}
 
static readonly int[] sampleRatesVersion25 = new int[] {11025, 12000, 8000}
 
const int MaxFrameLength = 16*1024
 

Detailed Description

Represents an MP3 Frame.

Constructor & Destructor Documentation

◆ Mp3Frame()

NAudio.Wave.Mp3Frame.Mp3Frame ( )
inlineprivate

Constructs an MP3 frame.

Here is the caller graph for this function:

Member Function Documentation

◆ IsValidHeader()

static bool NAudio.Wave.Mp3Frame.IsValidHeader ( byte[] headerBytes,
Mp3Frame frame )
inlinestaticprivate

Checks if the provided header bytes and Mp3Frame are valid and returns a boolean value indicating the result.

Parameters
headerBytesThe header bytes of the Mp3Frame.
frameThe Mp3Frame to be validated.
Returns
True if the header bytes and Mp3Frame are valid; otherwise, false.

This method checks if the provided header bytes and Mp3Frame are valid according to the MPEG audio format specifications. It validates various properties of the Mp3Frame such as MPEG version, layer, bit rate, sample rate, channel mode, frame length, etc. If any of the properties are invalid, the method returns false; otherwise, it returns true.

Here is the caller graph for this function:

◆ LoadFromStream() [1/2]

static Mp3Frame NAudio.Wave.Mp3Frame.LoadFromStream ( Stream input)
inlinestatic

Loads an MP3 frame from the given input stream and returns the frame.

Parameters
inputThe input stream from which to load the MP3 frame.
readDataA boolean value indicating whether to read the frame data from the input stream.
Returns
The loaded MP3 frame.

This method reads the header bytes from the input stream and validates them to identify an MP3 frame. If the header is not valid, it shifts down by one and tries again until a valid header is found. Once a valid header is found, it reads the frame data from the input stream based on the frame length. If readData is false, it skips reading the frame data and moves the input stream position accordingly.

Exceptions
EndOfStreamExceptionThrown when an unexpected end of stream is encountered before the frame is complete.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFromStream() [2/2]

static Mp3Frame NAudio.Wave.Mp3Frame.LoadFromStream ( Stream input,
bool readData )
inlinestatic

Reads an MP3Frame from a stream.

http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm has some good info also see http://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx

Returns
A valid MP3 frame, or null if none found
Here is the call graph for this function:

Member Data Documentation

◆ bitRates

readonly int [,,] NAudio.Wave.Mp3Frame.bitRates
staticprivate
Initial value:
= new int[,,] {
{
{ 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
{ 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 },
},
{
{ 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
{ 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
}
}

◆ MaxFrameLength

const int NAudio.Wave.Mp3Frame.MaxFrameLength = 16*1024
staticprivate

◆ sampleRatesVersion1

readonly int [] NAudio.Wave.Mp3Frame.sampleRatesVersion1 = new int[] {44100, 48000, 32000}
staticprivate

◆ sampleRatesVersion2

readonly int [] NAudio.Wave.Mp3Frame.sampleRatesVersion2 = new int[] {22050, 24000, 16000}
staticprivate

◆ sampleRatesVersion25

readonly int [] NAudio.Wave.Mp3Frame.sampleRatesVersion25 = new int[] {11025, 12000, 8000}
staticprivate

◆ samplesPerFrame

readonly int [,] NAudio.Wave.Mp3Frame.samplesPerFrame
staticprivate
Initial value:
= new int[,] {
{
384,
1152,
1152
},
{
384,
1152,
576
}
}

Property Documentation

◆ BitRate

int NAudio.Wave.Mp3Frame.BitRate
getprivate set

Bit Rate.

◆ BitRateIndex

int NAudio.Wave.Mp3Frame.BitRateIndex
getprivate set

The bitrate index (directly from the header)

◆ ChannelExtension

int NAudio.Wave.Mp3Frame.ChannelExtension
getprivate set

The channel extension bits.

◆ ChannelMode

ChannelMode NAudio.Wave.Mp3Frame.ChannelMode
getprivate set

Channel Mode.

◆ Copyright

bool NAudio.Wave.Mp3Frame.Copyright
getprivate set

Whether the Copyright bit is set.

◆ CrcPresent

bool NAudio.Wave.Mp3Frame.CrcPresent
getprivate set

Whether a CRC is present.

◆ FileOffset

long NAudio.Wave.Mp3Frame.FileOffset
getprivate set

Not part of the MP3 frame itself - indicates where in the stream we found this header.

◆ FrameLength

int NAudio.Wave.Mp3Frame.FrameLength
getprivate set

Frame length in bytes.

◆ MpegLayer

MpegLayer NAudio.Wave.Mp3Frame.MpegLayer
getprivate set

MPEG Layer.

◆ MpegVersion

MpegVersion NAudio.Wave.Mp3Frame.MpegVersion
getprivate set

MPEG Version.

◆ RawData

byte [] NAudio.Wave.Mp3Frame.RawData
getprivate set

Raw frame data (includes header bytes)

◆ SampleCount

int NAudio.Wave.Mp3Frame.SampleCount
getprivate set

The number of samples in this frame.

◆ SampleRate

int NAudio.Wave.Mp3Frame.SampleRate
getprivate set

Sample rate of this frame.


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