public void UpdateVoiceEffect(Effects.Effect effect)
        {
            if (effect is null)
            {
                effect = new Effects.NoEffect();
            }

            currentEffect = effect;

            //Get the PitchShiftEffect, if any
            lastPitchShiftEffect = effect.GetEffects().OfType <Effects.PitchShiftEffect>().FirstOrDefault();

            ResetVoiceStream();

            communication.SendDebugMessage($"New Voice Effect: {effect.GetEffectsChain()}");
        }
        public bool TryParse(string effectsChain, out Effect effect, out string errorMessage)
        {
            effect       = null;
            errorMessage = null;

            if (string.IsNullOrWhiteSpace(effectsChain))
            {
                effect = new NoEffect();
                return(true);
            }

            effectsChain = effectsChain.Trim().ToLowerInvariant();

            string[] splitChain = effectsChain.Split(',', StringSplitOptions.RemoveEmptyEntries);

            if (splitChain.Length == 0 || (splitChain.Length == 1 && splitChain[0] == "none"))
            {
                effect = new NoEffect();
                return(true);
            }

            try
            {
                foreach (string effectString in splitChain)
                {
                    string[] splitEffect = effectString.Split(' ', StringSplitOptions.RemoveEmptyEntries);

                    if (!effectHandlers.ContainsKey(splitEffect[0]))
                    {
                        throw new EffectParsingException($"Unexpected effect name: {splitEffect[0]}");
                    }

                    effect = effectHandlers[splitEffect[0]](splitEffect, effect);
                }
            }
            catch (EffectParsingException effectParsingException)
            {
                communication.SendWarningMessage(effectParsingException.ErrorMessage);
                effect       = new NoEffect();
                errorMessage = effectParsingException.ErrorMessage;

                return(false);
            }

            return(true);
        }