当前位置: 首页>>代码示例>>C#>>正文


C# ISampleProvider.Read方法代码示例

本文整理汇总了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);
		}
开发者ID:LuckyLuik,项目名称:AudioVSTToolbox,代码行数:42,代码来源:SpectrumProvider.cs

示例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);
                }
            }
        }
开发者ID:danielmititelu,项目名称:Piano,代码行数:17,代码来源:SampleAggregator.cs


注:本文中的ISampleProvider.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。