Ejemplo n.º 1
0
 public void TestPipeline()
 {
     AudioReader reader = new AudioReader();
       SoundData data = reader.ReadSoundFile("../../../Data/file-system.wav");
       CassetteData[] cassettes = new DataChunker().ChunkData(data);
       Assert.AreEqual(1, cassettes.Length);
       CassetteData cassette = cassettes[0];
       AudioWriter writer = new AudioWriter();
       writer.WriteCassetteData(cassette, "../../../Data/processed.wav");
       data = reader.ReadSoundFile("../../../Data/processed.wav");
       cassettes = new DataChunker().ChunkData(data);
       Assert.AreEqual(1, cassettes.Length);
       CassetteData cassette2 = cassettes[0];
       Assert.AreEqual(cassette.Meta.Key, cassette2.Meta.Key);
       Assert.AreEqual(cassette.Meta.FileName, cassette2.Meta.FileName);
       Assert.AreEqual(cassette.Meta.ProgramSize, cassette2.Meta.ProgramSize);
       Assert.AreEqual(cassette.Meta.Parity, cassette2.Meta.Parity);
       Assert.AreEqual(cassette.Program.Length, cassette2.Program.Length);
       Assert.AreEqual(cassette.Program.Key, cassette2.Program.Key);
       Assert.AreEqual(cassette.Program.Parity, cassette2.Program.Parity);
       IEnumerator<byte> bytes = cassette.Program.GetEnumerator();
       foreach (byte b in cassette2.Program) {
     bytes.MoveNext();
     Assert.AreEqual(bytes.Current, b);
       }
 }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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");
       }
 }