v1 Providers - Axwabo/SecretLabNAudio GitHub Wiki
Providers
[!CAUTION] This page is for v1 of SecretLabNAudio. v2 guide
SecretLabNAudio.Core includes some ISampleProvider classes for convenience.
LoopingWaveProvider
Loops the given WaveStream
BufferedSampleProvider
Uses a PlaybackBuffer and reads as much data as possible into the buffer when Read is called.
PlaybackBufferSampleProvider
Exposes methods to read & write from a PlaybackBuffer
RawSourceSampleProvider
Reads data from a float array. This array is stored in a private field, but the caller may modify it if they have a reference to the array passed to the constructor.
The Copy method creates a new RawSourceSampleProvider that references the original array.
This way, different providers can seek to different positions without reallocating the entire array.
LoopingRawSampleProvider
Loops the given RawSourceSampleProvider
SampleProviderQueue
Exposes methods to enqueue & dequeue providers from a queue, and reads from them sequentially.
From NAudio
Some important sample providers contained in NAudio.Core are:
MixingSampleProvider- combines multiple inputs into oneConcatenatingSampleProvider- sequentially plays the given providersVolumeSampleProvider- sets the volumeOffsetSampleProvider- has multiple properties:DelayBy- silence to insert before playing the sourceSkipOver- time to discard from the beginning of the sourceTake- limits the maximum samples to read from the sourceLeadOut- time of appended silence at the end
Extension Methods
NAudio
ToSampleProvider(IWaveProvider)FollowedBy(ISampleProvider, ISampleProvider)- concats two providers
SecretLabNAudio
-
ToPlayerCompatible(ISampleProvider)- mixes down and resamples forAudioPlayercompatibility (if required) -
MixWith(ISampleProvider, ISampleProvider)- mixes two inputs. The first input is returned if it's aMixingSampleProvider- a new mixer is created otherwise -
Buffer(ISampleProvider, double)- creates aBufferedSampleProvider -
Queue(ISampleProvider, ISampleProvider)- uses the first or creates a newSampleProviderQueue -
Volume(ISampleProvider, float)- uses the original or creates a newVolumeSampleProvider -
ToPlayerCompatible(IWaveProvider)- converts to a sample provider and callsToPlayerCompatible -
Loop(WaveStream)- creates aLoopingWaveProvider -
ReadPlayerCompatibleSamples(WaveStream, bool)- reads the stream into a player-compatibleRawSourceSampleProvider -
ReadSamples(WaveStream, bool)- reads the samples into aRawSourceSampleProviderwith the original format