/// <summary> /// Read blocked data. /// </summary> /// <param name="r">The reader.</param> /// <param name="encodingType">Encoding type.</param> /// <param name="numChannels">Number of channels to read.</param> /// <param name="numBlocks">Number of blocks to read.</param> /// <param name="blockSize">Size of each block.</param> /// <param name="blockSamples">Samples in each block.</param> /// <param name="lastBlockSize">Last block size.</param> /// <param name="lastBlockSamples">Last block samples.</param> /// <param name="lastBlockPaddingSize">Size of the padding following the last block.</param> public void Read(FileReader r, Type encodingType, int numChannels, uint numBlocks, uint blockSize, uint blockSamples, uint lastBlockSize, uint lastBlockSamples, uint lastBlockPaddingSize) { //Set properties. EncodingType = encodingType; BlockSize = (int)blockSize; BlockSamples = (int)blockSamples; LastBlockPaddingSize = (int)lastBlockPaddingSize; //Init channels. Channels.Clear(); for (int i = 0; i < numChannels; i++) { Channels.Add(new List <IAudioEncoding>()); } //Read standard blocks. for (uint i = 0; i < numBlocks - 1; i++) { for (int j = 0; j < numChannels; j++) { IAudioEncoding data = (IAudioEncoding)Activator.CreateInstance(EncodingType); data.ReadRaw(r, blockSamples, blockSize); Channels[j].Add(data); } } //Read last block. for (int i = 0; i < numChannels; i++) { IAudioEncoding data = (IAudioEncoding)Activator.CreateInstance(EncodingType); data.ReadRaw(r, lastBlockSamples, lastBlockSize); Channels[i].Add(data); r.ReadBytes(LastBlockPaddingSize); } }
/// <summary> /// Read unblocked data. /// </summary> /// <param name="r">The reader.</param> /// <param name="encodingType">Encoding type.</param> /// <param name="numChannels">Number of channels to read.</param> /// <param name="dataSize">Data size of each channel.</param> /// <param name="numSamples">Number of samples to read.</param> /// <param name="dataPadding">Padding between one channel's data and the next.</param> public void Read(FileReader r, Type encodingType, int numChannels, int dataSize, int numSamples, int dataPadding) { //Set properties. EncodingType = encodingType; BlockSize = -1; BlockSamples = -1; LastBlockPaddingSize = dataPadding; //Read channel data. Channels.Clear(); for (int i = 0; i < numChannels; i++) { Channels.Add(new List <IAudioEncoding>()); IAudioEncoding data = (IAudioEncoding)Activator.CreateInstance(EncodingType); data.ReadRaw(r, (uint)numSamples, (uint)dataSize); Channels.Last().Add(data); r.ReadBytes(dataPadding); } }