Beispiel #1
0
 internal AudioFileStream(string Path, AudioFileHeader Header, bool AddWAVHeader)
 {
     this.Path_         = Path;
     this.Header_       = Header;
     this.AddWAVHeader_ = AddWAVHeader;
     this.Codec_        = null;
     this.Position_     = 0;
     if (this.Header_.SampleFormat == SampleFormat.ADPCM)
     {
         this.Codec_ = new ADPCMCodec(this.Header_.Channels, this.Header_.BlockSize);
     }
     this.File_ = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
     this.File_.Seek(0x30, SeekOrigin.Begin);
     if (AddWAVHeader)
     {
         // Prepare WAV file header
         this.WAVHeader_ = new byte[0x2C];
         BinaryWriter BW = new BinaryWriter(new MemoryStream(this.WAVHeader_, true), Encoding.ASCII);
         // File Header
         BW.Write("RIFF".ToCharArray());
         BW.Write((int)this.Length);
         // Wave Format Header
         BW.Write("WAVEfmt ".ToCharArray());
         BW.Write((int)0x10);
         // Wave Format Data
         BW.Write((short)1); // PCM
         BW.Write((short)this.Header_.Channels);
         BW.Write((int)this.Header_.SampleRate);
         BW.Write((int)(2 * this.Header_.Channels * this.Header_.SampleRate)); // bytes per second
         BW.Write((short)(2 * this.Header_.Channels));                         // bytes per sample
         BW.Write((short)16);                                                  // bits
         // Wave Data Header
         BW.Write("data".ToCharArray());
         BW.Write((int)(this.Length - 0x2C));
         BW.Close();
     }
     this.Buffer_     = null;
     this.BufferPos_  = 0;
     this.BufferSize_ = 0;
 }
Beispiel #2
0
 internal AudioFileStream(string Path, AudioFileHeader Header, bool AddWAVHeader)
 {
     this.Path_ = Path;
     this.Header_ = Header;
     this.AddWAVHeader_ = AddWAVHeader;
     this.Codec_ = null;
     this.Position_ = 0;
     if (this.Header_.SampleFormat == SampleFormat.ADPCM)
     {
         this.Codec_ = new ADPCMCodec(this.Header_.Channels, this.Header_.BlockSize);
     }
     this.File_ = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
     this.File_.Seek(0x30, SeekOrigin.Begin);
     if (AddWAVHeader)
     {
         // Prepare WAV file header
         this.WAVHeader_ = new byte[0x2C];
         BinaryWriter BW = new BinaryWriter(new MemoryStream(this.WAVHeader_, true), Encoding.ASCII);
         // File Header
         BW.Write("RIFF".ToCharArray());
         BW.Write((int)this.Length);
         // Wave Format Header
         BW.Write("WAVEfmt ".ToCharArray());
         BW.Write((int)0x10);
         // Wave Format Data
         BW.Write((short)1); // PCM
         BW.Write((short)this.Header_.Channels);
         BW.Write((int)this.Header_.SampleRate);
         BW.Write((int)(2 * this.Header_.Channels * this.Header_.SampleRate)); // bytes per second
         BW.Write((short)(2 * this.Header_.Channels)); // bytes per sample
         BW.Write((short)16); // bits
         // Wave Data Header
         BW.Write("data".ToCharArray());
         BW.Write((int)(this.Length - 0x2C));
         BW.Close();
     }
     this.Buffer_ = null;
     this.BufferPos_ = 0;
     this.BufferSize_ = 0;
 }