Example #1
0
        public void setWave(WavFile wave)
        {
            if (!wave.checkFormat(wf))
            {
                throw new Exception("Wrong import wave format");
            }
            byte[] bts = wave.rawBytes();
            if (bts.Length != wavelen())
            {
                throw new Exception("Bad import wave length");
            }
            UInt32 bpos = 0;

            foreach (UInt32[] x in waveMap)
            {
                byte[] chunk = new byte[x[1]];
                Array.Copy(bts, bpos, chunk, 0, x[1]);
                bpos         += x[1];
                data.Position = x[0];
                data.Write(chunk, 0, (int)x[1]);
            }
        }
Example #2
0
 static void Main(string[] args)
 {
     Console.WriteLine("CrusAVI v0.1");
     if (args.Length < 3 || (args[0] != "export" && args[0] != "import") || (args[0] == "import" && args.Length < 4))
     {
         usage();
         return;
     }
     try
     {
         string  inavi = args[1];
         string  wav   = args[2];
         AVIFile avi   = new AVIFile(inavi);
         if (args[0] == "export")
         {
             WavFile    wave = avi.getWave();
             FileStream fs   = new FileStream(wav, FileMode.Create);
             wave.saveToStream(fs);
             fs.Close();
         }
         else
         {
             string     outavi = args[3];
             FileStream fs     = new FileStream(wav, FileMode.Open);
             WavFile    wave   = new WavFile(fs);
             fs.Close();
             avi.setWave(wave);
             avi.save(outavi);
         }
         avi.close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("ERROR:" + ex.Message);
     }
 }
Example #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("CrusAVI v0.1");
     if (args.Length < 3 || (args[0] != "export" && args[0] != "import") || (args[0]=="import" && args.Length<4))
     {
         usage();
         return;
     }
     try
     {
         string inavi = args[1];
         string wav = args[2];
         AVIFile avi = new AVIFile(inavi);
         if (args[0] == "export")
         {
             WavFile wave = avi.getWave();
             FileStream fs = new FileStream(wav, FileMode.Create);
             wave.saveToStream(fs);
             fs.Close();
         }
         else
         {
             string outavi = args[3];
             FileStream fs=new FileStream(wav,FileMode.Open);
             WavFile wave = new WavFile(fs);
             fs.Close();
             avi.setWave(wave);
             avi.save(outavi);
         }
         avi.close();
     }
     catch (Exception ex)
     {
         Console.WriteLine("ERROR:"+ex.Message);
     }
 }
Example #4
0
 public void setWave(WavFile wave)
 {
     if (!wave.checkFormat(wf))
         throw new Exception("Wrong import wave format");
     byte[] bts=wave.rawBytes();
     if (bts.Length != wavelen())
         throw new Exception("Bad import wave length");
     UInt32 bpos=0;
     foreach (UInt32[] x in waveMap)
     {
         byte[] chunk = new byte[x[1]];
         Array.Copy(bts, bpos, chunk, 0, x[1]);
         bpos += x[1];
         data.Position = x[0];
         data.Write(chunk, 0, (int)x[1]);
     }
 }