コード例 #1
0
        public void ApplyEffects(SecondarySoundBuffer ab)
        {
            var boxes = new CheckBox[] {
                ChorusCheckBox,
                CompressorCheckBox,
                DistortionCheckBox,
                EchoCheckBox,
                FlangerCheckBox,
                GargleCheckBox,
                ParamEqCheckBox,
                ReverbCheckBox,
                Reverb3dCheckBox,
            };
            var effects = new List <Guid>();

            // Create array of enabled effects.
            if (ChorusCheckBox.Checked)
            {
                effects.Add(StandardChorusGuid);
            }
            if (CompressorCheckBox.Checked)
            {
                effects.Add(StandardCompressorGuid);
            }
            if (DistortionCheckBox.Checked)
            {
                effects.Add(StandardDistortionGuid);
            }
            if (EchoCheckBox.Checked)
            {
                effects.Add(StandardEchoGuid);
            }
            if (FlangerCheckBox.Checked)
            {
                effects.Add(StandardFlangerGuid);
            }
            if (GargleCheckBox.Checked)
            {
                effects.Add(StandardGargleGuid);
            }
            if (ParamEqCheckBox.Checked)
            {
                effects.Add(StandardParamEqGuid);
            }
            if (ReverbCheckBox.Checked)
            {
                effects.Add(StandardWavesReverbGuid);
            }
            if (Reverb3dCheckBox.Checked)
            {
                effects.Add(StandardI3DL2ReverbGuid);
            }
            // Set effects.
            if (effects.Count == 0)
            {
                return;
            }
            ab.SetEffect(effects.ToArray());
            int index;

            if (ChorusCheckBox.Checked)
            {
                index = effects.IndexOf(StandardChorusGuid);
                var chorus           = ab.GetEffect <Chorus>(index);
                var chorusParamaters = chorus.AllParameters;
                ApplyChorusEffect(ref chorusParamaters);
                chorus.AllParameters = chorusParamaters;
            }
            if (CompressorCheckBox.Checked)
            {
                index = effects.IndexOf(StandardCompressorGuid);
                var compressor           = ab.GetEffect <Compressor>(index);
                var compressorParamaters = compressor.AllParameters;
                ApplyCompressorEffect(ref compressorParamaters);
                compressor.AllParameters = compressorParamaters;
            }
            if (DistortionCheckBox.Checked)
            {
                index = effects.IndexOf(StandardDistortionGuid);
                var distortion           = ab.GetEffect <Distortion>(index);
                var distortionParamaters = distortion.AllParameters;
                ApplyDistortionEffect(ref distortionParamaters);
                distortion.AllParameters = distortionParamaters;
            }
            if (EchoCheckBox.Checked)
            {
                index = effects.IndexOf(StandardEchoGuid);
                var echo           = ab.GetEffect <Echo>(index);
                var echoParamaters = echo.AllParameters;
                ApplyEchoEffect(ref echoParamaters);
                echo.AllParameters = echoParamaters;
            }
            if (FlangerCheckBox.Checked)
            {
                index = effects.IndexOf(StandardFlangerGuid);
                var flanger           = ab.GetEffect <Flanger>(index);
                var flangerParamaters = flanger.AllParameters;
                ApplyFlangerEffect(ref flangerParamaters);
                flanger.AllParameters = flangerParamaters;
            }
            if (GargleCheckBox.Checked)
            {
                index = effects.IndexOf(StandardGargleGuid);
                var gargle           = ab.GetEffect <Gargle>(index);
                var gargleParamaters = gargle.AllParameters;
                ApplyGargleEffect(ref gargleParamaters);
                gargle.AllParameters = gargleParamaters;
            }
            if (ParamEqCheckBox.Checked)
            {
                index = effects.IndexOf(StandardParamEqGuid);
                var paramEq           = ab.GetEffect <ParametricEqualizer>(index);
                var paramEqParamaters = paramEq.AllParameters;
                ApplyParamEqEffect(ref paramEqParamaters);
                paramEq.AllParameters = paramEqParamaters;
            }
            if (ReverbCheckBox.Checked)
            {
                index = effects.IndexOf(StandardWavesReverbGuid);
                var reverb           = ab.GetEffect <WavesReverb>(index);
                var reverbParamaters = reverb.AllParameters;
                ApplyReverbEffect(ref reverbParamaters);
                reverb.AllParameters = reverbParamaters;
            }
            if (Reverb3dCheckBox.Checked)
            {
                index = effects.IndexOf(StandardI3DL2ReverbGuid);
                var reverb3D           = ab.GetEffect <I3DL2Reverb>(index);
                var reverb3DParamaters = reverb3D.AllParameters;
                ApplyReverb3dEffect(ref reverb3DParamaters);
                reverb3D.AllParameters = reverb3DParamaters;
            }
        }