Esempio n. 1
0
        public void TestWrite()
        {
            AudioReader reader = new AudioReader();
              AudioWriter writer = new AudioWriter();

              SoundData original = reader.ReadSoundFile("../../../data/sine.wav");
              writer.WriteSoundData(original,           "../../../data/written.wav");
              SoundData written = reader.ReadSoundFile( "../../../data/written.wav");

              Assert.AreEqual(original.Length, written.Length, "The written data " +
                      "should be of the same length as the read data.");

              IEnumerator<Int16> enumWritten = written.GetEnumerator();

              foreach (Int16 sample in original) {
            enumWritten.MoveNext();
            Assert.AreEqual(sample, enumWritten.Current,
                        "The written data should match the read data.");
              }

              Assert.IsFalse(enumWritten.MoveNext());
              enumWritten.Dispose();
        }
Esempio n. 2
0
 private void Process(SoundData data, string outputDir)
 {
     AudioWriter writer = new AudioWriter();
       string dir = NormalizeDirectory(outputDir);
       writer.WriteSoundData(data, dir + "master.wav");
       CassetteData[] cassettes = chunker.ChunkData(data);
       string[] names = new string[cassettes.Length];
       for (int i = 0; i < names.Length; ++i) {
     string name = cassettes[0].Meta.FileName;
     int adjust = 0;
     for (int j = 0; j < i; ++j) {
       if (names[j] == name) {
     if (adjust == 0) {
       name += "1";
       adjust = 1;
     } else {
       name = name.Substring(0, name.Length - 1) + (++adjust);
     }
       }
     }
     names[i] = name;
       }
       for (int i = 0; i < names.Length; ++i) {
     writer.WriteCassetteData(cassettes[i], dir + names[i] + ".wav");
       }
 }