/// <summary> /// block type nine /// </summary> private void ParseBlockTypeNine(ref int pos, int len) { Rott2DVocBlockNineHeader _blockheader = new Rott2DVocBlockNineHeader(); _blockheader.SampleRate = BitConverter.ToInt32(this._rawData, pos); //Int32 (int) _blockheader.BitsPerSample = this._rawData[(pos = pos + sizeof(int))]; //Byte _blockheader.Channels = this._rawData[(pos = pos + sizeof(byte))]; //Byte _blockheader.Codec = BitConverter.ToInt16(this._rawData, (pos = pos + sizeof(ushort))); //Int16 (short) _blockheader.Reserved0 = this._rawData[pos = pos + sizeof(byte)]; //Byte _blockheader.Reserved1 = this._rawData[pos = pos + sizeof(byte)]; //Byte _blockheader.Reserved2 = this._rawData[pos = pos + sizeof(byte)]; //Byte Rott2DVocBlockData _block = new Rott2DVocBlockData(); _block.SampleRate = _blockheader.SampleRate; _block.PCMType = 0; _block.Bits = _blockheader.BitsPerSample; //set general settings this._sampleRate = _block.SampleRate; this._channels = _blockheader.Channels; this._bits = _block.Bits; if (_blockheader.Channels > 1 && _blockheader.Codec == VOC_SAMPLE_16BIT) { _block.ChannelType = VOC_STEREO; //16 bit sample = stereo } else if (_blockheader.Channels == 1 && _blockheader.Codec == VOC_SAMPLE_8BIT) { _block.ChannelType = VOC_MONO; //8 bit sample = mono } else { throw new Exception("ParseBlockTypeNine :: BlockNine invalid voc block"); } //fill sound data buffer (-> this is the "real" sound data) _block.initSampleData(len); ushort samplePos = 0; //block index int datarest = this._rawData.Length - this._vocHeader.HeaderSize - len - 1; //calculate other rubbish to be removed for (int block = 0; block < len; block++) { _block[samplePos] = this._rawData[(this._vocHeader.HeaderSize + datarest) + block]; //_block[samplePos] = this._rawData[block + this._vocHeader.HeaderSize + 4]; //_block[samplePos] = this._rawData[this._vocHeader.HeaderSize + block]; //_block[samplePos] = this._rawData[block]; samplePos++; } //add sound data to generics list this.blocks.Add(_block); }
/// <summary> /// block type one /// </summary> private void ParseBlockTypeOne(ref int pos, int len) { Rott2DVocBlockOneHeader _blockheader = new Rott2DVocBlockOneHeader(); _blockheader.Len = len; _blockheader.Tc = (uint)(this._rawData[pos] << 8); _blockheader.Pack = this._rawData[pos = pos + 1]; Rott2DVocBlockData _block = new Rott2DVocBlockData(); _block.SampleRate = (int)((ulong)256000000L / (65536 - _blockheader.Tc)); _block.PCMType = _blockheader.Pack & 0xFF; _block.Bits = 8; _block.ChannelType = VOC_MONO; //mono tone only //set general settings this._sampleRate = _block.SampleRate; this._channels = 1; this._bits = _block.Bits; //fill sound data buffer (this is the real sound data) _block.initSampleData(len); ushort samplePos = 0; int datarest = this._rawData.Length - this._vocHeader.HeaderSize - len - 1; //calculate other rubbish to be removed for (int block = 0; block < len; block++) { _block[samplePos] = this._rawData[(this._vocHeader.HeaderSize + datarest) + block]; //_block[samplePos] = this._rawData[block + this._vocHeader.HeaderSize + 4]; //_block[samplePos] = this._rawData[this._vocHeader.HeaderSize + block]; //_block[samplePos] = this._rawData[block]; samplePos++; } //add sound data to generics list this.blocks.Add(_block); }