public void IterateAudioSamples() { AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 10.0); AsfAudio asfAudio = new AsfAudio(asfStream); int requestedSampleCount = 10000; int receivedSampleCount = 0; foreach (AudioSample audioSample in asfAudio.GetSamples(requestedSampleCount)) { receivedSampleCount++; } Assert.AreEqual(requestedSampleCount, receivedSampleCount); }
public void ComputeWaveForm(UInt32 presentationTime) { try { double timeInSeconds = presentationTime; timeInSeconds /= 1000; float[] samples; using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds)) using (AsfAudio asfAudio = new AsfAudio(asfStream)) { int sampleCountForTwoSeconds = (int)(2 * asfStream.Configuration.AudioSampleRate); samples = asfAudio.GetSamples(sampleCountForTwoSeconds).Select(sample => sample.Left).ToArray(); } Dispatcher.BeginInvoke((Action)(() => DrawAudio(samples))); } catch (AsfStreamException) { } }