private static void commonSaveWaveFile(WaveAudio w) { string strFilename = getSaveFilename(); if (strFilename == null || strFilename == "") return; try { w.SaveWaveFile(strFilename); } catch (Exception er) { MessageBox.Show("Error when saving wave file: " + er.Message); return; } }
public void Play(WaveAudio a, bool bAsync) { m = new MemoryStream(); bw = new BinaryWriter(m); a.SaveWaveFile(bw); SoundPlayer pl = new SoundPlayer(m); pl.Stream.Position = 0; // This line is necessary if (bAsync) pl.Play(); else pl.PlaySync(); }
public void Play(WaveAudio a, bool bAsync) { m = new MemoryStream(); bw = new BinaryWriter(m); a.SaveWaveFile(bw); pl = new SoundPlayer(m); pl.Stream.Position = 0; // This line is necessary if (bAsync) { pl.Play(); } else { pl.PlaySync(); } }
static void iotests_perfile(string strFilename, int nBits, int nChannels, int nRate) { WaveAudio w01 = new WaveAudio(strFilename); asserteq(w01.getNumChannels(), nChannels); asserteq(w01.getSampleRate(), nRate, "011"); asserteqf(w01.LengthInSamples, 90725 * (nRate / 22050), 1.0, "012"); //note give 1.0 tolerance asserteqf(w01.LengthInSeconds, 4.1145124, "013"); asserteq(w01.data.Length, nChannels); asserteq(w01.data[0].Length, w01.LengthInSamples); for (int i = 0; i < nChannels; i++) asserteq(w01.data[i].Length, w01.LengthInSamples); // test converting to other rates / quality w01.SaveWaveFile("..\\..\\testout\\o_" + nRate + "_" + nBits + "_" + nRate + "_" + nChannels + ".wav", nBits); nBits = (nBits == 8) ? 16 : 8; w01.SaveWaveFile("..\\..\\testout\\ot_" + nRate + "_" + nBits + "_" + nRate + "_" + nChannels + ".wav", nBits); }