Пример #1
0
        public override void WriteHeader(string comment)
        {
            OggCrc oggCrc = new OggCrc();

            byte[] array = OggSpeexWriter.BuildOggPageHeader(2, 0L, this.streamSerialNumber, this.pageCount++, 1, new byte[]
            {
                80
            });
            byte[] array2 = AudioFileWriter.BuildSpeexHeader(this.sampleRate, this.mode, this.channels, this.vbr, this.nframes);
            oggCrc.Initialize();
            oggCrc.TransformBlock(array, 0, array.Length, array, 0);
            oggCrc.TransformFinalBlock(array2, 0, array2.Length);
            this.xout.Write(array, 0, 22);
            this.xout.Write(oggCrc.Hash, 0, oggCrc.HashSize / 8);
            this.xout.Write(array, 26, array.Length - 26);
            this.xout.Write(array2, 0, array2.Length);
            array = OggSpeexWriter.BuildOggPageHeader(0, 0L, this.streamSerialNumber, this.pageCount++, 1, new byte[]
            {
                (byte)(comment.Length + 8)
            });
            array2 = AudioFileWriter.BuildSpeexComment(comment);
            oggCrc.Initialize();
            oggCrc.TransformBlock(array, 0, array.Length, array, 0);
            oggCrc.TransformFinalBlock(array2, 0, array2.Length);
            this.xout.Write(array, 0, 22);
            this.xout.Write(oggCrc.Hash, 0, oggCrc.HashSize / 8);
            this.xout.Write(array, 26, array.Length - 26);
            this.xout.Write(array2, 0, array2.Length);
        }
Пример #2
0
 public override void WriteHeader(string comment)
 {
     byte[] bytes = Encoding.UTF8.GetBytes("RIFF");
     this.raf.Write(bytes, 0, bytes.Length);
     this.raf.Write(0);
     bytes = Encoding.UTF8.GetBytes("WAVE");
     this.raf.Write(bytes, 0, bytes.Length);
     bytes = Encoding.UTF8.GetBytes("fmt ");
     this.raf.Write(bytes, 0, bytes.Length);
     if (this.isPCM)
     {
         this.raf.Write(16);
         this.raf.Write(1);
         this.raf.Write((short)this.channels);
         this.raf.Write(this.sampleRate);
         this.raf.Write(this.sampleRate * this.channels * 2);
         this.raf.Write((short)(this.channels * 2));
         this.raf.Write(16);
     }
     else
     {
         int length = comment.Length;
         this.raf.Write((short)(100 + length));
         this.raf.Write(-24311);
         this.raf.Write((short)this.channels);
         this.raf.Write(this.sampleRate);
         this.raf.Write(PcmWaveWriter.CalculateEffectiveBitrate(this.mode, this.channels, this.quality) + 7 >> 3);
         this.raf.Write((short)PcmWaveWriter.CalculateBlockSize(this.mode, this.channels, this.quality));
         this.raf.Write((short)this.quality);
         this.raf.Write((short)(82 + length));
         this.raf.Write(1);
         this.raf.Write(0);
         this.raf.Write(AudioFileWriter.BuildSpeexHeader(this.sampleRate, this.mode, this.channels, this.vbr, this.nframes));
         this.raf.Write(comment);
     }
     bytes = Encoding.UTF8.GetBytes("data");
     this.raf.Write(bytes, 0, bytes.Length);
     this.raf.Write(0);
 }
Пример #3
0
 protected static byte[] BuildSpeexComment(string comment)
 {
     byte[] array = new byte[comment.Length + 8];
     AudioFileWriter.WriteSpeexComment(new BinaryWriter(new MemoryStream(array)), comment);
     return(array);
 }
Пример #4
0
 protected static byte[] BuildSpeexHeader(int sampleRate, int mode, int channels, bool vbr, int nframes)
 {
     byte[] array = new byte[80];
     AudioFileWriter.WriteSpeexHeader(new BinaryWriter(new MemoryStream(array)), sampleRate, mode, channels, vbr, nframes);
     return(array);
 }