Useful extension methods to make switching between WaveAndSampleProvider easier.
More...
|
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.
|
|
Useful extension methods to make switching between WaveAndSampleProvider easier.
◆ AsStandardWaveFormat()
static WaveFormat NAudio.Wave.WaveExtensionMethods.AsStandardWaveFormat |
( |
this WaveFormat | waveFormat | ) |
|
|
inlinestatic |
Converts the input WaveFormat to standard WaveFormat and returns the result.
- Parameters
-
waveFormat | The 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.
◆ FollowedBy() [1/2]
Appends a silence duration to the input sample provider, followed by another sample provider.
- Parameters
-
sampleProvider | The input sample provider. |
silenceDuration | The duration of silence to be appended. |
next | The 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]
Concatenates one Sample Provider on the end of another with silence inserted.
- Parameters
-
sampleProvider | The sample provider to play first |
silenceDuration | Silence duration to insert between the two |
next | The 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
-
wavePlayer | The wave player to be initialized. |
sampleProvider | The sample provider to be used for audio playback. |
convertTo16Bit | Optional 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.
◆ Skip()
Skips the specified duration of audio samples from the beginning of the input sample provider.
- Parameters
-
sampleProvider | The input sample provider. |
skipDuration | The 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()
Takes a specified duration of audio from the input sample provider.
- Parameters
-
sampleProvider | The input sample provider. |
takeDuration | The 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.
◆ ToMono()
Converts a stereo audio sample provider to mono with specified left and right volume levels.
- Parameters
-
sourceProvider | The stereo audio sample provider to be converted to mono. |
leftVol | The volume level for the left channel (default is 0.5). |
rightVol | The 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()
Converts the specified waveProvider into a sample provider.
- Parameters
-
waveProvider | The wave provider to be converted. |
- Returns
- A sample provider representing the converted waveProvider .
◆ 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
-
sourceProvider | The mono audio sample provider to be converted to stereo. |
leftVol | The volume level for the left channel (default is 1.0). |
rightVol | The 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()
Converts the given ISampleProvider to an IWaveProvider.
- Parameters
-
sampleProvider | The ISampleProvider to be converted. |
- Returns
- An IWaveProvider representing the converted sample provider.
◆ ToWaveProvider16()
Converts the given ISampleProvider to a 16-bit IWaveProvider.
- Parameters
-
sampleProvider | The 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:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/Plugins/LiveMicrophone/lib/NAudio.Core/Wave/WaveExtensionMethods.cs