コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }