Пример #1
0
        internal SoundHelperInstance(SoundHelper sh)
        {
            mData = sh;

            _tracks = new TrackHelperInstance[sh._tracks.Length];
            for (int i = 0; i < _tracks.Length; i++)
            {
                _tracks[i] = new TrackHelperInstance(sh._tracks[i]);
            }
        }
Пример #2
0
        internal SoundHelperInstance(SoundHelper sh)
        {
            mData = sh;

            _tracks = new TrackHelperInstance[sh._tracks.Length];
            for (int i = 0; i < _tracks.Length; i++)
            {
                _tracks[i] = new TrackHelperInstance(sh._tracks[i]);
            }
        }
Пример #3
0
        public void Update()
        {
            if (Playing)
            {
                if (!mUpdating)
                {
                    mUpdating = true;
                    _player.mData.bank.instances.Add(this);
                }

                float rpcDb     = 0;
                float rpcFilter = 20000;
                int   rpcReverb = -10000;
                //float reverb = 0;
                for (int i = 0; i < mData.rpcs.Length; i++)
                {
                    float v = mData.rpcs[i].Value(_player);
                    if (mData.rpcs[i].mParameterType == 0)
                    {
                        // GG HAX make volume ducking more duckalicious
                        rpcDb += 1.5f * v;
                    }
                    else if (mData.rpcs[i].mParameterType == 2)
                    {
                        rpcReverb = (int)v;
                    }
                    else
                    {
                        GSGE.Debug.assert(mData.rpcs[i].mParameterType == 3);
                        GSGE.Debug.assert(v <= 20000);
                        rpcFilter = Math.Min(rpcFilter, v);
                    }
                }

                for (int i = 0; i < _tracks.Length; i++)
                {
                    Sound _sound = GetSound(i);
                    if (_sound != null)
                    {
                        TrackHelperInstance track = _tracks[i];

                        double attenuation_in_db = (rpcDb / 100.0f) + track.mVolVar;
                        float  rpcGain           = (float)Math.Pow(10, attenuation_in_db / 20.0);

                        _sound.Volume = mData.gain * mData.category.Volume * rpcGain;

                        float filter = rpcFilter;
                        if (track.mData.mFiltered && track.mData.mFilterFrequency < filter)
                        {
                            filter = track.mData.mFilterFrequency;
                        }

                        _sound.LowPassCutoff = filter;

                        _sound.Pitch = track.mPitchVar + mData._pitch;

                        _sound.Reverb = rpcReverb;
                    }
                }
            }
        }