public ADPCMStream(RSTMHeader* pRSTM, VoidPtr dataAddr) { HEADHeader* pHeader = pRSTM->HEADData; StrmDataInfo* part1 = pHeader->Part1; bshort* ynCache = (bshort*)pRSTM->ADPCData->Data; byte* sPtr; short[][] coefs; ADPCMInfo* info; int loopBlock, loopChunk; short yn1 = 0, yn2 = 0; _numChannels = part1->_format._channels; _isLooped = part1->_format._looped != 0; _sampleRate = part1->_sampleRate; _numSamples = part1->_numSamples; _numBlocks = part1->_numBlocks; _blockLen = part1->_blockSize; _loopStartSample = part1->_loopStartSample; _lastBlockSamples = part1->_lastBlockSamples; _lastBlockSize = part1->_lastBlockTotal; _samplesPerBlock = part1->_samplesPerBlock; _loopEndSample = _numSamples; _blockStates = new ADPCMState[_numChannels, _numBlocks]; _currentStates = new ADPCMState[_numChannels]; _loopStates = new ADPCMState[_numChannels]; coefs = new short[_numChannels][]; loopBlock = _loopStartSample / _samplesPerBlock; loopChunk = (_loopStartSample - (loopBlock * _samplesPerBlock)) / 14; sPtr = (byte*)dataAddr + (loopBlock * _blockLen * _numChannels) + (loopChunk * 8); //Get channel info for (int i = 0; i < _numChannels; i++) { info = pHeader->GetChannelInfo(i); //Get channel coefs coefs[i] = info->Coefs; //Fill loop state _loopStates[i] = new ADPCMState(sPtr, info->_lps, info->_lyn1, info->_lyn2, coefs[i]); //Advance source pointer for next channel sPtr += _blockLen; } //Fill block states in a linear fashion sPtr = (byte*)dataAddr; for (int sIndex = 0, bIndex = 0; sIndex < _numSamples; sIndex += _samplesPerBlock, bIndex++) for (int cIndex = 0; cIndex < _numChannels; cIndex++) { if (bIndex > 0) //yn values will be zero if first block { yn1 = *ynCache++; yn2 = *ynCache++; } //Get block state _blockStates[cIndex, bIndex] = new ADPCMState(sPtr, *sPtr, yn1, yn2, coefs[cIndex]); //Use ps from data stream //Advance address sPtr += (bIndex == _numBlocks - 1) ? _lastBlockSize : _blockLen; } }
public ADPCMStream(WaveInfo* pWAVE, VoidPtr dataAddr) { _dataAddress = dataAddr; ADPCMInfo*[] info; int loopBlock, loopChunk; byte* sPtr; info = new ADPCMInfo*[_numChannels = pWAVE->_format._channels]; _currentStates = new ADPCMState[_numChannels]; _loopStates = new ADPCMState[_numChannels]; _isLooped = pWAVE->_format._looped != 0; _sampleRate = pWAVE->_sampleRate; _numSamples = pWAVE->NumSamples; if (_numSamples <= 0) return; _blockLen = (_numSamples.Align(14) / 14 * 8).Align(0x20); _loopStartSample = (int)pWAVE->LoopSample; _loopEndSample = _numSamples; Init(); _blockStates = new ADPCMState[_numChannels, _numBlocks]; loopBlock = _loopStartSample / _samplesPerBlock; loopChunk = (_loopStartSample - (loopBlock * _samplesPerBlock)) / 14; int x = (loopBlock * _blockLen * _numChannels) + (loopChunk * 8); int y = (_loopStartSample / 14 * 8); sPtr = (byte*)dataAddr + x; //Get channel info for (int i = 0; i < _numChannels; i++) //{ // //sPtr = (byte*)dataAddr + pWAVE->GetChannelInfo(i)->_channelDataOffset + loopStart; info[i] = pWAVE->GetADPCMInfo(i); // //Fill loop state // _loopStates[i] = new ADPCMState(sPtr, info[i]->_lps, info[i]->_lyn1, info[i]->_lyn2, info[i]->Coefs); // //Advance source pointer for next channel // sPtr += _blockLen; //} //Fill block states in a linear fashion sPtr = (byte*)dataAddr; for (int sIndex = 0, bIndex = 0; sIndex < _numSamples; sIndex += _samplesPerBlock, bIndex++) for (int cIndex = 0; cIndex < _numChannels; cIndex++) { //sPtr = (byte*)dataAddr + pWAVE->GetChannelInfo(cIndex)->_channelDataOffset; //Get block state ADPCMInfo* i = info[cIndex]; _blockStates[cIndex, bIndex] = new ADPCMState(sPtr, i->_ps, i->_yn1, i->_yn2, i->_lps, i->_lyn1, i->_lyn2, i->Coefs); //Use ps from data stream //Advance address sPtr += (bIndex == _numBlocks - 1) ? _lastBlockSize : _blockLen; } }
public THPStream(THPNode node) { byte* sPtr; short yn1 = 0, yn2 = 0; _numChannels = (int)node.Channels; _sampleRate = (int)node.Frequency; _numSamples = (int)node.NumSamples; _numBlocks = (int)node.NumFrames; _blockStates = new ADPCMState[_numChannels, _numBlocks]; _currentStates = new ADPCMState[_numChannels]; _audioBlocks = new THPAudioBlock[_numBlocks]; //Fill block states in a linear fashion for (int frame = 0; frame < node.NumFrames; frame++) { THPFrame f = node._frames[frame]; ThpAudioFrameHeader* header = f.Audio; for (int channel = 0; channel < _numChannels; channel++) { sPtr = header->GetAudioChannel(channel); short[] coefs; if (channel == 0) { yn1 = header->_c1yn1; yn2 = header->_c1yn2; coefs = header->Coefs1; } else { yn1 = header->_c2yn1; yn2 = header->_c2yn2; coefs = header->Coefs2; } //Get block state _blockStates[channel, frame] = new ADPCMState(sPtr, *sPtr, yn1, yn2, coefs); //Use ps from data stream } _audioBlocks[frame] = new THPAudioBlock(header->_blockSize, header->_numSamples); } }
public ADPCMStream(RSTMHeader* pRSTM, int channels, int startChannel, VoidPtr dataAddr) { HEADHeader* pHeader = pRSTM->HEADData; StrmDataInfo* part1 = pHeader->Part1; bshort* ynCache = (bshort*)pRSTM->ADPCData->Data; byte* sPtr; short[][] coefs; ADPCMInfo* info; int loopBlock, loopChunk; short yn1 = 0, yn2 = 0; _numChannels = part1->_format._channels; _isLooped = part1->_format._looped != 0; _sampleRate = part1->_sampleRate; _numSamples = part1->_numSamples; _numBlocks = part1->_numBlocks; _blockLen = part1->_blockSize; _loopStartSample = part1->_loopStartSample; _lastBlockSamples = part1->_lastBlockSamples; _lastBlockSize = part1->_lastBlockTotal; _samplesPerBlock = part1->_samplesPerBlock; _loopEndSample = _numSamples; _blockStates = new ADPCMState[_numChannels, _numBlocks]; _currentStates = new ADPCMState[_numChannels]; _loopStates = new ADPCMState[_numChannels]; coefs = new short[_numChannels][]; loopBlock = _loopStartSample / _samplesPerBlock; loopChunk = (_loopStartSample - (loopBlock * _samplesPerBlock)) / 14; sPtr = (byte*)dataAddr + (loopBlock * _blockLen * _numChannels) + (loopChunk * 8); //Get channel info for (int i = 0; i < _numChannels; i++) { info = pHeader->GetChannelInfo(i); //Get channel coefs coefs[i] = info->Coefs; //Fill loop state _loopStates[i] = new ADPCMState(sPtr, info->_lps, info->_lyn1, info->_lyn2, coefs[i]); //Advance source pointer for next channel sPtr += _blockLen; } //Fill block states in a linear fashion sPtr = (byte*)dataAddr; for (int sIndex = 0, bIndex = 0; sIndex < _numSamples; sIndex += _samplesPerBlock, bIndex++) for (int cIndex = 0; cIndex < _numChannels; cIndex++) { if (bIndex > 0) //yn values will be zero if first block { yn1 = *ynCache++; yn2 = *ynCache++; } //Get block state _blockStates[cIndex, bIndex] = new ADPCMState(sPtr, *sPtr, yn1, yn2, coefs[cIndex]); //Use ps from data stream //Advance address sPtr += (bIndex == _numBlocks - 1) ? _lastBlockSize : _blockLen; } _numChannels = channels; _startChannel = startChannel; }
public ADPCMStream(WaveInfo* pWAVE, VoidPtr dataAddr) { _dataAddress = dataAddr; ADPCMInfo*[] info; int loopBlock, loopChunk; byte* sPtr; info = new ADPCMInfo*[_numChannels = pWAVE->_format._channels]; _currentStates = new ADPCMState[_numChannels]; _loopStates = new ADPCMState[_numChannels]; _isLooped = pWAVE->_format._looped != 0; _sampleRate = pWAVE->_sampleRate; _numSamples = pWAVE->NumSamples; if (_numSamples <= 0) return; _blockLen = (_numSamples.Align(14) / 14 * 8).Align(0x20); _loopStartSample = (int)pWAVE->LoopSample; _loopEndSample = _numSamples; Init(); _blockStates = new ADPCMState[_numChannels, _numBlocks]; loopBlock = _loopStartSample / _samplesPerBlock; loopChunk = (_loopStartSample - (loopBlock * _samplesPerBlock)) / 14; int x = (loopBlock * _blockLen * _numChannels) + (loopChunk * 8); int y = (_loopStartSample / 14 * 8); sPtr = (byte*)dataAddr + x; //Get channel info for (int i = 0; i < _numChannels; i++) //{ // //sPtr = (byte*)dataAddr + pWAVE->GetChannelInfo(i)->_channelDataOffset + loopStart; info[i] = pWAVE->GetADPCMInfo(i); // //Fill loop state // _loopStates[i] = new ADPCMState(sPtr, info[i]->_lps, info[i]->_lyn1, info[i]->_lyn2, info[i]->Coefs); // //Advance source pointer for next channel // sPtr += _blockLen; //} //Fill block states in a linear fashion sPtr = (byte*)dataAddr; for (int sIndex = 0, bIndex = 0; sIndex < _numSamples; sIndex += _samplesPerBlock, bIndex++) for (int cIndex = 0; cIndex < _numChannels; cIndex++) { //sPtr = (byte*)dataAddr + pWAVE->GetChannelInfo(cIndex)->_channelDataOffset; //Get block state ADPCMInfo* i = info[cIndex]; _blockStates[cIndex, bIndex] = new ADPCMState(sPtr, i->_ps, i->_yn1, i->_yn2, i->_lps, i->_lyn1, i->_lyn2, i->Coefs); //Use ps from data stream //Advance address sPtr += (bIndex == _numBlocks - 1) ? _lastBlockSize : _blockLen; } }
public ADPCMStream(RWSD_WAVEEntry *pWAVE, VoidPtr dataAddr) { ADPCMInfo *info; short[][] coefs; short yn1 = 0, yn2 = 0; coefs = new short[_numChannels = pWAVE->_format._channels][]; if (_numChannels == 2) { Console.WriteLine("2 channels"); } _currentStates = new ADPCMState[_numChannels]; _loopStates = new ADPCMState[_numChannels]; _isLooped = pWAVE->_format._looped != 0; _sampleRate = pWAVE->_sampleRate; _numSamples = pWAVE->NumSamples; _blockLen = (_numSamples.Align(14) / 14 * 8).Align(0x20); _loopStartSample = (int)pWAVE->_loopStartSample; _loopEndSample = _numSamples; //_preserveLoopState = true; if (_blockLen <= 0) { _samplesPerBlock = 0; _numBlocks = 0; _lastBlockSamples = 0; } else { _samplesPerBlock = _blockLen / 8 * 14; _numBlocks = _numSamples.Align(_samplesPerBlock) / _samplesPerBlock; if ((_numSamples % _samplesPerBlock) != 0) { _lastBlockSamples = _numSamples % _samplesPerBlock; } else { _lastBlockSamples = _samplesPerBlock; } } _lastBlockSize = _lastBlockSamples.Align(14) / 14 * 8; //Init(); _blockStates = new ADPCMState[_numChannels, _numBlocks]; //info = &pWAVE->_adpcInfo; //coefs = info->Coefs; //_blockStates = new ADPCMState[1, 1]; //_currentStates = new ADPCMState[1]; //_loopStates = new ADPCMState[1]; byte *sPtr = (byte *)dataAddr + (_loopStartSample / 14 * 8); //Get channel info for (int i = 0; i < _numChannels; i++) { info = &pWAVE->Info[i]; //Get channel coefs coefs[i] = info->Coefs; //Fill loop state _loopStates[i] = new ADPCMState(sPtr, info->_lps, info->_lyn1, info->_lyn2, coefs[i]); //Advance source pointer for next channel sPtr += _blockLen; } //Fill block states in a linear fashion sPtr = (byte *)dataAddr; for (int sIndex = 0, bIndex = 0; sIndex < _numSamples; sIndex += _samplesPerBlock, bIndex++) { for (int cIndex = 0; cIndex < _numChannels; cIndex++) { if (bIndex > 0) //yn values will be zero if first block { yn1 = (short)&pWAVE->Info[cIndex]._lyn1; yn2 = (short)&pWAVE->Info[cIndex]._lyn2; } //Get block state _blockStates[cIndex, bIndex] = new ADPCMState(sPtr, *sPtr, yn1, yn2, coefs[cIndex]); //Use ps from data stream //Advance address sPtr += (bIndex == _numBlocks - 1) ? _lastBlockSize : _blockLen; } } //_loopStates[0] = new ADPCMState((byte*)dataAddr + (_loopStartSample / 14 * 8), info->_lps, info->_lyn1, info->_lyn2, coefs); //_currentStates[0] = _blockStates[0, 0] = new ADPCMState((byte*)dataAddr, info->_ps, info->_yn1, info->_yn2, coefs); }