Class SmbPitchShiftingSampleProvider
- Namespace
- NAudio.Wave.SampleProviders
- Assembly
- NAudio.Core.dll
Author: Freefall Date: 05.08.16 Based on: the port of Stephan M. Bernsee“s pitch shifting class Port site: https://sites.google.com/site/mikescoderama/pitch-shifting Test application and github site: https://github.com/Freefall63/NAudio-Pitchshifter
NOTE: I strongly advice to add a Limiter for post-processing. For my needs the FastAttackCompressor1175 provides acceptable results: https://github.com/Jiyuu/SkypeFX/blob/master/JSNet/FastAttackCompressor1175.cs
UPDATE: Added a simple Limiter based on the pydirac implementation. https://github.com/echonest/remix/blob/master/external/pydirac225/source/Dirac_LE.cpp
public class SmbPitchShiftingSampleProvider : ISampleProvider
- Inheritance
-
SmbPitchShiftingSampleProvider
- Implements
- Inherited Members
- Extension Methods
Constructors
SmbPitchShiftingSampleProvider(ISampleProvider)
Creates a new SMB Pitch Shifting Sample Provider with default settings
public SmbPitchShiftingSampleProvider(ISampleProvider sourceProvider)
Parameters
sourceProviderISampleProviderSource provider
SmbPitchShiftingSampleProvider(ISampleProvider, int, long, float)
Creates a new SMB Pitch Shifting Sample Provider with custom settings
public SmbPitchShiftingSampleProvider(ISampleProvider sourceProvider, int fftSize, long osamp, float initialPitch)
Parameters
sourceProviderISampleProviderSource provider
fftSizeintFFT Size (any power of two <= 4096: 4096, 2048, 1024, 512, ...)
osamplongOversampling (number of overlapping windows)
initialPitchfloatInitial pitch (0.5f = octave down, 1.0f = normal, 2.0f = octave up)
Properties
Latency
The latency (group delay) introduced by the underlying STFT phase vocoder, expressed as a TimeSpan.
public TimeSpan Latency { get; }
Property Value
LatencySamples
The latency (group delay) introduced by the underlying STFT phase vocoder, expressed as an interleaved sample count (latency per channel multiplied by the channel count). This is the value to use for SkipOverSamples when realigning pitch-shifted audio with unshifted audio.
public int LatencySamples { get; }
Property Value
LatencySamplesPerChannel
The latency (group delay) introduced by the underlying STFT phase vocoder, expressed
as a number of samples per channel. The shifted output is delayed by this many samples
relative to the input, and the equivalent number of samples is lost from the tail when
the source ends. The value is fftSize - fftSize / osamp and depends only on the
FFT size and oversampling factor passed to the constructor (not on the pitch factor).
public int LatencySamplesPerChannel { get; }
Property Value
Remarks
Use this to time-align pitch-shifted material with unshifted material, e.g. by skipping this many samples per channel from the start of the shifted output (see LatencySamples for the interleaved count to pass to an OffsetSampleProvider).
PitchFactor
Pitch Factor (0.5f = octave down, 1.0f = normal, 2.0f = octave up)
public float PitchFactor { get; set; }
Property Value
WaveFormat
WaveFormat
public WaveFormat WaveFormat { get; }
Property Value
Methods
Read(Span<float>)
Read from this sample provider
public int Read(Span<float> buffer)