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

WaveStream that converts 32 bit audio back down to 16 bit, clipping if necessary. More...

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

Public Member Functions

 Wave32To16Stream (WaveStream sourceStream)
 Creates a new Wave32To16Stream.
 
override int Read (byte[] destBuffer, int offset, int numBytes)
 Reads data from the source stream, converts it to 16-bit and writes it to the destination buffer.
 
- 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.
 

Protected Member Functions

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

Properties

float Volume [get, set]
 Sets the volume for this stream. 1.0f is full scale.
 
override int BlockAlign [get]
 WaveStream.BlockAlign
 
override long Length [get]
 Returns the stream length.
 
override long Position [get, set]
 Gets or sets the current position in the stream.
 
override WaveFormat WaveFormat [get]
 WaveStream.WaveFormat
 
bool Clip [get, set]
 Clip indicator. Can be reset.
 
- 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

Private Member Functions

unsafe void Convert32To16 (byte[] destBuffer, int offset, byte[] source, int bytesRead)
 Converts 32-bit audio samples to 16-bit audio samples and writes the result to the destination buffer.
 

Private Attributes

WaveStream sourceStream
 
readonly WaveFormat waveFormat
 
readonly long length
 
long position
 
bool clip
 
float volume
 
readonly object lockObject = new object()
 
byte[] sourceBuffer
 The Read method reuses the same buffer to prevent unnecessary allocations.
 

Detailed Description

WaveStream that converts 32 bit audio back down to 16 bit, clipping if necessary.

Constructor & Destructor Documentation

◆ Wave32To16Stream()

NAudio.Wave.Wave32To16Stream.Wave32To16Stream ( WaveStream sourceStream)
inline

Creates a new Wave32To16Stream.

Parameters
sourceStreamthe source stream

Member Function Documentation

◆ Convert32To16()

unsafe void NAudio.Wave.Wave32To16Stream.Convert32To16 ( byte[] destBuffer,
int offset,
byte[] source,
int bytesRead )
inlineprivate

Converts 32-bit audio samples to 16-bit audio samples and writes the result to the destination buffer.

Parameters
destBufferThe destination buffer to write the 16-bit audio samples to.
offsetThe offset in the destination buffer to start writing the samples.
sourceThe source buffer containing the 32-bit audio samples.
bytesReadThe number of bytes read from the source buffer.

This method converts the 32-bit audio samples in the source buffer to 16-bit audio samples and writes the result to the destination buffer. It also applies volume scaling and handles clipping if the sample value exceeds the range of a 16-bit integer. The method uses unsafe code to work with pointers for better performance.

Here is the caller graph for this function:

◆ Dispose()

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

Releases the unmanaged resources used by the ClassName 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 ClassName and optionally releases the managed resources. If disposing is true, this method releases all resources held by any managed objects that this ClassName references. This method is called by the public Dispose() method and the Finalize method.

◆ Read()

override int NAudio.Wave.Wave32To16Stream.Read ( byte[] destBuffer,
int offset,
int numBytes )
inline

Reads data from the source stream, converts it to 16-bit and writes it to the destination buffer.

Parameters
destBufferThe destination buffer where the converted data will be written.
offsetThe zero-based byte offset in destBuffer at which to begin storing the data.
numBytesThe maximum number of bytes to read from the source stream.
Returns
The actual number of 16-bit words read into destBuffer .
Exceptions
System.IO.IOExceptionAn I/O error occurs while reading from the source stream.

Implements NAudio.Wave.IWaveProvider.

Here is the call graph for this function:

Member Data Documentation

◆ clip

bool NAudio.Wave.Wave32To16Stream.clip
private

◆ length

readonly long NAudio.Wave.Wave32To16Stream.length
private

◆ lockObject

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

◆ position

long NAudio.Wave.Wave32To16Stream.position
private

◆ sourceBuffer

byte [] NAudio.Wave.Wave32To16Stream.sourceBuffer
private

The Read method reuses the same buffer to prevent unnecessary allocations.

◆ sourceStream

WaveStream NAudio.Wave.Wave32To16Stream.sourceStream
private

◆ volume

float NAudio.Wave.Wave32To16Stream.volume
private

◆ waveFormat

readonly WaveFormat NAudio.Wave.Wave32To16Stream.waveFormat
private

Property Documentation

◆ BlockAlign

override int NAudio.Wave.Wave32To16Stream.BlockAlign
get

WaveStream.BlockAlign

◆ Clip

bool NAudio.Wave.Wave32To16Stream.Clip
getset

Clip indicator. Can be reset.

◆ Length

override long NAudio.Wave.Wave32To16Stream.Length
get

Returns the stream length.

◆ Position

override long NAudio.Wave.Wave32To16Stream.Position
getset

Gets or sets the current position in the stream.

◆ Volume

float NAudio.Wave.Wave32To16Stream.Volume
getset

Sets the volume for this stream. 1.0f is full scale.

◆ WaveFormat

override WaveFormat NAudio.Wave.Wave32To16Stream.WaveFormat
get

WaveStream.WaveFormat

Implements NAudio.Wave.IWaveProvider.


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