/// <summary> /// Read a soundN'Stream block from a b_wav. /// </summary> /// <param name="br">The reader.</param> /// <param name="wavInfo"></param> public SoundNStreamDataBlock(ref BinaryDataReader br, b_wav.InfoBlock wavInfo) { //Read magic. br.ReadUInt32(); UInt32 size = br.ReadUInt32(); //Set data base postion. long dataBasePosition = br.Position; //Read the channels. switch (wavInfo.encoding) { //PCM8. case EncodingTypes.PCM8: //Make new data array. pcm8 = new sbyte[wavInfo.channelInfo.Count()][]; //See how big the length of each channel is. int channelSize8 = (int)(size - wavInfo.channelInfo[pcm8.Length - 1].samplesRef.offset) - 8; //Read channels. for (int i = 0; i < pcm8.Count(); i++) { //Set postion. br.Position = wavInfo.channelInfo[i].samplesRef.offset + dataBasePosition; //Read data. pcm8[i] = br.ReadSBytes(channelSize8); } break; //PCM16. case EncodingTypes.PCM16: //Make new data array. pcm16 = new short[wavInfo.channelInfo.Count()][]; //See how big the length of each channel is. int channelSize16 = (int)((size - wavInfo.channelInfo[pcm16.Length - 1].samplesRef.offset) - 8) / 2; //Read channels. for (int i = 0; i < pcm16.Count(); i++) { //Set postion. br.Position = wavInfo.channelInfo[i].samplesRef.offset + dataBasePosition; //Read data. pcm16[i] = br.ReadInt16s(channelSize16); } break; //DSP-ADPCM. case EncodingTypes.DSP_ADPCM: //Make new data array. dspAdpcm = new byte[wavInfo.channelInfo.Count()][]; //See how big the length of each channel is. int channelSize4 = (int)(size - wavInfo.channelInfo[dspAdpcm.Length - 1].samplesRef.offset) - 8; //Read channels. for (int i = 0; i < dspAdpcm.Count(); i++) { //Set postion. br.Position = wavInfo.channelInfo[i].samplesRef.offset + dataBasePosition; //Read data. dspAdpcm[i] = br.ReadBytes(channelSize4); } break; } }