public float[] ReadMonoFromSource(string source, int sampleRate, double secondsToRead, double startAtSecond)
 {
     using (var stream = naudioFactory.GetStream(source))
     {
         SeekToSecondInCaseIfRequired(startAtSecond, stream);
         using (var resampler = naudioFactory.GetResampler(stream, sampleRate, Mono))
         {
             var waveToSampleProvider = new WaveToSampleProvider(resampler);
             return samplesAggregator.ReadSamplesFromSource(new NAudioSamplesProviderAdapter(waveToSampleProvider), secondsToRead, sampleRate);
         }
     }
 }
Ejemplo n.º 2
0
 private float[] ReadMonoFromSource(string pathToSource, int sampleRate, int secondsToRead, int startAtSecond, Func<SampleProviderConverterBase, ISamplesProvider> getSamplesProvider)
 {
     using (var reader = new MediaFoundationReader(pathToSource))
     {
         SeekToSecondInCaseIfRequired(startAtSecond, reader);
         var ieeeFloatWaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, 1);
         using (var resampler = new MediaFoundationResampler(reader, ieeeFloatWaveFormat))
         {
             var waveToSampleProvider = new WaveToSampleProvider(resampler);
             return samplesAggregator.ReadSamplesFromSource(getSamplesProvider(waveToSampleProvider), secondsToRead, sampleRate);
         }
     }
 }