-
Notifications
You must be signed in to change notification settings - Fork 0
Providers
This is a minimal interface that allows essentially limitless ways to create or process samples.
It defines a wave format and an int Read(float[] buffer, int offset, int count) method.
Tip
See also: digital audio basics
When Read is called, it tries to fill the buffer with the amount of requested samples.
The method returns the read sample count, which can signal that the provider ended by returning 0 or an amount less than requested (e.g. there isn't enough data available).
SecretLabNAudio v2 introduced audio processors,
which are an extension of the ISampleProvider and IDisposable interface.
It's recommended to use audio processors when possible to avoid resource
management issues.
An interface that combines ISampleProvider and IDisposable
Some built-in implementations are: Mixer AudioQueue StreamAudioProcessor
When a class implementing this interface is disposed, it should release
all resources used by it. Use the ProcessorLayer record to define
"child" processors (similar to Mixer)
that specify whether to dispose of the specific resource.
Tip
See also: streaming music
Use the ProcessorChain to stack "effects" (e.g. pitch, speed, etc.) while preserving access to the original source.
The original sources are exposed to let callers seek, or change the loop property via extension methods. This also lets consumers inspect the chain and see each step.
-
StreamAudioProcessorencapsulates aWaveStream - Mixer combines the output of multiple sample providers, as if they were playing at once
- AudioQueue plays the next provider when the current one ends
- ProcessorChain allows for different layers to be added to a provider (volume, pitch, etc.)
-
SampleProviderWrapperencapsulates anISampleProviderand an optionalIDiposable
Tip
You can leverage the below providers by using extension methods on a ProcessorChain
Some noteworthy NAudio providers are:
-
WdlResamplingSampleProviderchanges the sample rate while retaining quality -
StereoToMonoSampleProvidermixes the channels down to one VolumeSampleProvider-
OffsetSampleProviderhas multiple properties:-
DelayBy- silence to insert before playing the source -
SkipOver- time to discard from the beginning of the source -
Take- limits the maximum samples to read from the source -
LeadOut- time of appended silence at the end
-
-
SmbPitchShiftingSampleProviderpitch-shifts the input
- π Home
- πΌ Digital Audio Basics
- π Examples
- π¦ Supported Formats
- β¬οΈ Migrating from v1
- π AudioPlayer
- πΎ Short Clips
- πΏ Streaming From Disk
- ποΈ Speaker Groups
- π Sample Providers
- β»οΈ Pooling
- π¨ SendEngines
- π§ Personalizing Speakers
- π Monitoring Output
- βοΈ AudioQueue
- πΆ Mixer
- ποΈοΈ ProcessorChain
- π§° Intro to FFmpeg
- π© Installation
- ποΈ FFmpegArguments
- πͺ Adding Short Clips
- π FFmpeg Audio Processors
- ποΈ Caches
Caution
v1 will be out of support soon.