1

im building a tool for some musician friends of mine and i wanted to create an equalizer like spotify has.
But i cant put the Band Gain of the equalizer Every digital equalizer i've seen so far was able to put the Gain below 0.

I also can't really find a properly article about the ranges of the Audioeffect properties in general :/

Hopefully some of you guys can help me out.

Edit: The Code where the EqualizerEffectDefinition is used:

After the init of the AudioGraph i init the eq

            this.equalizerLowFreq = new EqualizerEffectDefinition(this.audioGraph);
            this.equalizerMidFreq = new EqualizerEffectDefinition(this.audioGraph);
            this.equalizerHighFreq = new EqualizerEffectDefinition(this.audioGraph);

i use 3 EqualizerEffectDefinitions because 1 only holds 4 Bands.


Right after init the deviceOutputNode i add and enable them

this.deviceOutputNode.EffectDefinitions.Add(this.equalizerLowFreq);
            this.deviceOutputNode.EffectDefinitions.Add(this.equalizerMidFreq);
            this.deviceOutputNode.EffectDefinitions.Add(this.equalizerHighFreq);
            this.deviceOutputNode.EnableEffectsByDefinition(this.equalizerLowFreq);
            this.deviceOutputNode.EnableEffectsByDefinition(this.equalizerMidFreq);
            this.deviceOutputNode.EnableEffectsByDefinition(this.equalizerHighFreq);




And here i wanna choose between predefined EQs and a custom one

private void chooseEQ(string EQ)
        {
            // switch back old EQ button
            switch (this.localSettings.Values["selected EQ"].ToString())
            {
                case "Normal":
                    EQNormal.IsChecked = false;
                    break;

                case "Pop":
                    EQPop.IsChecked = false;
                    break;

                case "Classic":
                    EQClassic.IsChecked = false;
                    break;

                case "Jazz":
                    EQJazz.IsChecked = false;
                    break;

                case "Rock":
                    EQRock.IsChecked = false;
                    break;

                case "Party":
                    EQParty.IsChecked = false;
                    break;

                case "Custom":
                    EQCustom.IsChecked = false;
                    break;
            }

            // set EQ
            switch (EQ)
            {
                case "Normal":
                    //this.setEQBands(0, 0, 0, 0, 0, 0, 0, 0, 0, false); <- Gain = 0 gives error
                    this.setEQBands(1, 1, 1, 1, 1, 1, 1, 1, 1, false);
                    this.localSettings.Values["selected EQ"] = "Normal";
                    EQNormal.IsChecked = true;
                    break;

                case "Pop":
                    this.setEQBands(0, 0, 0, 2, 3, -2, -4, -4, -4, false);
                    this.localSettings.Values["selected EQ"] = "Pop";
                    EQPop.IsChecked = true;
                    break;

                case "Classic":
                    this.setEQBands(0, 0, -6, 0, 1, 0, 6, 6, 6, false);
                    this.localSettings.Values["selected EQ"] = "Classic";
                    EQClassic.IsChecked = true;
                    break;

                case "Jazz":
                    this.setEQBands(0, 0, 5, -5, -2, 2, -1, -1, -1, false);
                    this.localSettings.Values["selected EQ"] = "Jazz";
                    EQJazz.IsChecked = true;
                    break;

                case "Rock":
                    this.setEQBands(0, 0, 3, -9, -2, 3, 3, 3, 3, false);
                    this.localSettings.Values["selected EQ"] = "Rock";
                    EQRock.IsChecked = true;
                    break;

                case "Party":
                    this.setEQBands(8, 6, 3, 0, -3, -1, 1, 5, 9, false);
                    this.localSettings.Values["selected EQ"] = "Party";
                    EQParty.IsChecked = true;
                    break;

                case "Custom":
                    this.setEQBands(0, 0, 0, 0, 0, 0, 0, 0, 0, true);
                    this.localSettings.Values["selected EQ"] = "Custom";
                    EQCustom.IsChecked = true;
                    break;
            }
        }

        private void setEQBands(int low1, int low2, int low3, int mid1, int mid2, int mid3, int high1, int high2, int high3, bool isCustomEQ)
        {
            if (isCustomEQ)
            {
                this.equalizerLowFreq.Bands[0].Gain = this.customEQ63HzGain;
                EQ63HzSlider.Value = this.customEQ63HzGain;
                this.equalizerLowFreq.Bands[1].Gain = this.customEQ125HzGain;
                EQ125HzSlider.Value = this.customEQ125HzGain;
                this.equalizerLowFreq.Bands[2].Gain = this.customEQ250HzGain;
                EQ250HzSlider.Value = this.customEQ250HzGain;

                this.equalizerMidFreq.Bands[0].Gain = this.customEQ500HzGain;
                EQ500HzSlider.Value = this.customEQ500HzGain;
                this.equalizerMidFreq.Bands[1].Gain = this.customEQ1kHzGain;
                EQ1kHzSlider.Value = this.customEQ500HzGain;
                this.equalizerMidFreq.Bands[2].Gain = this.customEQ2kHzGain;
                EQ2kHzSlider.Value = this.customEQ500HzGain;

                this.equalizerHighFreq.Bands[0].Gain = this.customEQ4kHzGain;
                EQ4kHzSlider.Value = this.customEQ500HzGain;
                this.equalizerHighFreq.Bands[1].Gain = this.customEQ8kHzGain;
                EQ8kHzSlider.Value = this.customEQ500HzGain;
                this.equalizerHighFreq.Bands[2].Gain = this.customEQ16kHzGain;
                EQ16kHzSlider.Value = this.customEQ500HzGain;
            }
            else
            {
                this.equalizerLowFreq.Bands[0].Gain = low1;
                EQ63HzSlider.Value = low1;
                this.equalizerLowFreq.Bands[1].Gain = low2;
                EQ125HzSlider.Value = low2;
                this.equalizerLowFreq.Bands[2].Gain = low3;
                EQ250HzSlider.Value = low3;

                this.equalizerMidFreq.Bands[0].Gain = mid1;
                EQ500HzSlider.Value = mid1;
                this.equalizerMidFreq.Bands[1].Gain = mid2;
                EQ1kHzSlider.Value = mid2;
                this.equalizerMidFreq.Bands[2].Gain = mid3;
                EQ2kHzSlider.Value = mid3;

                this.equalizerHighFreq.Bands[0].Gain = high1;
                EQ4kHzSlider.Value = high1;
                this.equalizerHighFreq.Bands[1].Gain = high2;
                EQ8kHzSlider.Value = high2;
                this.equalizerHighFreq.Bands[2].Gain = high3;
                EQ16kHzSlider.Value = high3;
            }
        }
  • Please post some code – Prisoner ZERO Aug 14 '20 at 15:15
  • i added some code @PrisonerZERO – Nico Eggers Aug 14 '20 at 15:35
  • Do you mean you want to set a negative value for the Band Gain of EqualizerEffectDefinition? Have you received any exceptions? Can you provide more details about your expected behavior and unexpected behavior? – Faywang - MSFT Aug 17 '20 at 05:03
  • Yeah, as reference i used Equalizers like for example spotify has, where you can set the Band from -10dB to 10dB. So i expected to set the Gain to 0 with a range from -10 to 10 for set the equalizer how one wants. I tried a bit out at the weekend and found out that every value <= 0 or >=8 throws the exception "Value does not fall within the expected range." How am i supposed to make a properly working EQ from -10 to 10? – Nico Eggers Aug 17 '20 at 10:49
  • Based on the [AudioGraph sample](https://learn.microsoft.com/en-us/samples/microsoft/windows-universal-samples/audiocreation/), you can check this [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.xapofx.fxeq_parameters(v=vs.85).aspx) page for parameter explanations. Gain must be between FXEQ_MIN_GAIN and FXEQ_MAX_GAIN, the FXEQ_MIN_GAIN is defined 0.126 and FXEQ_MAX_GAIN is defined 7.94, so you can not set the Gain with a range from -10 to 10. – Faywang - MSFT Aug 18 '20 at 07:20
  • Thank you @Faywang-MSFT i would never found that. when i manage the UWP to not say "Value does not fall within expected Range" when i first fill the gain with a value in the range, i tryout how to make a properly working EQ and will post it here how i made it (for other people that may have the same struggle) – Nico Eggers Aug 28 '20 at 12:09

0 Answers0