UWP EqualizerEffectDefinition没有负收益吗?

问题描述


我为我的一些音乐家朋友建立了一个工具,我想创建一个像spotify has的均衡器。
但是我不能把均衡器的频段增益 到目前为止,我所见过的每个数字均衡器都能够使增益低于0。

我也通常找不到关于Audioeffect属性范围的适当文章:/

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

编辑: 使用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,false); <- Gain = 0 gives error
                    this.setEQBands(1,1,false);
                    this.localSettings.Values["selected EQ"] = "normal";
                    EQnormal.IsChecked = true;
                    break;

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

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

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

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

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

                case "Custom":
                    this.setEQBands(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;
            }
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)