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

AcmStream encapsulates an Audio Compression Manager Stream used to convert audio from one format to another. More...

Inheritance diagram for NAudio.Wave.Compression.AcmStream:
Collaboration diagram for NAudio.Wave.Compression.AcmStream:

Public Member Functions

 AcmStream (WaveFormat sourceFormat, WaveFormat destFormat)
 Creates a new ACM stream to convert one format to another. Note that not all conversions can be done in one step.
 
 AcmStream (IntPtr driverId, WaveFormat sourceFormat, WaveFilter waveFilter)
 Creates a new ACM stream to convert one format to another, using a specified driver identifier and wave filter.
 
int SourceToDest (int source)
 Converts the source value to destination and returns the result.
 
int DestToSource (int dest)
 Converts the specified destination value to the source format and returns the result.
 
void Reposition ()
 Repositions the stream header.
 
int Convert (int bytesToConvert, out int sourceBytesConverted)
 Converts the specified number of bytes and returns the converted bytes count.
 
int Convert (int bytesToConvert)
 Converts the contents of the SourceBuffer into the DestinationBuffer.
 
void Dispose ()
 Releases the unmanaged resources used by the WaveFormatConverter and optionally releases the managed resources.
 

Static Public Member Functions

static WaveFormat SuggestPcmFormat (WaveFormat compressedFormat)
 Suggests a PCM format based on the given compressed format.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Frees resources associated with this ACM Stream.
 

Properties

byte[] SourceBuffer [get]
 Returns the Source Buffer. Fill this with data prior to calling convert.
 
byte[] DestBuffer [get]
 Returns the Destination buffer. This will contain the converted data after a successful call to Convert.
 

Private Member Functions

 ~AcmStream ()
 Frees resources associated with this ACM Stream.
 

Private Attributes

IntPtr streamHandle
 
IntPtr driverHandle
 
AcmStreamHeader streamHeader
 
readonly WaveFormat sourceFormat
 

Detailed Description

AcmStream encapsulates an Audio Compression Manager Stream used to convert audio from one format to another.

Constructor & Destructor Documentation

◆ AcmStream() [1/2]

NAudio.Wave.Compression.AcmStream.AcmStream ( WaveFormat sourceFormat,
WaveFormat destFormat )
inline

Creates a new ACM stream to convert one format to another. Note that not all conversions can be done in one step.

Parameters
sourceFormatThe source audio format
destFormatThe destination audio format
Here is the call graph for this function:

◆ AcmStream() [2/2]

NAudio.Wave.Compression.AcmStream.AcmStream ( IntPtr driverId,
WaveFormat sourceFormat,
WaveFilter waveFilter )
inline

Creates a new ACM stream to convert one format to another, using a specified driver identifier and wave filter.

Parameters
driverIdthe driver identifier
sourceFormatthe source format
waveFilterthe wave filter
Here is the call graph for this function:

◆ ~AcmStream()

NAudio.Wave.Compression.AcmStream.~AcmStream ( )
inlineprivate

Frees resources associated with this ACM Stream.

Here is the call graph for this function:

Member Function Documentation

◆ Convert() [1/2]

int NAudio.Wave.Compression.AcmStream.Convert ( int bytesToConvert)
inline

Converts the contents of the SourceBuffer into the DestinationBuffer.

Parameters
bytesToConvertThe number of bytes in the SourceBuffer that need to be converted
Returns
The number of converted bytes in the DestinationBuffer

◆ Convert() [2/2]

int NAudio.Wave.Compression.AcmStream.Convert ( int bytesToConvert,
out int sourceBytesConverted )
inline

Converts the specified number of bytes and returns the converted bytes count.

Parameters
bytesToConvertThe number of bytes to be converted.
Returns
The number of bytes after conversion.
Exceptions
MmExceptionThrown when the conversion does not convert all the bytes.

This method is marked as obsolete and it is recommended to call the version returning sourceBytesConverted instead. The method internally calls another overloaded method to perform the conversion and checks if the conversion was successful. If the conversion did not convert all the bytes, a MmException is thrown with the message "AcmStreamHeader.Convert didn't convert everything".

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DestToSource()

int NAudio.Wave.Compression.AcmStream.DestToSource ( int dest)
inline

Converts the specified destination value to the source format and returns the result.

Parameters
destThe destination value to be converted.
Returns
The converted value in the source format.
Exceptions
MmExceptionThrown when the acmStreamSize method fails.

If the dest parameter is 0, the method returns 0, as zero is considered an invalid parameter for acmStreamSize. The method uses the acmStreamSize method to determine the size of the buffer needed to convert the specified destination value to the source format.

Here is the call graph for this function:

◆ Dispose() [1/2]

void NAudio.Wave.Compression.AcmStream.Dispose ( )
inline

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

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Exceptions
MmExceptionThrown when an error occurs during the ACM stream close operation.

This method releases the unmanaged resources used by the WaveFormatConverter. If the disposing parameter is true, it also releases the managed resources. The method first checks if the streamHeader is not null, and if so, disposes it and sets it to null. Then, it checks if the streamHandle is not IntPtr.Zero, and if so, calls acmStreamClose to close the stream handle. If an error occurs during the acmStreamClose operation, a MmException is thrown with details of the error. Finally, it checks if the driverHandle is not IntPtr.Zero, and if so, calls acmDriverClose to close the driver handle.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose() [2/2]

virtual void NAudio.Wave.Compression.AcmStream.Dispose ( bool disposing)
inlineprotectedvirtual

Frees resources associated with this ACM Stream.

Here is the call graph for this function:

◆ Reposition()

void NAudio.Wave.Compression.AcmStream.Reposition ( )
inline

Repositions the stream header.

This method calls the Reposition method of the streamHeader object to reposition the stream header.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SourceToDest()

int NAudio.Wave.Compression.AcmStream.SourceToDest ( int source)
inline

Converts the source value to destination and returns the result.

Parameters
sourceThe value to be converted.
Returns
The converted value from source .
Exceptions
MmExceptionThrown when an error occurs during the conversion process.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SuggestPcmFormat()

static WaveFormat NAudio.Wave.Compression.AcmStream.SuggestPcmFormat ( WaveFormat compressedFormat)
inlinestatic

Suggests a PCM format based on the given compressed format.

Parameters
compressedFormatThe compressed format for which to suggest a PCM format.
Returns
A PCM format suggested based on the given compressed format.
Exceptions
MmExceptionThrown when an error occurs during the suggestion process.

This method suggests a PCM format based on the given compressed format using the acmFormatSuggest2 function from AcmInterop. It creates a PCM format with the same sample rate and channels as the compressed format, with 16-bit sample size. The suggested PCM format is returned after the suggestion process is completed.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ driverHandle

IntPtr NAudio.Wave.Compression.AcmStream.driverHandle
private

◆ sourceFormat

readonly WaveFormat NAudio.Wave.Compression.AcmStream.sourceFormat
private

◆ streamHandle

IntPtr NAudio.Wave.Compression.AcmStream.streamHandle
private

◆ streamHeader

AcmStreamHeader NAudio.Wave.Compression.AcmStream.streamHeader
private

Property Documentation

◆ DestBuffer

byte [] NAudio.Wave.Compression.AcmStream.DestBuffer
get

Returns the Destination buffer. This will contain the converted data after a successful call to Convert.

◆ SourceBuffer

byte [] NAudio.Wave.Compression.AcmStream.SourceBuffer
get

Returns the Source Buffer. Fill this with data prior to calling convert.


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