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

Simply shifts the input stream in time, optionally clipping its start and end. (n.b. may include looping in the future) More...

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

Public Member Functions

 WaveOffsetStream (WaveStream sourceStream, TimeSpan startTime, TimeSpan sourceOffset, TimeSpan sourceLength)
 Creates a new WaveOffsetStream.
 
 WaveOffsetStream (WaveStream sourceStream)
 Creates a WaveOffsetStream with default settings (no offset or pre-delay, and whole length of source stream)
 
override int Read (byte[] destBuffer, int offset, int numBytes)
 Reads audio data from the source stream into the destination buffer, filling with silence if necessary, and returns the number of bytes read.
 
override bool HasData (int count)
 Checks if the source stream has data available.
 
- 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.
 

Protected Member Functions

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

Properties

TimeSpan StartTime [get, set]
 The length of time before which no audio will be played.
 
TimeSpan SourceOffset [get, set]
 An offset into the source stream from which to start playing.
 
TimeSpan SourceLength [get, set]
 Length of time to read from the source stream.
 
override int BlockAlign [get]
 Gets the block alignment for this WaveStream.
 
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
 
- 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 Attributes

WaveStream sourceStream
 
long audioStartPosition
 
long sourceOffsetBytes
 
long sourceLengthBytes
 
long length
 
readonly int bytesPerSample
 
long position
 
TimeSpan startTime
 
TimeSpan sourceOffset
 
TimeSpan sourceLength
 
readonly object lockObject = new object()
 

Detailed Description

Simply shifts the input stream in time, optionally clipping its start and end. (n.b. may include looping in the future)

Constructor & Destructor Documentation

◆ WaveOffsetStream() [1/2]

NAudio.Wave.WaveOffsetStream.WaveOffsetStream ( WaveStream sourceStream,
TimeSpan startTime,
TimeSpan sourceOffset,
TimeSpan sourceLength )
inline

Creates a new WaveOffsetStream.

Parameters
sourceStreamthe source stream
startTimethe time at which we should start reading from the source stream
sourceOffsetamount to trim off the front of the source stream
sourceLengthlength of time to play from source stream

◆ WaveOffsetStream() [2/2]

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

Creates a WaveOffsetStream with default settings (no offset or pre-delay, and whole length of source stream)

Parameters
sourceStreamThe source stream

Member Function Documentation

◆ Dispose()

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

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

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

This method disposes the sourceStream if it is not null and sets it to null. If disposing is false, it asserts that the WaveOffsetStream was not disposed.

◆ HasData()

override bool NAudio.Wave.WaveOffsetStream.HasData ( int count)
inlinevirtual

Checks if the source stream has data available.

Parameters
countThe number of bytes to check for availability.
Returns
True if the source stream has the specified amount of data available; otherwise, false.

This method checks if the source stream has the specified amount of data available by comparing the current position and count with the audio start position and length. If the position plus count is less than the audio start position, or if the position is greater than or equal to the length, false is returned. Otherwise, it delegates the check to the source stream's HasData method and returns its result.

Reimplemented from NAudio.Wave.WaveStream.

Here is the call graph for this function:

◆ Read()

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

Reads audio data from the source stream into the destination buffer, filling with silence if necessary, and returns the number of bytes read.

Parameters
destBufferThe destination buffer to write the audio data into.
offsetThe offset in the destination buffer at which to start writing the audio data.
numBytesThe number of bytes to read from the source stream and write into the destination buffer.
Returns
The total number of bytes read and written into the destination buffer, which is equal to numBytes .

This method fills the destination buffer with silence if the current position is before the audio start position. It then reads audio data from the source stream into the destination buffer, ensuring not to read beyond the source stream's length. Finally, it fills out any remaining space in the destination buffer with zeroes and updates the position accordingly.

Implements NAudio.Wave.IWaveProvider.

Here is the call graph for this function:

Member Data Documentation

◆ audioStartPosition

long NAudio.Wave.WaveOffsetStream.audioStartPosition
private

◆ bytesPerSample

readonly int NAudio.Wave.WaveOffsetStream.bytesPerSample
private

◆ length

long NAudio.Wave.WaveOffsetStream.length
private

◆ lockObject

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

◆ position

long NAudio.Wave.WaveOffsetStream.position
private

◆ sourceLength

TimeSpan NAudio.Wave.WaveOffsetStream.sourceLength
private

◆ sourceLengthBytes

long NAudio.Wave.WaveOffsetStream.sourceLengthBytes
private

◆ sourceOffset

TimeSpan NAudio.Wave.WaveOffsetStream.sourceOffset
private

◆ sourceOffsetBytes

long NAudio.Wave.WaveOffsetStream.sourceOffsetBytes
private

◆ sourceStream

WaveStream NAudio.Wave.WaveOffsetStream.sourceStream
private

◆ startTime

TimeSpan NAudio.Wave.WaveOffsetStream.startTime
private

Property Documentation

◆ BlockAlign

override int NAudio.Wave.WaveOffsetStream.BlockAlign
get

Gets the block alignment for this WaveStream.

◆ Length

override long NAudio.Wave.WaveOffsetStream.Length
get

Returns the stream length.

◆ Position

override long NAudio.Wave.WaveOffsetStream.Position
getset

Gets or sets the current position in the stream.

◆ SourceLength

TimeSpan NAudio.Wave.WaveOffsetStream.SourceLength
getset

Length of time to read from the source stream.

◆ SourceOffset

TimeSpan NAudio.Wave.WaveOffsetStream.SourceOffset
getset

An offset into the source stream from which to start playing.

◆ StartTime

TimeSpan NAudio.Wave.WaveOffsetStream.StartTime
getset

The length of time before which no audio will be played.

◆ WaveFormat

override WaveFormat NAudio.Wave.WaveOffsetStream.WaveFormat
get

WaveStream.WaveFormat

Implements NAudio.Wave.IWaveProvider.


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