2

我正在尝试做的是从某些歌曲中检索频率并抑制所有未出现在人声范围或一般任何范围内的频率。这是我的抑制功能。

    public void SupressAndWrite(Func<FrequencyUnit, bool> func)
    {
        this.WaveManipulated = true;
        while (this.mainWave.WAVFile.NumSamplesRemaining > 0)
        {
            FrequencyUnit[] freqUnits = this.mainWave.NextFrequencyUnits();

            Complex[] compUnits = (from item
                                   in freqUnits
                                   select (func(item)
                                    ? new Complex(item.Frequency, 0) :Complex.Zero))    
                                   .ToArray();

            FourierTransform.FFT(compUnits, FourierTransform.Direction.Backward);

            short[] shorts = (from item
                              in compUnits
                              select (short)item.Real).ToArray();

            foreach (short item in shorts)
            {
                this.ManipulatedFile.AddSample16bit(item);
            }
        }
        this.ManipulatedFile.Close();
    }

这是我的波浪课。

public sealed class ComplexWave
{
    public readonly WAVFile WAVFile;
    public readonly Int32 SampleSize;

    private FourierTransform.Direction fourierDirection { get; set; }

    private long position;
    /// <param name="file"></param>
    /// <param name="sampleSize in BLOCKS"></param>
    public ComplexWave(WAVFile file, int sampleSize)
    {
        file.NullReferenceExceptionCheck();

        this.WAVFile = file;
        this.SampleSize = sampleSize;

        if (this.SampleSize % 8 != 0)
        {
            if (this.SampleSize % 16 != 0)
            {
                throw new ArgumentException("Sample Size");
            }
        }
        if (!MathTools.IsPowerOf2(sampleSize))
        {
            throw new ArgumentException("Sample Size");
        }
        this.fourierDirection = FourierTransform.Direction.Forward;
    }
    public Complex[] NextSampleFourierTransform()
    {
        short[] newInput = this.GetNextSample();
        Complex[] data = newInput.CopyToComplex();

        if (newInput.Any((x) => x != 0))
        {
            Debug.Write("done");
        }
        FourierTransform.FFT(data, this.fourierDirection);

        return data;
    }
    public FrequencyUnit[] NextFrequencyUnits()
    {
        Complex[] cm = this.NextSampleFourierTransform();
        FrequencyUnit[] freqUn = new FrequencyUnit[(cm.Length / 2)];
        int max = (cm.Length / 2);
        for (int i = 0; i < max; i++)
        {
            freqUn[i] = new FrequencyUnit(cm[i], this.WAVFile.SampleRateHz, i, cm.Length);
        }
        Array.Sort(freqUn);
        return freqUn;
    }
    private short[] GetNextSample()
    {
        short[] retval = new short[this.SampleSize];

        for (int i = 0; i < this.SampleSize; i++)
        {
            if (this.WAVFile.NumSamplesRemaining > 0)
            {
                retval[i] = this.WAVFile.GetNextSampleAs16Bit();
                this.position++;
            }
        }
        return retval;
    }
}

FFT 向前和 FFT 向后都可以正常工作。你能告诉我我的错误是什么吗?

4

1 回答 1

2

不幸的是,即使在唱歌时,人声也不在“频率范围”内。它通常有一个主频率和跟随它的大量谐波,这取决于音素。

使用此https://play.google.com/store/apps/details?id=radonsoft.net.spectralview&hl=en或一些类似的应用程序来了解我的意思 - 然后重新定义您的策略。还有谷歌“卡拉OK”效果。

下一个:

从您的示例中并不明显,但您应该在 Windows 中扫描整个文件(谷歌'fft windowing')以对其进行整体处理。

于 2013-07-28T20:20:12.697 回答