public virtual WaveAudio CreateWaveAudio(double fSeconds) { WaveAudio res = new WaveAudio(SampleRate, 1); int nSamples = (int) (fSeconds * res.getSampleRate()); res.data[0] = this.generate(nSamples); return res; }
public virtual WaveAudio CreateWaveAudio(double fSeconds) { WaveAudio res = new WaveAudio(SampleRate, 1); int nSamples = (int)(fSeconds * res.getSampleRate()); res.data[0] = this.generate(nSamples); return(res); }
public static void propertytests() { // these aren't the best tests. WaveAudio w1 = new WaveAudio(44100, 2); asserteq(w1.data.Length, 2, "channels"); asserteq(w1.getNumChannels(), 2, "channels"); assert(w1.data[0] != null && w1.data[1] != null, "channels"); assert(w1.data[0].Length == 1 && w1.data[1].Length == 1, "004"); asserteq(w1.getSampleRate(), 44100, "005"); WaveAudio w1m = new WaveAudio(22050, 1); asserteq(w1m.data.Length, 1, "channels"); assert(w1m.data[0] != null, "channels"); asserteq(w1m.data[0].Length, 1, "004"); asserteq(w1m.getSampleRate(), 22050, "005"); // now set some properties w1m.LengthInSamples = 100; asserteq(w1m.data[0].Length, 100); asserteqf(w1m.LengthInSeconds, 100 / (double)w1m.getSampleRate(), 0.001); }
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(mediadir + "ttout\\o_" + nRate + "_" + nBits + "_" + nRate + "_" + nChannels + ".wav", nBits); nBits = (nBits == 8) ? 16 : 8; w01.SaveWaveFile(mediadir + "ttout\\ot_" + nRate + "_" + nBits + "_" + nRate + "_" + nChannels + ".wav", nBits); }