如何消除静态背景噪音?

时间:2019-04-02 14:05:01

标签: c# naudio noise

我正在使用NAudio BiQuadFilter播放Wav文件。我要消除“静态”背景噪音,这些低隆隆声不是人的言语。我创建了一条通过BiQuadFilter传递的DSP链。我为滤波器提供了许多不同的增益和频率,同时保持带宽不变。我可以降低静电,但声音也会降低。如何在不影响人声的情况下仅隔离静态噪声。如果您能指出正确的方向,那就太好了! (我已经失去了研究的一天。)

我创建了8个频段,并将频率设置为100、300、400、500、800、1200、4800、9600等值;将增益设置为-6到-100之间的值;保持带宽为.8。

我还尝试仅使用1个频段,并以1300为目标,以-30为增益。

Bands = {New EqualizerBand(), New EqualizerBand(), New EqualizerBand(), 
         New EqualizerBand(), New EqualizerBand(), New 
             EqualizerBand(), New EqualizerBand(), New EqualizerBand()}

Bands(0).Bandwidth = 0.8F
 Bands(0).Gain = -6
 Bands(0).Frequency = 100

 Bands(1).Bandwidth = 0.8F
 Bands(1).Gain = -6
 Bands(1).Frequency = 300

 Bands(2).Bandwidth = 0.8F
 Bands(2).Gain = -6
 Bands(2).Frequency = 400

 Bands(3).Bandwidth = 0.8F
 Bands(3).Gain = -6
 Bands(3).Frequency = 500

 Bands(4).Bandwidth = 0.8F
 Bands(4).Gain = -6
 Bands(4).Frequency = 800

 Bands(5).Bandwidth = 0.8F
 Bands(5).Gain = -6
 Bands(5).Frequency = 1200

 Bands(6).Bandwidth = 0.8F
 Bands(6).Gain = -6
 Bands(6).Frequency = 4800

 Bands(7).Bandwidth = 0.8F
 Bands(7).Gain = -6
 Bands(7).Frequency = 9600


  AudioFileReader1 = New AudioFileReader(Me.FilePath)
  Equalizer1 = New EqualizerClass(AudioFileReader1, Bands)
  SpeedControl = New VarispeedSampleProvider(Equalizer1, 100, New 
                 SoundTouchProfile(False, False))
  SpeedControl.PlaybackRate = 1
  VolumeSampleProvider1 = New VolumeSampleProvider(SpeedControl)

Here's the ISampleProvider, which is from this example: https://github.com/naudio/NAudio/tree/master/NAudioWpfDemo/EqualizationDemo 


namespace Equalizer
{
    /// <summary>
    /// Basic example of a multi-band eq
    /// uses the same settings for both channels in stereo audio
    /// Call Update after you've updated the bands
    /// Potentially to be added to NAudio in a future version
    /// </summary>
    public class EqualizerClass : ISampleProvider
    {
        private readonly ISampleProvider sourceProvider;
        private readonly EqualizerBand[] bands;
        private readonly BiQuadFilter[,] filters;
        private readonly int channels;
        private readonly int bandCount;
        private bool updated;

        public EqualizerClass(ISampleProvider sourceProvider, EqualizerBand[] bands)
        {
            this.sourceProvider = sourceProvider;
            this.bands = bands;
            channels = sourceProvider.WaveFormat.Channels;
            bandCount = bands.Length;
            filters = new BiQuadFilter[channels, bands.Length];
            CreateFilters();
        }

        private void CreateFilters()
        {
            for (int bandIndex = 0; bandIndex < bandCount; bandIndex++)
            {
                var band = bands[bandIndex];

                for (int n = 0; n < channels; n++)
                {
                    if (filters[n, bandIndex] == null)
                        filters[n, bandIndex] = BiQuadFilter.PeakingEQ(sourceProvider.WaveFormat.SampleRate, band.Frequency, band.Bandwidth, band.Gain);
                    else
                        filters[n, bandIndex].SetPeakingEq(sourceProvider.WaveFormat.SampleRate, band.Frequency, band.Bandwidth, band.Gain);
                }
            }
        }

        public void Update()
        {
            updated = true;
            CreateFilters();
        }

        public WaveFormat WaveFormat => sourceProvider.WaveFormat;

        public int Read(float[] buffer, int offset, int count)
        {
            int samplesRead = sourceProvider.Read(buffer, offset, count);

            if (updated)
            {
                CreateFilters();
                updated = false;
            }

            for (int n = 0; n < samplesRead; n++)
            {
                int ch = n % channels;

                for (int band = 0; band < bandCount; band++)
                {
                    buffer[offset + n] = filters[ch, band].Transform(buffer[offset + n]);
                }
            }
            return samplesRead;
        }
    }
}

我期望,当消除较低的频率范围(100-500)时,我应该摆脱“静态”背景噪音,并且仍能听到用户的声音。实际发生的是,语音和“静态”背景噪音都降低了。

0 个答案:

没有答案