ฉันกำลังทำงานกับเกม platformer ซึ่งรวมถึงเพลงที่มีการตรวจจับจังหวะ ขณะนี้ฉันกำลังตรวจจับการเต้นด้วยการตรวจสอบว่าแอมพลิจูดปัจจุบันเกินกว่าตัวอย่างในอดีตหรือไม่ มันใช้งานไม่ได้กับแนวเพลงเช่นร็อคที่มีแอมพลิจูดค่อนข้างคงที่
ดังนั้นฉันจึงค้นหาเพิ่มเติมและพบอัลกอริทึมที่แยกเสียงออกเป็นหลาย ๆ วงโดยใช้ FFT ... จากนั้นฉันก็พบอัลกอริทึม Cooley-Tukey FFt
ปัญหาเดียวที่ฉันมีคือฉันค่อนข้างใหม่กับเสียงและฉันไม่รู้ว่าจะใช้มันอย่างไรเพื่อแยกสัญญาณออกเป็นสัญญาณหลาย ๆ สัญญาณ
ดังนั้นคำถามของฉันคือ:
คุณจะใช้ FFT เพื่อแยกสัญญาณออกเป็นหลายแบนด์ได้อย่างไร?
สำหรับคนที่สนใจนี่คืออัลกอริทึมของฉันใน c #:
// C = threshold, N = size of history buffer / 1024
    public void PlaceBeatMarkers(float C, int N)
    {
        List<float> instantEnergyList = new List<float>();
        short[] samples = soundData.Samples;
        float timePerSample = 1 / (float)soundData.SampleRate;
        int sampleIndex = 0;
        int nextSamples = 1024;
        // Calculate instant energy for every 1024 samples.
        while (sampleIndex + nextSamples < samples.Length)
        {
            float instantEnergy = 0;
            for (int i = 0; i < nextSamples; i++)
            {
                instantEnergy += Math.Abs((float)samples[sampleIndex + i]);
            }
            instantEnergy /= nextSamples;
            instantEnergyList.Add(instantEnergy);
            if(sampleIndex + nextSamples >= samples.Length)
                nextSamples = samples.Length - sampleIndex - 1;
            sampleIndex += nextSamples;
        }
        int index = N;
        int numInBuffer = index;
        float historyBuffer = 0;
        //Fill the history buffer with n * instant energy
        for (int i = 0; i < index; i++)
        {
            historyBuffer += instantEnergyList[i];
        }
        // If instantEnergy / samples in buffer < instantEnergy for the next sample then add beatmarker.
        while (index + 1 < instantEnergyList.Count)
        {
            if(instantEnergyList[index + 1] > (historyBuffer / numInBuffer) * C)
                beatMarkers.Add((index + 1) * 1024 * timePerSample); 
            historyBuffer -= instantEnergyList[index - numInBuffer];
            historyBuffer += instantEnergyList[index + 1];
            index++;
        }
    }