private void RepositionTest() { if (String.IsNullOrEmpty(InputFile)) { MessageBox.Show("Select a file first"); return; } var saveFile = SelectSaveFile("reposition"); if (saveFile == null) { return; } // do the resample using (var reader = new SharpMediaFoundationReader(InputFile)) using (var resampler = new SharpMediaFoundationResampler(reader, CreateOutputFormat(reader.WaveFormat))) { CreateRepositionTestFile(saveFile, resampler, () => { // tell the reader to go back to the start (we're trusting it not to have leftovers) reader.Position = 0; // tell the resampler that we have repositioned and it should drain all its buffers resampler.Reposition(); }); } // use the following to test that just the reader is doing clean repositions: /* * using (var reader = new MediaFoundationReader(InputFile)) * { * CreateRepositionTestFile(saveFile, reader, () => * { * // tell the reader to go back to the start (we're trusting it not to have leftovers) * reader.Position = 0; * }); * }*/ MessageBox.Show("Resample complete"); }
private void Resample() { if (String.IsNullOrEmpty(InputFile)) { MessageBox.Show("Select a file first"); return; } var saveFile = SelectSaveFile("resampled"); if (saveFile == null) { return; } // do the resample using (var reader = new SharpMediaFoundationReader(InputFile)) using (var resampler = new SharpMediaFoundationResampler(reader, CreateOutputFormat(reader.WaveFormat))) { WaveFileWriter.CreateWaveFile(saveFile, resampler); } MessageBox.Show("Resample complete"); }