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

Useful extension methods to make switching between WaveAndSampleProvider easier. More...

Collaboration diagram for NAudio.Wave.WaveExtensionMethods:

Static Public Member Functions

static ISampleProvider ToSampleProvider (this IWaveProvider waveProvider)
 Converts the specified waveProvider into a sample provider.
 
static void Init (this IWavePlayer wavePlayer, ISampleProvider sampleProvider, bool convertTo16Bit=false)
 Initializes the specified wave player with the given sample provider and optional 16-bit conversion.
 
static WaveFormat AsStandardWaveFormat (this WaveFormat waveFormat)
 Converts the input WaveFormat to standard WaveFormat and returns the result.
 
static IWaveProvider ToWaveProvider (this ISampleProvider sampleProvider)
 Converts the given ISampleProvider to an IWaveProvider.
 
static IWaveProvider ToWaveProvider16 (this ISampleProvider sampleProvider)
 Converts the given ISampleProvider to a 16-bit IWaveProvider.
 
static ISampleProvider FollowedBy (this ISampleProvider sampleProvider, ISampleProvider next)
 Appends a silence duration to the input sample provider, followed by another sample provider.
 
static ISampleProvider FollowedBy (this ISampleProvider sampleProvider, TimeSpan silenceDuration, ISampleProvider next)
 Concatenates one Sample Provider on the end of another with silence inserted.
 
static ISampleProvider Skip (this ISampleProvider sampleProvider, TimeSpan skipDuration)
 Skips the specified duration of audio samples from the beginning of the input sample provider.
 
static ISampleProvider Take (this ISampleProvider sampleProvider, TimeSpan takeDuration)
 Takes a specified duration of audio from the input sample provider.
 
static ISampleProvider ToMono (this ISampleProvider sourceProvider, float leftVol=0.5f, float rightVol=0.5f)
 Converts a stereo audio sample provider to mono with specified left and right volume levels.
 
static ISampleProvider ToStereo (this ISampleProvider sourceProvider, float leftVol=1.0f, float rightVol=1.0f)
 Converts a mono audio sample provider to a stereo audio sample provider with specified left and right volume levels.
 

Detailed Description

Useful extension methods to make switching between WaveAndSampleProvider easier.

Member Function Documentation

◆ AsStandardWaveFormat()

static WaveFormat NAudio.Wave.WaveExtensionMethods.AsStandardWaveFormat ( this WaveFormat waveFormat)
inlinestatic

Converts the input WaveFormat to standard WaveFormat and returns the result.

Parameters
waveFormatThe WaveFormat to be converted.
Returns
The standard WaveFormat if the input is of type WaveFormatExtensible; otherwise, returns the input WaveFormat.

This method checks if the input waveFormat is of type WaveFormatExtensible. If it is, it calls the ToStandardWaveFormat method to convert it to standard WaveFormat and returns the result. If the input is not of type WaveFormatExtensible, it returns the input WaveFormat as is.

Here is the call graph for this function:

◆ FollowedBy() [1/2]

static ISampleProvider NAudio.Wave.WaveExtensionMethods.FollowedBy ( this ISampleProvider sampleProvider,
ISampleProvider next )
inlinestatic

Appends a silence duration to the input sample provider, followed by another sample provider.

Parameters
sampleProviderThe input sample provider.
silenceDurationThe duration of silence to be appended.
nextThe sample provider to be appended after the silence duration.
Returns
A new sample provider with the silence duration followed by the next sample provider.

This method appends a specified duration of silence to the input sample provider, followed by another sample provider. The resulting sample provider contains the input sample provider with the specified silence duration followed by the next sample provider.

◆ FollowedBy() [2/2]

static ISampleProvider NAudio.Wave.WaveExtensionMethods.FollowedBy ( this ISampleProvider sampleProvider,
TimeSpan silenceDuration,
ISampleProvider next )
inlinestatic

Concatenates one Sample Provider on the end of another with silence inserted.

Parameters
sampleProviderThe sample provider to play first
silenceDurationSilence duration to insert between the two
nextThe sample provider to play next
Returns
A single sample provider

◆ Init()

static void NAudio.Wave.WaveExtensionMethods.Init ( this IWavePlayer wavePlayer,
ISampleProvider sampleProvider,
bool convertTo16Bit = false )
inlinestatic

Initializes the specified wave player with the given sample provider and optional 16-bit conversion.

Parameters
wavePlayerThe wave player to be initialized.
sampleProviderThe sample provider to be used for audio playback.
convertTo16BitOptional parameter to indicate whether to convert the samples to 16-bit format. Default is false.

This method initializes the specified wavePlayer with the provided sampleProvider for audio playback. If convertTo16Bit is true, the sample provider is converted to 16-bit format using SampleToWaveProvider16; otherwise, it uses SampleToWaveProvider.

Here is the call graph for this function:

◆ Skip()

static ISampleProvider NAudio.Wave.WaveExtensionMethods.Skip ( this ISampleProvider sampleProvider,
TimeSpan skipDuration )
inlinestatic

Skips the specified duration of audio samples from the beginning of the input sample provider.

Parameters
sampleProviderThe input sample provider.
skipDurationThe duration of audio samples to skip.
Returns
A new sample provider with the specified duration of audio samples skipped from the beginning.

This method creates a new sample provider that skips the specified duration of audio samples from the beginning of the input sample provider. The original input sample provider remains unmodified.

◆ Take()

static ISampleProvider NAudio.Wave.WaveExtensionMethods.Take ( this ISampleProvider sampleProvider,
TimeSpan takeDuration )
inlinestatic

Takes a specified duration of audio from the input sample provider.

Parameters
sampleProviderThe input sample provider.
takeDurationThe duration of audio to be taken from the input sample provider.
Returns
A new sample provider that provides audio for the specified duration from the input sample provider.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToMono()

static ISampleProvider NAudio.Wave.WaveExtensionMethods.ToMono ( this ISampleProvider sourceProvider,
float leftVol = 0::5f,
float rightVol = 0::5f )
inlinestatic

Converts a stereo audio sample provider to mono with specified left and right volume levels.

Parameters
sourceProviderThe stereo audio sample provider to be converted to mono.
leftVolThe volume level for the left channel (default is 0.5).
rightVolThe volume level for the right channel (default is 0.5).
Returns
A mono audio sample provider with the specified left and right volume levels.

This method checks if the input audio sample provider has stereo channels. If it does, it converts it to mono by creating a new instance of the StereoToMonoSampleProvider class with the specified left and right volume levels. If the input audio sample provider already has only one channel, it returns the original provider without any modifications.

◆ ToSampleProvider()

static ISampleProvider NAudio.Wave.WaveExtensionMethods.ToSampleProvider ( this IWaveProvider waveProvider)
inlinestatic

Converts the specified waveProvider into a sample provider.

Parameters
waveProviderThe wave provider to be converted.
Returns
A sample provider representing the converted waveProvider .
Here is the call graph for this function:

◆ ToStereo()

static ISampleProvider NAudio.Wave.WaveExtensionMethods.ToStereo ( this ISampleProvider sourceProvider,
float leftVol = 1::0f,
float rightVol = 1::0f )
inlinestatic

Converts a mono audio sample provider to a stereo audio sample provider with specified left and right volume levels.

Parameters
sourceProviderThe mono audio sample provider to be converted to stereo.
leftVolThe volume level for the left channel (default is 1.0).
rightVolThe volume level for the right channel (default is 1.0).
Returns
A stereo audio sample provider with the specified left and right volume levels.

◆ ToWaveProvider()

static IWaveProvider NAudio.Wave.WaveExtensionMethods.ToWaveProvider ( this ISampleProvider sampleProvider)
inlinestatic

Converts the given ISampleProvider to an IWaveProvider.

Parameters
sampleProviderThe ISampleProvider to be converted.
Returns
An IWaveProvider representing the converted sample provider.

◆ ToWaveProvider16()

static IWaveProvider NAudio.Wave.WaveExtensionMethods.ToWaveProvider16 ( this ISampleProvider sampleProvider)
inlinestatic

Converts the given ISampleProvider to a 16-bit IWaveProvider.

Parameters
sampleProviderThe input ISampleProvider to be converted.
Returns
A 16-bit IWaveProvider representing the converted sampleProvider.

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