本文整理汇总了C#中ISampleProvider类的典型用法代码示例。如果您正苦于以下问题:C# ISampleProvider类的具体用法?C# ISampleProvider怎么用?C# ISampleProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISampleProvider类属于命名空间,在下文中一共展示了ISampleProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AudioStreamModifier
public AudioStreamModifier(ISampleProvider sample, double rateMult, int pitchDelta)
{
_sample = sample;
WaveFormat = _sample.WaveFormat;
_soundTouch = new SoundTouch<float, double>();
channelCount = sample.WaveFormat.Channels;
_soundTouch.SetSampleRate(sample.WaveFormat.SampleRate);
_soundTouch.SetChannels(channelCount);
rateMult = (rateMult - 1) * 100;
_soundTouch.SetTempoChange(rateMult);
_soundTouch.SetPitchSemiTones(pitchDelta*0.25f);
_soundTouch.SetRateChange(1.0f);
_soundTouch.SetSetting(SettingId.UseQuickseek, 1);
_soundTouch.SetSetting(SettingId.UseAntiAliasFilter, 1);
_soundTouch.SetSetting(SettingId.SequenceDurationMs, 40);
_soundTouch.SetSetting(SettingId.SeekwindowDurationMs, 15);
_soundTouch.SetSetting(SettingId.OverlapDurationMs, 8);
sourceReadBuffer = new float[(WaveFormat.SampleRate * channelCount * readDurationMilliseconds) / 1000];
soundTouchReadBuffer = new float[sourceReadBuffer.Length * 10]; // support down to 0.1 speed
}
示例2: AutoDisposeSampleProvider
public AutoDisposeSampleProvider(ISampleProvider provider,
IEnumerable<IDisposable> disposables)
{
this._provider = provider;
this._disposables = new CompositeDisposable(disposables);
this.WaveFormat = provider.WaveFormat;
}
示例3: EnvelopeSampleProvider
public EnvelopeSampleProvider(ISampleProvider source, List<ExpPoint> envelope, double skipOver)
{
this.source = source;
foreach (var pt in envelope) this.envelope.Add(pt.Clone());
int skipOverSamples = (int)(skipOver * WaveFormat.SampleRate / 1000);
ConvertEnvelope(skipOverSamples);
}
示例4: AddMixerInput
/// <summary>
/// Adds a new mixer input
/// </summary>
/// <param name="mixerInput">Mixer input</param>
public void AddMixerInput(ISampleProvider mixerInput)
{
// we'll just call the lock around add since we are protecting against an AddMixerInput at
// the same time as a Read, rather than two AddMixerInput calls at the same time
lock (sources)
{
if (this.sources.Count >= maxInputs)
{
throw new InvalidOperationException("Too many mixer inputs");
}
this.sources.Add(mixerInput);
}
if (this.waveFormat == null)
{
this.waveFormat = mixerInput.WaveFormat;
}
else
{
if (this.WaveFormat.SampleRate != mixerInput.WaveFormat.SampleRate ||
this.WaveFormat.Channels != mixerInput.WaveFormat.Channels)
{
throw new ArgumentException("All mixer inputs must have the same WaveFormat");
}
}
}
示例5: SpectrumProvider
// Constructor, sets the {@link Decoder}, the sample window size and the
// hop size for the spectra returned. Say the sample window size is 1024
// samples. To get an overlapp of 50% you specify a hop size of 512 samples,
// for 25% overlap you specify a hopsize of 256 and so on. Hop sizes are of
// course not limited to powers of 2.
//
// @param decoder The decoder to get the samples from.
// @param sampleWindowSize The sample window size.
// @param hopSize The hop size.
// @param useHamming Wheter to use hamming smoothing or not.
public SpectrumProvider(ISampleProvider decoder, int sampleWindowSize, int hopSize, bool useHamming)
{
if(decoder == null)
throw new ArgumentException("Decoder must be != null");
if(sampleWindowSize <= 0)
throw new ArgumentException("Sample window size must be > 0");
if(hopSize <= 0)
throw new ArgumentException("Hop size must be > 0");
if(sampleWindowSize < hopSize)
throw new ArgumentException("Hop size must be <= sampleSize");
this.decoder = decoder;
this.samples = new float[sampleWindowSize];
this.nextSamples = new float[sampleWindowSize];
this.tempSamples = new float[sampleWindowSize];
this.hopSize = hopSize;
fft = new FFT(sampleWindowSize, 44100);
// calculate averages based on a miminum octave width of 22 Hz
// split each octave into three bands
// this should result in 30 averages
//fft.LogAverages(22, 3);
if(useHamming)
fft.Window(FFT.HAMMING);
decoder.Read(samples, 0, samples.Length);
decoder.Read(nextSamples, 0, nextSamples.Length);
}
示例6: RemoveMixerInput
/// <summary>
/// Removes a mixer input
/// </summary>
/// <param name="mixerInput">Mixer input to remove</param>
public void RemoveMixerInput(ISampleProvider mixerInput)
{
lock (sources)
{
this.sources.Remove(mixerInput);
}
}
示例7: SampleToWaveProvider
/// <summary>
/// Initializes a new instance of the WaveProviderFloatToWaveProvider class
/// </summary>
/// <param name="source">Source wave provider</param>
public SampleToWaveProvider(ISampleProvider source)
{
if (source.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat)
{
throw new ArgumentException("Must be already floating point");
}
this.source = source;
}
示例8: MeteringSampleProvider
/// <summary>
/// Initialises a new instance of MeteringSampleProvider
/// </summary>
/// <param name="source">source sampler provider</param>
/// <param name="samplesPerNotification">Number of samples between notifications</param>
public MeteringSampleProvider(ISampleProvider source, int samplesPerNotification)
{
this.source = source;
this.channels = source.WaveFormat.Channels;
this.maxSamples = new float[channels];
this.SamplesPerNotification = samplesPerNotification;
this.args = new StreamVolumeEventArgs() { MaxSampleValues = this.maxSamples }; // create objects up front giving GC little to do
}
示例9: BalanceSampleProvider
/// <summary>
/// Initializes a new instance of BalanceSampleProvider
/// </summary>
/// <param name="source">Source Sample Provider</param>
public BalanceSampleProvider(ISampleProvider source)
{
if (source.WaveFormat.Channels != 2)
throw new InvalidOperationException("Input wave format must be stereo!");
_source = source;
LeftVolume = 1.0f;
RightVolume = 1.0f;
}
示例10: AddSource
public void AddSource(ISampleProvider source, TimeSpan delayBy)
{
ISampleProvider _source;
if (source.WaveFormat.Channels == 1) _source = new MonoToStereoSampleProvider(source);
else if (source.WaveFormat.Channels == 2) _source = source;
else return;
mix.AddMixerInput(new OffsetSampleProvider(_source) { DelayBy = delayBy });
}
示例11: FilteredSampleProvider
public const float StandardBufferSizeSeconds = 0.05f; // 1/20 second buffer
/// <summary>
/// Constructor
/// </summary>
/// <param name="centreFrequency">For BiQuad filters</param>
/// <param name="q">For BiQuad filters</param>
public FilteredSampleProvider(ISampleProvider sourceProvider, float centreFrequency, float q) {
this.sourceProvider = sourceProvider;
channels = WaveFormat.Channels;
StandardBufferSize = (int)WaveFormat.SecondsToSamples(StandardBufferSizeSeconds);
filters = new BiQuadFilter[channels];
for (int n = 0; n < channels; n++) {
filters[n] = BiQuadFilter.BandPassFilterConstantPeakGain(WaveFormat.SampleRate, centreFrequency, q);
}
}
示例12: Equalizer
public Equalizer(ISampleProvider sourceProvider, EqualizerBand[] bands)
{
this.sourceProvider = sourceProvider;
this.bands = bands;
channels = sourceProvider.WaveFormat.Channels;
bandCount = bands.Length;
filters = new BiQuadFilter[channels, bands.Length];
CreateFilters();
}
示例13: MonoToStereoSampleProvider
/// <summary>
/// Initializes a new instance of MonoToStereoSampleProvider
/// </summary>
/// <param name="source">Source sample provider</param>
public MonoToStereoSampleProvider(ISampleProvider source)
{
if (source.WaveFormat.Channels != 1)
{
throw new ArgumentException("Source must be mono");
}
this.source = source;
this.waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(source.WaveFormat.SampleRate, 2);
}
示例14: PanningSampleProvider
/// <summary>
/// Initialises a new instance of the PanningSampleProvider
/// </summary>
/// <param name="source">Source sample provider, must be mono</param>
public PanningSampleProvider(ISampleProvider source)
{
if (source.WaveFormat.Channels != 1)
{
throw new ArgumentException("Source sample provider must be mono");
}
this.source = source;
this.waveFormat = WaveFormat.CreateIeeeFloatWaveFormat(source.WaveFormat.SampleRate, 2);
this.panStrategy = new SinPanStrategy();
}
示例15: Equalizer
public Equalizer(ISampleProvider sourceProvider, ObservableCollection<IEqualizerBand> bands)
{
_sourceProvider = sourceProvider;
_bands = bands;
_channels = sourceProvider.WaveFormat.Channels;
_lockObj = new object();
foreach (IEqualizerBand band in _bands) band.PropertyChanged += EqualizerBandPropertyChanged;
_bands.CollectionChanged += BandsOnCollectionChanged;
_filters = new List<BiQuadFilter[]>();
CreateFilters();
}