Example #1
0
        public static ISampleProvider ApplyEffects(this IWaveProvider waveProvider, Effects.Effect effectsChain)
        {
            if (effectsChain is null || effectsChain is Effects.NoEffect)
            {
                //Bypass conversion
                return(waveProvider.ToSampleProvider());
            }

            return(effectsChain.ApplyEffects(waveProvider.ToBGCStream().EnsureMono()).LimitStream().ToSampleProvider());
        }
        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()}");
        }
Example #3
0
        public static ISampleProvider ApplyMicrophoneEffects(
            this IBGCStream inputStream,
            Config.MicConfiguration micConfig,
            Effects.Effect effectsChain)
        {
            IBGCStream incomingStream = inputStream.EnsureMono();

            if (micConfig.NoiseGateConfiguration.Enabled)
            {
                incomingStream = incomingStream.NoiseGateV2(
                    openThreshold: micConfig.NoiseGateConfiguration.OpenThreshold,
                    closeThreshold: micConfig.NoiseGateConfiguration.CloseThreshold,
                    attackDuration: micConfig.NoiseGateConfiguration.AttackDuration,
                    holdDuration: micConfig.NoiseGateConfiguration.HoldDuration,
                    releaseDuration: micConfig.NoiseGateConfiguration.ReleaseDuration);
            }

            if (micConfig.ExpanderConfiguration.Enabled)
            {
                incomingStream = incomingStream.Expander(
                    ratio: micConfig.ExpanderConfiguration.Ratio,
                    threshold: micConfig.ExpanderConfiguration.Threshold,
                    attackDuration: micConfig.ExpanderConfiguration.AttackDuration,
                    releaseDuration: micConfig.ExpanderConfiguration.ReleaseDuration,
                    outputGain: micConfig.ExpanderConfiguration.OutputGain);
            }

            if (micConfig.CompressorConfiguration.Enabled)
            {
                incomingStream = incomingStream.Compressor(
                    ratio: micConfig.CompressorConfiguration.Ratio,
                    threshold: micConfig.CompressorConfiguration.Threshold,
                    attackDuration: micConfig.CompressorConfiguration.AttackDuration,
                    releaseDuration: micConfig.CompressorConfiguration.ReleaseDuration,
                    outputGain: micConfig.CompressorConfiguration.OutputGain);
            }

            //incomingStream = incomingStream.LimitStream();

            if (effectsChain is null || effectsChain is Effects.NoEffect)
            {
                //Do Nothing
            }