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

A read-only stream of AIFF data based on an aiff file with an associated WaveFormat originally contributed to NAudio by Giawa. More...

Inheritance diagram for NAudio.Wave.AiffFileReader:
Collaboration diagram for NAudio.Wave.AiffFileReader:

Classes

struct  AiffChunk
 AIFF Chunk. More...
 

Public Member Functions

 AiffFileReader (String aiffFile)
 Supports opening a AIF file.
 
 AiffFileReader (Stream inputStream)
 Creates an Aiff File Reader based on an input stream.
 
override int Read (byte[] array, int offset, int count)
 Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
 
- Public Member Functions inherited from NAudio.Wave.WaveStream
override void Flush ()
 Flushes the buffer of the current stream and causes any buffered data to be written to the underlying device.
 
override long Seek (long offset, SeekOrigin origin)
 Sets the position within the current stream.
 
override void SetLength (long length)
 Throws a NotSupportedException with the message "Can't set length of a WaveFormatString".
 
override void Write (byte[] buffer, int offset, int count)
 Throws a NotSupportedException with the message "Can't write to a WaveFormatString".
 
void Skip (int seconds)
 Skips the playback to a new position in the audio file based on the specified number of seconds.
 
virtual bool HasData (int count)
 Checks if there is data available at the current position.
 

Static Public Member Functions

static void ReadAiffHeader (Stream stream, out WaveFormat format, out long dataChunkPosition, out int dataChunkLength, List< AiffChunk > chunks)
 Reads the AIFF header from the provided stream and extracts the wave format, data chunk position, data chunk length, and optional additional chunks.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the AiffFileReader and optionally releases the managed resources.
 

Properties

override WaveFormat WaveFormat [get]
 WaveStream.WaveFormat
 
override long Length [get]
 WaveStream.WaveFormat
 
long SampleCount [get]
 Number of Samples (if possible to calculate)
 
override long Position [get, set]
 Position in the AIFF file Stream.Position
 
- Properties inherited from NAudio.Wave.WaveStream
WaveFormat WaveFormat [get]
 Retrieves the WaveFormat for this stream.
 
override bool CanRead [get]
 We can read from this stream.
 
override bool CanSeek [get]
 We can seek within this stream.
 
override bool CanWrite [get]
 We can't write to this stream.
 
virtual int BlockAlign [get]
 The block alignment for this wavestream. Do not modify the Position to anything that is not a whole multiple of this value.
 
virtual TimeSpan CurrentTime [get, set]
 The current position in the stream in Time format.
 
virtual TimeSpan TotalTime [get]
 Total length in real-time of the stream (may be an estimate for compressed files)
 
- Properties inherited from NAudio.Wave.IWaveProvider

Static Private Member Functions

static uint ConvertInt (byte[] buffer)
 Converts a byte array to an unsigned integer.
 
static short ConvertShort (byte[] buffer)
 Converts a byte array to a short integer and returns the result.
 
static AiffChunk ReadChunkHeader (BinaryReader br)
 Reads the header of a chunk from the provided BinaryReader and returns an AiffChunk object.
 
static string ReadChunkName (BinaryReader br)
 Reads a chunk name from the provided BinaryReader and returns it as a string.
 

Private Attributes

readonly WaveFormat waveFormat
 
readonly bool ownInput
 
readonly long dataPosition
 
readonly int dataChunkLength
 
readonly List< AiffChunkchunks = new List<AiffChunk>()
 
Stream waveStream
 
readonly object lockObject = new object()
 

Detailed Description

A read-only stream of AIFF data based on an aiff file with an associated WaveFormat originally contributed to NAudio by Giawa.

Constructor & Destructor Documentation

◆ AiffFileReader() [1/2]

NAudio.Wave.AiffFileReader.AiffFileReader ( String aiffFile)
inline

Supports opening a AIF file.

The AIF is of similar nastiness to the WAV format. This supports basic reading of uncompressed PCM AIF files, with 8, 16, 24 and 32 bit PCM data.

◆ AiffFileReader() [2/2]

NAudio.Wave.AiffFileReader.AiffFileReader ( Stream inputStream)
inline

Creates an Aiff File Reader based on an input stream.

Parameters
inputStreamThe input stream containing a AIF file including header
Here is the call graph for this function:

Member Function Documentation

◆ ConvertInt()

static uint NAudio.Wave.AiffFileReader.ConvertInt ( byte[] buffer)
inlinestaticprivate

Converts a byte array to an unsigned integer.

Parameters
bufferThe byte array to be converted.
Exceptions
ExceptionThrown when the length of the buffer is not 4.
Returns
The unsigned integer value obtained from the byte array.

This method converts the input byte array buffer to an unsigned integer by performing bitwise operations on the individual bytes. It shifts the bytes to their respective positions and then performs a bitwise OR operation to combine them into a single integer value. If the length of the input buffer is not 4, an exception is thrown indicating an incorrect length for the conversion.

Here is the caller graph for this function:

◆ ConvertShort()

static short NAudio.Wave.AiffFileReader.ConvertShort ( byte[] buffer)
inlinestaticprivate

Converts a byte array to a short integer and returns the result.

Parameters
bufferThe byte array to be converted to a short integer.
Returns
The short integer value obtained by converting the input byte array.
Exceptions
ExceptionThrown when the length of the input byte array is not 2.

This method converts the input byte array to a short integer by performing a bitwise left shift operation on the first byte and then performing a bitwise OR operation with the second byte. The resulting short integer value is returned.

Here is the caller graph for this function:

◆ Dispose()

override void NAudio.Wave.AiffFileReader.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the AiffFileReader and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the AiffFileReader and optionally releases the managed resources. If disposing is true, this method releases all resources held by any managed objects that this AiffFileReader references. This method is called by the public Dispose() method and the Finalize method.

◆ Read()

override int NAudio.Wave.AiffFileReader.Read ( byte[] array,
int offset,
int count )
inline

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Parameters
arrayAn array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offsetThe zero-based byte offset in array at which to begin storing the data read from the current stream.
countThe maximum number of bytes to be read from the current stream.
Exceptions
ArgumentExceptionThrown when count is not a multiple of waveFormat.BlockAlign.
Returns
The total number of bytes read into the buffer. This might be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream is reached.

This method reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. If the end of the stream is reached, it returns zero. It first checks if count is a multiple of waveFormat.BlockAlign, and if not, it throws an ArgumentException. It then locks the lockObject to ensure thread safety while reading from the stream. It checks if there is more data at the end of the file past the data chunk, and adjusts the count accordingly. It reads data from waveStream into a buffer and then performs endianness conversion based on the wave format's BitsPerSample. Finally, it returns the total number of bytes read into the buffer.

Implements NAudio.Wave.IWaveProvider.

◆ ReadAiffHeader()

static void NAudio.Wave.AiffFileReader.ReadAiffHeader ( Stream stream,
out WaveFormat format,
out long dataChunkPosition,
out int dataChunkLength,
List< AiffChunk > chunks )
inlinestatic

Reads the AIFF header from the provided stream and extracts the wave format, data chunk position, data chunk length, and optional additional chunks.

Parameters
streamThe input stream containing the AIFF data.
formatWhen this method returns, contains the wave format extracted from the AIFF header, if valid; otherwise, null.
dataChunkPositionWhen this method returns, contains the position of the data chunk within the stream, if found; otherwise, -1.
dataChunkLengthWhen this method returns, contains the length of the data chunk, if found; otherwise, 0.
chunksAn optional list to store additional AIFF chunks found in the header.
Exceptions
FormatExceptionThrown when the input stream does not contain a valid AIFF file or when specific required chunks are not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadChunkHeader()

static AiffChunk NAudio.Wave.AiffFileReader.ReadChunkHeader ( BinaryReader br)
inlinestaticprivate

Reads the header of a chunk from the provided BinaryReader and returns an AiffChunk object.

Parameters
brThe BinaryReader used to read the chunk header.
Returns
An AiffChunk object representing the read chunk header.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadChunkName()

static string NAudio.Wave.AiffFileReader.ReadChunkName ( BinaryReader br)
inlinestaticprivate

Reads a chunk name from the provided BinaryReader and returns it as a string.

Parameters
brThe BinaryReader from which to read the chunk name.
Returns
A string representing the chunk name read from the BinaryReader.
Here is the caller graph for this function:

Member Data Documentation

◆ chunks

readonly List<AiffChunk> NAudio.Wave.AiffFileReader.chunks = new List<AiffChunk>()
private

◆ dataChunkLength

readonly int NAudio.Wave.AiffFileReader.dataChunkLength
private

◆ dataPosition

readonly long NAudio.Wave.AiffFileReader.dataPosition
private

◆ lockObject

readonly object NAudio.Wave.AiffFileReader.lockObject = new object()
private

◆ ownInput

readonly bool NAudio.Wave.AiffFileReader.ownInput
private

◆ waveFormat

readonly WaveFormat NAudio.Wave.AiffFileReader.waveFormat
private

◆ waveStream

Stream NAudio.Wave.AiffFileReader.waveStream
private

Property Documentation

◆ Length

override long NAudio.Wave.AiffFileReader.Length
get

WaveStream.WaveFormat

◆ Position

override long NAudio.Wave.AiffFileReader.Position
getset

Position in the AIFF file Stream.Position

◆ SampleCount

long NAudio.Wave.AiffFileReader.SampleCount
get

Number of Samples (if possible to calculate)

◆ WaveFormat

override WaveFormat NAudio.Wave.AiffFileReader.WaveFormat
get

WaveStream.WaveFormat

Implements NAudio.Wave.IWaveProvider.


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