Esempio n. 1
0
    private void Start()
    {
        rb   = GetComponent <Rigidbody>();
        anim = GetComponent <Animator>();
        echo = GetComponent <EchoEffect>();

        shake = GameObject.FindGameObjectWithTag("shake").GetComponent <CameraShake>();

        AnimationClip clip;

        //Get jump and animation to happen at same time
        AnimationEvent jump;

        jump = new AnimationEvent();
        jump.functionName = "AddForceToJump";
        anim = GetComponent <Animator>();
        clip = anim.runtimeAnimatorController.animationClips[1];
        clip.AddEvent(jump);

        //Get in world effects and player animation to happen at same time
        AnimationEvent impact;

        impact = new AnimationEvent();
        impact.functionName = "Impact";
        anim = GetComponent <Animator>();
        clip = anim.runtimeAnimatorController.animationClips[3];
        clip.AddEvent(impact);
    }
Esempio n. 2
0
        public SelfState(CitizenFX.Core.Vector3 position, float rotation, bool echo = false)
        {
            this.Position = new Vector3(position.X, position.Y, position.Z);
            this.Rotation = rotation;
            this.IsAlive  = true;

            if (echo)
            {
                this.Echo = new EchoEffect();
            }
        }
Esempio n. 3
0
        public SelfState(CitizenFX.Core.Vector3 position, float rotation, float voiceRange, bool isAlive, bool echo = false)
        {
            this.Position   = new TSVector(position.X, position.Y, position.Z);
            this.Rotation   = rotation;
            this.VoiceRange = voiceRange;
            this.IsAlive    = isAlive;

            if (echo)
            {
                this.Echo = new EchoEffect();
            }
        }
Esempio n. 4
0
        private void applyEffectButton_Click(object sender, EventArgs e)
        {
            AudioEffect effect;

            var fs = _signal.SamplingRate;

            var winSize = int.Parse(winSizeTextBox.Text);
            var hopSize = int.Parse(hopSizeTextBox.Text);
            var tsm     = (TsmAlgorithm)tsmComboBox.SelectedIndex;

            var shift = float.Parse(pitchShiftTextBox.Text);

            if (tremoloRadioButton.Checked)
            {
                var freq  = float.Parse(tremoloFrequencyTextBox.Text);
                var index = float.Parse(tremoloIndexTextBox.Text);
                effect = new TremoloEffect(fs, freq, index);
            }
            else if (overdriveRadioButton.Checked)
            {
                var gain = float.Parse(distortionGainTextBox.Text);
                effect = new OverdriveEffect(gain);
            }
            else if (distortionRadioButton.Checked)
            {
                var gain = float.Parse(distortionGainTextBox.Text);
                effect = new DistortionEffect(gain);
            }
            else if (tubeDistortionRadioButton.Checked)
            {
                var gain = float.Parse(distortionGainTextBox.Text);
                var mix  = float.Parse(wetTextBox.Text);
                var dist = float.Parse(distTextBox.Text);
                var q    = float.Parse(qTextBox.Text);
                effect = new TubeDistortionEffect(gain, mix, q, dist);
            }
            else if (echoRadioButton.Checked)
            {
                var delay = float.Parse(echoDelayTextBox.Text);
                var decay = float.Parse(echoDecayTextBox.Text);
                effect = new EchoEffect(fs, delay, decay);
            }
            else if (delayRadioButton.Checked)
            {
                var delay = float.Parse(echoDelayTextBox.Text);
                var decay = float.Parse(echoDecayTextBox.Text);
                effect = new DelayEffect(fs, delay, decay);
            }
            else if (wahwahRadioButton.Checked)
            {
                var lfoFrequency = float.Parse(lfoFreqTextBox.Text);
                var minFrequency = float.Parse(minFreqTextBox.Text);
                var maxFrequency = float.Parse(maxFreqTextBox.Text);
                var q            = float.Parse(lfoQTextBox.Text);
                //effect = new WahwahEffect(fs, lfoFrequency, minFrequency, maxFrequency, q);
                effect = new AutowahEffect(fs, minFrequency, maxFrequency, q);
            }
            else if (flangerRadioButton.Checked)
            {
                var lfoFrequency = float.Parse(lfoFreqTextBox.Text);
                var maxDelay     = float.Parse(maxDelayTextBox.Text);
                effect = new FlangerEffect(fs, maxDelay, lfoFrequency);
            }
            else if (pitchShiftRadioButton.Checked)
            {
                effect = pitchShiftCheckBox.Checked ? new PitchShiftEffect(shift, winSize, hopSize, tsm) : null;
                //effect = pitchShiftCheckBox.Checked ? new WhisperEffect(hopSize, winSize) : null;
                //effect = new MorphEffect(hopSize, winSize);
            }
            else
            {
                var lfoFrequency = float.Parse(lfoFreqTextBox.Text);
                var minFrequency = float.Parse(minFreqTextBox.Text);
                var maxFrequency = float.Parse(maxFreqTextBox.Text);
                var q            = float.Parse(lfoQTextBox.Text);

                var lfo = new SawtoothBuilder()
                          .SetParameter("freq", lfoFrequency)
                          .SetParameter("min", minFrequency)
                          .SetParameter("max", maxFrequency)
                          .SampledAt(_signal.SamplingRate);

                effect = new PhaserEffect(fs, lfo, q);
            }

            if (effect != null)
            {
                effect.Wet = float.Parse(wetTextBox.Text);
                effect.Dry = float.Parse(dryTextBox.Text);

                _filteredSignal = effect.ApplyTo(_signal, FilteringMethod.Auto);

                //DiscreteSignal morph;
                //using (var stream = new FileStream(@"D:\Docs\Research\DATABASE\Dictor1\wav\gtr16khz.wav", FileMode.Open))
                //{
                //    var waveFile = new WaveFile(stream);
                //    morph = waveFile[Channels.Average];
                //}

                //_filteredSignal = ((MorphEffect)effect).ApplyTo(_signal, morph);
            }
            else
            {
                _filteredSignal = Operation.TimeStretch(_signal, shift, tsm);
                //Operation.TimeStretch(_signal, shift, winSize, hopSize, tsm);
            }

            signalAfterFilteringPanel.Signal           = _filteredSignal;
            spectrogramAfterFilteringPanel.Spectrogram = _stft.Spectrogram(_filteredSignal.Samples);
        }
Esempio n. 5
0
        private void applyEffectButton_Click(object sender, EventArgs e)
        {
            IFilter effect;

            if (tremoloRadioButton.Checked)
            {
                var freq  = float.Parse(tremoloFrequencyTextBox.Text);
                var index = float.Parse(tremoloIndexTextBox.Text);
                effect = new TremoloEffect(freq, index);
            }
            else if (overdriveRadioButton.Checked)
            {
                effect = new OverdriveEffect();
            }
            else if (distortionRadioButton.Checked)
            {
                var gain = float.Parse(distortionGainTextBox.Text);
                var mix  = float.Parse(distortionMixTextBox.Text);
                effect = new DistortionEffect(gain, mix);
            }
            else if (tubeDistortionRadioButton.Checked)
            {
                var gain = float.Parse(distortionGainTextBox.Text);
                var mix  = float.Parse(distortionMixTextBox.Text);
                var dist = float.Parse(distTextBox.Text);
                var q    = float.Parse(qTextBox.Text);
                effect = new TubeDistortionEffect(gain, mix, q, dist);
            }
            else if (echoRadioButton.Checked)
            {
                var delay = float.Parse(echoDelayTextBox.Text);
                var decay = float.Parse(echoDecayTextBox.Text);
                effect = new EchoEffect(delay, decay);
            }
            else if (delayRadioButton.Checked)
            {
                var delay = float.Parse(echoDelayTextBox.Text);
                var decay = float.Parse(echoDecayTextBox.Text);
                effect = new DelayEffect(delay, decay);
            }
            else if (wahwahRadioButton.Checked)
            {
                var lfoFrequency = float.Parse(lfoFreqTextBox.Text);
                var minFrequency = float.Parse(minFreqTextBox.Text);
                var maxFrequency = float.Parse(maxFreqTextBox.Text);
                var q            = float.Parse(lfoQTextBox.Text);
                effect = new WahwahEffect(lfoFrequency, minFrequency, maxFrequency, q);
            }
            else if (pitchShiftRadioButton.Checked)
            {
                var shift = float.Parse(pitchShiftTextBox.Text);
                effect = pitchShiftCheckBox.Checked ? new PitchShiftEffect(shift) : null;
            }
            else
            {
                var lfoFrequency = float.Parse(lfoFreqTextBox.Text);
                var minFrequency = float.Parse(minFreqTextBox.Text);
                var maxFrequency = float.Parse(maxFreqTextBox.Text);
                var q            = float.Parse(lfoQTextBox.Text);
                effect = new PhaserEffect(lfoFrequency, minFrequency, maxFrequency, q);
            }

            _filteredSignal = effect != null?
                              effect.ApplyTo(_signal, FilteringOptions.Auto) :
                                  Operation.TimeStretch(_signal, float.Parse(pitchShiftTextBox.Text));

            signalAfterFilteringPanel.Signal           = _filteredSignal;
            spectrogramAfterFilteringPanel.Spectrogram = _stft.Spectrogram(_filteredSignal.Samples);
        }
Esempio n. 6
0
        private void setEffects()
        {
            //Interactive3DLevel2ReverbEffect en = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(0);
            //EffectsInteractive3DLevel2Reverb enviroEffect = en.AllParameters;
            //enviroEffect.
            //enviroEffects.DecayHfRatio = 2.0f;
            //enviroEffects.DecayTime = 20.0f;
            //enviroEffects.Density = 1.0f;
            //enviroEffects.Diffusion = 2.0f;
            //enviroEffect.Reflections = 1000;
            //en.AllParameters = enviroEffect;
            //return;
            if (Configer.Effects.Count > 0)
            {
                EffectDescription[] effs = new EffectDescription[Configer.Effects.Count];
                for (int i = 0; i < effs.Length; i++)
                {
                    switch (Configer.Effects[i])
                    {
                    case AudioEffects.Chorus: effs[i].GuidEffectClass = DSoundHelper.StandardChorusGuid; break;

                    case AudioEffects.Compressor: effs[i].GuidEffectClass = DSoundHelper.StandardCompressorGuid; break;

                    case AudioEffects.Distortion: effs[i].GuidEffectClass = DSoundHelper.StandardDistortionGuid; break;

                    case AudioEffects.Echo: effs[i].GuidEffectClass = DSoundHelper.StandardEchoGuid; break;

                    case AudioEffects.Flanger: effs[i].GuidEffectClass = DSoundHelper.StandardFlangerGuid; break;

                    case AudioEffects.Gargle: effs[i].GuidEffectClass = DSoundHelper.StandardGargleGuid; break;

                    case AudioEffects.I3DLevel2Reverb: effs[i].GuidEffectClass = DSoundHelper.StandardInteractive3DLevel2ReverbGuid; break;

                    case AudioEffects.ParamEq: effs[i].GuidEffectClass = DSoundHelper.StandardParamEqGuid; break;

                    case AudioEffects.WavesReverb: effs[i].GuidEffectClass = DSoundHelper.StandardWavesReverbGuid; break;

                    default: break;
                    }
                }
                _sound.SetEffects(effs);
                for (int i = 0; i < effs.Length; i++)
                {
                    switch (Configer.Effects[i])
                    {
                    case AudioEffects.Chorus:
                        ChorusEffect  chorus        = (ChorusEffect)_sound.GetEffects(i);
                        EffectsChorus chorus_params = chorus.AllParameters;
                        chorus_params.Delay     = 15.0f;
                        chorus_params.Depth     = ChorusEffect.DepthMax;
                        chorus_params.Phase     = ChorusEffect.PhaseNegative90;
                        chorus_params.Waveform  = ChorusEffect.WaveSin;
                        chorus_params.WetDryMix = 50.0f;
                        chorus.AllParameters    = chorus_params;
                        break;

                    case AudioEffects.Compressor: break;

                    case AudioEffects.Distortion: break;

                    case AudioEffects.Echo:
                        EchoEffect  echo        = (EchoEffect)_sound.GetEffects(i);
                        EffectsEcho echo_params = echo.AllParameters;
                        echo_params.LeftDelay = 0.9f;

                        /*echo_params.RightDelay = 77.0f;
                         * echo_params.Feedback = 9.0f;
                         * echo_params.PanDelay = 1;
                         * echo_params.WetDryMix = 9.0f;
                         * echo.AllParameters = echo_params;*/
                        break;

                    case AudioEffects.Flanger: break;

                    case AudioEffects.Gargle: break;

                    case AudioEffects.I3DLevel2Reverb:
                        Interactive3DLevel2ReverbEffect  env           = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i);
                        EffectsInteractive3DLevel2Reverb enviroEffects = env.AllParameters;
                        //enviroEffects.DecayHfRatio = 2.0f;
                        //enviroEffects.DecayTime = 20.0f;
                        //enviroEffects.Density = 1.0f;
                        //enviroEffects.Diffusion = 2.0f;
                        enviroEffects.Reflections = 1000;
                        //enviroEffects.Reverb = 2;
                        env.AllParameters = enviroEffects;
                        break;

                    case AudioEffects.ParamEq: break;

                    case AudioEffects.WavesReverb: break;

                    default: break;
                    }
                }
            }
        }
Esempio n. 7
0
        private void updateSoundEffects(bool newEffects)
        {
            if (_conf.SoundEffects.Count == 0)
            {
                _conf.SoundEffects[AudioEffects.ParamEq] = 1;
            }

            int  i         = 0;
            bool wasPlayed = _sound.Status.Looping || _sound.Status.Playing;
            bool looped    = _sound.Status.Looping;

            if (newEffects)
            {
                EffectDescription[] effs = new EffectDescription[_conf.SoundEffects.Count];
                foreach (AudioEffects eff in _conf.SoundEffects.Keys)
                {
                    switch (eff)
                    {
                    case AudioEffects.Chorus: effs[i].GuidEffectClass = DSoundHelper.StandardChorusGuid; break;

                    case AudioEffects.Compressor: effs[i].GuidEffectClass = DSoundHelper.StandardCompressorGuid; break;

                    case AudioEffects.Distortion: effs[i].GuidEffectClass = DSoundHelper.StandardDistortionGuid; break;

                    case AudioEffects.Echo: effs[i].GuidEffectClass = DSoundHelper.StandardEchoGuid; break;

                    case AudioEffects.Flanger: effs[i].GuidEffectClass = DSoundHelper.StandardFlangerGuid; break;

                    case AudioEffects.Gargle: effs[i].GuidEffectClass = DSoundHelper.StandardGargleGuid; break;

                    case AudioEffects.I3DLevel2Reverb: effs[i].GuidEffectClass = DSoundHelper.StandardInteractive3DLevel2ReverbGuid; break;

                    case AudioEffects.ParamEq: effs[i].GuidEffectClass = DSoundHelper.StandardParamEqGuid; break;

                    case AudioEffects.WavesReverb: effs[i].GuidEffectClass = DSoundHelper.StandardWavesReverbGuid; break;

                    default: break;
                    }
                    i += 1;
                }
                _sound.Stop();
                _sound.SetEffects(effs);
            }
            i = 0;
            foreach (AudioEffects eff in _conf.SoundEffects.Keys)
            {
                float val = (float)_conf.SoundEffects[eff];
                switch (eff)
                {
                case AudioEffects.Chorus:
                    val += 40;
                    ChorusEffect  chorus        = (ChorusEffect)_sound.GetEffects(i);
                    EffectsChorus chorus_params = chorus.AllParameters;
                    chorus_params.Delay     = 10 + val / (float)10; // 15.0f;
                    chorus_params.Depth     = ChorusEffect.DepthMax - 80 + val;
                    chorus_params.Phase     = ChorusEffect.PhaseNegative180;
                    chorus_params.Waveform  = ChorusEffect.WaveTriangle;
                    chorus_params.WetDryMix = val + val / 5 - 20;    // 50.0f;
                    chorus.AllParameters    = chorus_params;
                    break;

                case AudioEffects.Compressor:
                    //CompressorEffect com = (CompressorEffect)_sound.GetEffects(i);
                    //EffectsCompressor ecom = com.AllParameters;
                    // ecom.Threshold = ((CompressorEffect.ThresholdMax - CompressorEffect.ThresholdMin) / 100) * val;

                    //  com.AllParameters = ecom;
                    break;

                case AudioEffects.Distortion:
                    val += 10;
                    DistortionEffect  dis        = (DistortionEffect)_sound.GetEffects(i);
                    EffectsDistortion dis_params = dis.AllParameters;
                    dis_params.Gain                  = -35 + val;
                    dis_params.Edge                  = val - 5;
                    dis_params.PostEqBandwidth       = (float)(val % 99) * 20 + 2000;
                    dis_params.PostEqCenterFrequency = (float)(val % 99) * 20 + 2000;
                    // dis_params.PreLowpassCutoff = (float)(_conf.SoundEffects[eff] + 1) ;
                    dis.AllParameters = dis_params;
                    break;

                case AudioEffects.Gargle:
                    GargleEffect  gar  = (GargleEffect)_sound.GetEffects(i);
                    EffectsGargle egar = (EffectsGargle)gar.AllParameters;
                    egar.RateHz       = (int)val * 25;
                    gar.AllParameters = egar;

                    break;

                case AudioEffects.Echo:
                    /*Interactive3DLevel2ReverbEffect env1 = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i);
                     * EffectsInteractive3DLevel2Reverb enviroEffects1 = env1.AllParameters;
                     * enviroEffects1.Reflections = 10 * _conf.SoundEffects[eff];
                     * enviroEffects1.Reverb = 2 * _conf.SoundEffects[eff];
                     * enviroEffects1.Diffusion = 0.1f * _conf.SoundEffects[eff];
                     * env1.AllParameters = enviroEffects1;
                     * break;*/
                    EchoEffect  echo        = (EchoEffect)_sound.GetEffects(i);
                    EffectsEcho echo_params = echo.AllParameters;
                    echo_params.LeftDelay  = (_conf.SoundEffects[eff] + 1) * 5; // 250.0f;
                    echo_params.RightDelay = (_conf.SoundEffects[eff] + 1) * 5; // 250.0f;
//echo_params.RightDelay = 1.0f * _conf.SoundEffects[eff];
                    echo_params.Feedback  = val;                                //20;//1  + _conf.SoundEffects[eff] ;// 85.0f;
                    echo_params.PanDelay  = 1;
                    echo_params.WetDryMix = (_conf.SoundEffects[eff]) + 1;
                    echo.AllParameters    = echo_params;
                    break;

                case AudioEffects.Flanger:
                    FlangerEffect  flan  = (FlangerEffect)_sound.GetEffects(i);
                    EffectsFlanger eflan = flan.AllParameters;
                    val += 40;
                    //eflan.Delay = FlangerEffect.DelayMax + 80 - val;
                    eflan.Depth        = FlangerEffect.DepthMax - 80 + val;
                    eflan.Phase        = FlangerEffect.Phase90;
                    eflan.Waveform     = FlangerEffect.WaveTriangle;
                    eflan.WetDryMix    = FlangerEffect.WetDryMixMax - val / 5; // +val / 5 - 20;// 50.0f;
                    flan.AllParameters = eflan;
                    break;

                case AudioEffects.I3DLevel2Reverb:
                    Interactive3DLevel2ReverbEffect  env           = (Interactive3DLevel2ReverbEffect)_sound.GetEffects(i);
                    EffectsInteractive3DLevel2Reverb enviroEffects = env.AllParameters;
                    enviroEffects.DecayHfRatio = 2.0f;
                    enviroEffects.DecayTime    = 20.0f;
                    enviroEffects.Density      = 1.0f;
                    enviroEffects.Diffusion    = 2.0f;
                    enviroEffects.Reflections  = (int)(val / 10);
                    enviroEffects.Reverb       = 2;
                    env.AllParameters          = enviroEffects;
                    break;

                case AudioEffects.ParamEq: break;

                case AudioEffects.WavesReverb:
                    val += 85;
                    WavesReverbEffect  wrev  = (WavesReverbEffect)_sound.GetEffects(i);
                    EffectsWavesReverb ewrev = wrev.AllParameters;
                    //ewrev.ReverbMix = (float)_conf.SoundEffects[eff] / (float)100;
                    ewrev.ReverbTime = val * 20;
                    //ewrev.HighFrequencyRtRatio = (float)val / (float)100;
                    ewrev.ReverbMix = -95.5f + (float)val;    // (val >= 96) ? 0 : val - 96;
                    //MessageBox.Show(String.Format("{0} / {1}, {2} / {3}", WavesReverbEffect.ReverbMixMin, WavesReverbEffect.ReverbTimeMax, WavesReverbEffect.ReverbTimeMin, WavesReverbEffect.ReverbTimeMax));

                    //MessageBox.Show(string.Format("{0} - {1} - {2}", WavesReverbEffect.ReverbTimeMin,WavesReverbEffect.ReverbMixMin, WavesReverbEffect.HighFrequencyRtRatioMin), "");
                    wrev.AllParameters = ewrev;
                    break;

                default: break;
                }
                i += 1;
            }
            if (newEffects && wasPlayed)
            {
                _sound.Play(0, looped ? BufferPlayFlags.Looping : BufferPlayFlags.Default);
            }
        }