示例#1
0
 public SmackerAudioTrack(IMixer mixer, AudioInfo audioInfo, SoundType soundType)
 {
     Mixer = mixer;
     _audioInfo = audioInfo;
     SoundType = soundType;
     _audioStream = new QueuingAudioStream((int)_audioInfo.sampleRate, _audioInfo.isStereo);
 }
示例#2
0
        public void Clear()
        {
            TrackId      = 0;
            pan          = 0;
            vol          = 0;
            VolFadeDest  = 0;
            VolFadeStep  = 0;
            VolFadeDelay = 0;
            VolFadeUsed  = false;
//            SoundId = 0;
            SoundName      = null;
            Used           = false;
            ToBeRemoved    = false;
            SouStreamUsed  = false;
            SndDataExtComp = false;
            SoundPriority  = 0;
            RegionOffset   = 0;
            DataOffset     = 0;
            CurRegion      = 0;
            CurHookId      = 0;
            VolGroupId     = 0;
            SoundType      = 0;
            FeedSize       = 0;
            DataMod12Bit   = 0;
            MixerFlags     = AudioFlags.None;

            SoundDesc     = null;
            MixChanHandle = new SoundHandle();
            Stream        = null;
        }
示例#3
0
 public SmackerAudioTrack(IMixer mixer, AudioInfo audioInfo, SoundType soundType)
 {
     _mixer       = mixer;
     _audioInfo   = audioInfo;
     _soundType   = soundType;
     _audioStream = new QueuingAudioStream((int)_audioInfo.sampleRate, _audioInfo.isStereo);
 }
示例#4
0
            public PsxAudioTrack(IMixer mixer, Stream sector)
            {
                _mixer = mixer;
                _endOfTrack = false;
                _adpcmStatus = new ADPCMStatus[2];
                for (int i = 0; i < _adpcmStatus.Length; i++)
                {
                    _adpcmStatus[i] = new ADPCMStatus();
                }

                sector.Seek(19, SeekOrigin.Begin);
                byte format = (byte)sector.ReadByte();
                bool stereo = (format & (1 << 0)) != 0;
                int rate = ((format & (1 << 2)) != 0) ? 18900 : 37800;
                _audStream = new QueuingAudioStream(rate, stereo);
                _dst = new byte[AUDIO_DATA_SAMPLE_COUNT * 2];
                _buf = new byte[AUDIO_DATA_CHUNK_SIZE];
            }
示例#5
0
            public PsxAudioTrack(IMixer mixer, Stream sector)
            {
                _mixer       = mixer;
                _endOfTrack  = false;
                _adpcmStatus = new ADPCMStatus[2];
                for (int i = 0; i < _adpcmStatus.Length; i++)
                {
                    _adpcmStatus[i] = new ADPCMStatus();
                }

                sector.Seek(19, SeekOrigin.Begin);
                byte format = (byte)sector.ReadByte();
                bool stereo = (format & (1 << 0)) != 0;
                int  rate   = ((format & (1 << 2)) != 0) ? 18900 : 37800;

                _audStream = new QueuingAudioStream(rate, stereo);
                _dst       = new byte[AUDIO_DATA_SAMPLE_COUNT * 2];
                _buf       = new byte[AUDIO_DATA_CHUNK_SIZE];
            }
示例#6
0
 public override bool Rewind()
 {
     _audioStream.Dispose();
     _audioStream = new QueuingAudioStream((int)_audioInfo.sampleRate, _audioInfo.isStereo);
     return true;
 }
示例#7
0
 public override bool Rewind()
 {
     _audioStream.Dispose();
     _audioStream = new QueuingAudioStream((int)_audioInfo.sampleRate, _audioInfo.isStereo);
     return(true);
 }
示例#8
0
        void HandleIACT(uint subSize, BinaryReader b)
        {
            //            Debug.WriteLine("SmushPlayer::IACT()");
            Debug.Assert(subSize >= 8);

            int code        = b.ReadUInt16();
            int flags       = b.ReadUInt16();
            int unknown     = b.ReadInt16();
            int track_flags = b.ReadUInt16();

            if ((code != 8) && (flags != 46))
            {
                _vm.Insane.ProcIACT(_dst, 0, 0, 0, b, 0, 0, code, flags, unknown, track_flags);
                return;
            }

            if (_compressedFileMode)
            {
                return;
            }

            Debug.Assert(flags == 46 && unknown == 0);
            int track_id = b.ReadUInt16();
            int index    = b.ReadUInt16();
            int nbframes = b.ReadUInt16();
            int size     = b.ReadInt32();
            int bsize    = (int)subSize - 18;

            if (_vm.Game.GameId != GameId.CurseOfMonkeyIsland)
            {
                int track = track_id;
                if (track_flags == 1)
                {
                    track = track_id + 100;
                }
                else if (track_flags == 2)
                {
                    track = track_id + 200;
                }
                else if (track_flags == 3)
                {
                    track = track_id + 300;
                }
                else if ((track_flags >= 100) && (track_flags <= 163))
                {
                    track = track_id + 400;
                }
                else if ((track_flags >= 200) && (track_flags <= 263))
                {
                    track = track_id + 500;
                }
                else if ((track_flags >= 300) && (track_flags <= 363))
                {
                    track = track_id + 600;
                }
                //                else
                //                {
                //                    Debug.Fail(string.Format("SmushPlayer::handleIACT(): bad track_flags: {0}", track_flags));
                //                }
                //                Debug.WriteLine("SmushPlayer::handleIACT(): {0}, {1}, {2}", track, index, track_flags);

                var c = _smixer.FindChannel(track);
                if (c == null)
                {
                    c = new ImuseChannel(track);
                    _smixer.AddChannel(c);
                }
                if (index == 0)
                {
                    c.SetParameters(nbframes, size, track_flags, unknown, 0);
                }
                else
                {
                    c.CheckParameters(index, nbframes, size, track_flags, unknown);
                }
                c.AppendData(b, bsize);
            }
            else
            {
                // TODO: Move this code into another SmushChannel subclass?
                var  src   = b.ReadBytes(bsize);
                int  d_src = 0;
                byte value;

                while (bsize > 0)
                {
                    if (_IACTpos >= 2)
                    {
                        int len = ScummHelper.ToUInt16BigEndian(_IACToutput, 0) + 2;
                        len -= _IACTpos;
                        if (len > bsize)
                        {
                            Array.Copy(src, d_src, _IACToutput, _IACTpos, bsize);
                            _IACTpos += bsize;
                            bsize     = 0;
                        }
                        else
                        {
                            var output_data = new byte[4096];

                            Array.Copy(src, d_src, _IACToutput, _IACTpos, len);
                            var dst    = 0;
                            var d_src2 = 0;
                            d_src2 += 2;
                            int  count     = 1024;
                            byte variable1 = _IACToutput[d_src2++];
                            byte variable2 = (byte)(variable1 / 16);
                            variable1 &= 0x0f;
                            do
                            {
                                value = _IACToutput[d_src2++];
                                if (value == 0x80)
                                {
                                    output_data[dst++] = _IACToutput[d_src2++];
                                    output_data[dst++] = _IACToutput[d_src2++];
                                }
                                else
                                {
                                    short val = (short)((sbyte)value << variable2);
                                    output_data[dst++] = (byte)(val >> 8);
                                    output_data[dst++] = (byte)val;
                                }
                                value = _IACToutput[d_src2++];
                                if (value == 0x80)
                                {
                                    output_data[dst++] = _IACToutput[d_src2++];
                                    output_data[dst++] = _IACToutput[d_src2++];
                                }
                                else
                                {
                                    short val = (short)((sbyte)value << variable1);
                                    output_data[dst++] = (byte)(val >> 8);
                                    output_data[dst++] = (byte)val;
                                }
                            } while ((--count) != 0);

                            if (_IACTstream == null)
                            {
                                _IACTstream  = new QueuingAudioStream(22050, true);
                                _IACTchannel = _vm.Mixer.PlayStream(SoundType.SFX, _IACTstream);
                            }
                            _IACTstream.QueueBuffer(output_data, 0x1000, true, AudioFlags.Stereo | AudioFlags.Is16Bits);

                            bsize   -= len;
                            d_src   += len;
                            _IACTpos = 0;
                        }
                    }
                    else
                    {
                        if (bsize > 1 && _IACTpos == 0)
                        {
                            _IACToutput[0] = src[d_src++];
                            _IACTpos       = 1;
                            bsize--;
                        }
                        _IACToutput[_IACTpos] = src[d_src++];
                        _IACTpos++;
                        bsize--;
                    }
                }
            }
        }