Пример #1
0
        static AudioFlags MakeMixerFlags(Track track)
        {
            var flags = track.MixerFlags;
            var mixerFlags = AudioFlags.None;
            if (flags.HasFlag(AudioFlags.Unsigned))
                mixerFlags |= AudioFlags.Unsigned;
            if (flags.HasFlag(AudioFlags.Is16Bits))
                mixerFlags |= AudioFlags.Is16Bits;


            if (track.SndDataExtComp)
                mixerFlags |= AudioFlags.LittleEndian;

            if (flags.HasFlag(AudioFlags.Stereo))
                mixerFlags |= AudioFlags.Stereo;
            return mixerFlags;
        }
Пример #2
0
        public IMuseDigital(ScummEngine7 scumm, IMixer mixer, int fps)
        {
            _vm = scumm;
            _mixer = mixer;

            _pause = false;
            _sound = new ImuseDigiSndMgr(_vm);
            Debug.Assert(_sound != null);
            _callbackFps = fps;
            ResetState();
            for (int l = 0; l < MaxDigitalTracks + MaxDigitalFadeTracks; l++)
            {
                _track[l] = new Track();
                _track[l].TrackId = l;
            }

            _timer = new Timer(new TimerCallback(o => Callback()), this, TimeSpan.Zero, TimeSpan.FromMilliseconds(1000 / _callbackFps));

            _audioNames = null;
            _numAudioNames = 0;
        }
Пример #3
0
        void SwitchToNextRegion(Track track)
        {
            Debug.Assert(track != null);

            if (track.TrackId >= MaxDigitalTracks)
            {
                FlushTrack(track);
//                Debug.WriteLine("SwToNeReg(trackId:{0}) - fadetrack can't go next region, exiting SwToNeReg", track.TrackId);
                return;
            }

            int num_regions = _sound.GetNumRegions(track.SoundDesc);

            if (++track.CurRegion == num_regions)
            {
                FlushTrack(track);
//                Debug.WriteLine("SwToNeReg(trackId:{0}) - end of region, exiting SwToNeReg", track.TrackId);
                return;
            }

            SoundDesc soundDesc = track.SoundDesc;
            if (_triggerUsed && track.SoundDesc.NumMarkers != 0)
            {
                if (_sound.CheckForTriggerByRegionAndMarker(soundDesc, track.CurRegion, _triggerParams.Marker))
                {
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - trigger {1} reached", track.TrackId, _triggerParams.Marker);
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - exit current region {1}", track.TrackId, track.CurRegion);
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - call cloneToFadeOutTrack(delay:{1})", track.TrackId, _triggerParams.FadeOutDelay);
                    Track fadeTrack = CloneToFadeOutTrack(track, _triggerParams.FadeOutDelay);
                    if (fadeTrack != null)
                    {
                        fadeTrack.DataOffset = _sound.GetRegionOffset(fadeTrack.SoundDesc, fadeTrack.CurRegion);
                        fadeTrack.RegionOffset = 0;
//                        Debug.WriteLine("SwToNeReg(trackId:{0})-sound({1}) select region {2}, curHookId: {3}", fadeTrack.TrackId, fadeTrack.SoundId, fadeTrack.CurRegion, fadeTrack.CurHookId);
                        fadeTrack.CurHookId = 0;
                    }
                    FlushTrack(track);
                    StartMusic(_triggerParams.Filename, _triggerParams.SoundId, _triggerParams.HookId, _triggerParams.Volume);
                    _triggerUsed = false;
                    return;
                }
            }

            int jumpId = _sound.GetJumpIdByRegionAndHookId(soundDesc, track.CurRegion, track.CurHookId);
            if (jumpId != -1)
            {
                int region = _sound.GetRegionIdByJumpId(soundDesc, jumpId);
                Debug.Assert(region != -1);
                int sampleHookId = _sound.GetJumpHookId(soundDesc, jumpId);
                Debug.Assert(sampleHookId != -1);
//                Debug.WriteLine("SwToNeReg(trackId:{0}) - JUMP found - sound:{1}, track hookId:{2}, data hookId:{3}", track.TrackId, track.SoundId, track.CurHookId, sampleHookId);
                if (track.CurHookId == sampleHookId)
                {
                    int fadeDelay = (60 * _sound.GetJumpFade(soundDesc, jumpId)) / 1000;
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - sound({1}) match hookId", track.TrackId, track.SoundId);
                    if (fadeDelay != 0)
                    {
//                        Debug.WriteLine("SwToNeReg(trackId:{0}) - call cloneToFadeOutTrack(delay:{1})", track.TrackId, fadeDelay);
                        var fadeTrack = CloneToFadeOutTrack(track, fadeDelay);
                        if (fadeTrack != null)
                        {
                            fadeTrack.DataOffset = _sound.GetRegionOffset(fadeTrack.SoundDesc, fadeTrack.CurRegion);
                            fadeTrack.RegionOffset = 0;
//                            Debug.WriteLine("SwToNeReg(trackId:{0}) - sound({1}) faded track, select region {2}, curHookId: {3}", fadeTrack.TrackId, fadeTrack.SoundId, fadeTrack.CurRegion, fadeTrack.CurHookId);
                            fadeTrack.CurHookId = 0;
                        }
                    }
                    track.CurRegion = region;
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - sound({1}) jump to region {2}, curHookId: {3}", track.TrackId, track.SoundId, track.CurRegion, track.CurHookId);
                    track.CurHookId = 0;
                }
                else
                {
//                    Debug.WriteLine("SwToNeReg(trackId:{0}) - Normal switch region, sound({1}), hookId({2})", track.TrackId, track.SoundId, track.CurHookId);
                }
            }
            else
            {
//                Debug.WriteLine("SwToNeReg(trackId:{0}) - Normal switch region, sound({1}), hookId({2})", track.TrackId, track.SoundId, track.CurHookId);
            }

//            Debug.WriteLine("SwToNeReg(trackId:{0}) - sound({1}), select region {2}", track.TrackId, track.SoundId, track.CurRegion);
            track.DataOffset = _sound.GetRegionOffset(soundDesc, track.CurRegion);
            track.RegionOffset = 0;
//            Debug.WriteLine("SwToNeReg(trackId:{0}) - end of func", track.TrackId);
        }