首页 > 解决方案 > UWP EqualizerEffectDefinition 没有负增益?

问题描述


我正在为我的一些音乐家朋友构建一个工具,我想创建一个像 spotify 这样的均衡器。
但我不能把均衡器的频带增益到目前为止我见过的每个数字均衡器都能把增益设置在 0 以下。

我也找不到关于一般音频效果属性范围的正确文章:/

希望你们中的一些人可以帮助我。

编辑:使用 EqualizerEffectDefinition 的代码:

在 AudioGraph 的初始化之后,我初始化了 eq

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

我使用 3 个 EqualizerEffectDefinitions,因为 1 个仅包含 4 个频段。


在初始化 deviceOutputNode 之后,我添加并启用它们

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);




在这里,我想在预定义的 EQ 和自定义的 EQ 之间进行选择

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;
            }
        }

标签: c#uwpequalizer

解决方案


推荐阅读