Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        public override bool OnInitialize()
        {
            if (_name == null && _origPath != null)
            {
                _name = Path.GetFileNameWithoutExtension(_origPath);
            }

            base.OnInitialize();

            hdr   = Header->_header;
            cmp   = Header->_frameCompInfo;
            audio = Header->_audioInfo;
            video = Header->_videoInfo;

            _componentTypes = new List <byte>();

            for (int i = 0; i < Header->_frameCompInfo._numComponents; i++)
            {
                _componentTypes.Add(Header->_frameCompInfo._frameComp[i]);
            }

            uint    size = Header->_header._firstFrameSize;
            VoidPtr addr = Header->_header.FirstFrame;

            _frames = new THPFrame[NumFrames];
            for (int i = 0; i < NumFrames; i++)
            {
                _frames[i] = new THPFrame(addr, size, this);
                addr      += size;
                size       = _frames[i].Header->_frameSizeNext;
            }

            if (_componentTypes.Count > 1)
            {
                _audio = new THPStream(this);
            }
            else
            {
                _audio = null;
            }

            return(false);
        }
Exemplo n.º 3
0
        public override bool OnInitialize()
        {
            if ((_name == null) && (_origPath != null))
                _name = Path.GetFileNameWithoutExtension(_origPath);

            base.OnInitialize();

            hdr = Header->_header;
            cmp = Header->_frameCompInfo;
            audio = Header->_audioInfo;
            video = Header->_videoInfo;

            _componentTypes = new List<byte>();

            for (int i = 0; i < Header->_frameCompInfo._numComponents; i++)
                _componentTypes.Add(Header->_frameCompInfo._frameComp[i]);

            uint size = Header->_header._firstFrameSize;
            VoidPtr addr = Header->_header.FirstFrame;
            _frames = new THPFrame[NumFrames];
            for (int i = 0; i < NumFrames; i++)
            {
                _frames[i] = new THPFrame(addr, size, this);
                addr += size;
                size = _frames[i].Header->_frameSizeNext;
            }

            if (_componentTypes.Count > 1)
                _audio = new THPStream(this);
            else
                _audio = null;

            return false;
        }