本文整理汇总了C#中ISampleProvider.Read方法的典型用法代码示例。如果您正苦于以下问题:C# ISampleProvider.Read方法的具体用法?C# ISampleProvider.Read怎么用?C# ISampleProvider.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISampleProvider
的用法示例。
在下文中一共展示了ISampleProvider.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: Read
public void Read(ISampleProvider waveSampleProvider, FFTCalculated FFTCalculated)
{
float[] dummyFftArray = new float[fftBufferLength];
var dummyFftArrayLength = waveSampleProvider.Read(dummyFftArray, 0, fftBufferLength);
for (int i = 0; i < dummyFftArrayLength; i += channels) {
fftBuffer[fftBufferCurPossition].X = (float)(dummyFftArray[i] * FastFourierTransform.HammingWindow(fftBufferCurPossition, fftBufferLength));
fftBuffer[fftBufferCurPossition].Y = 0;
fftBufferCurPossition++;
if (fftBufferCurPossition >= fftBufferLength) {
fftBufferCurPossition = 0;
// 1024 = 2^10
FastFourierTransform.FFT(true, m, fftBuffer);
FFTCalculated(fftBuffer);
}
}
}