public void NewSample(float sample) { var radFreq = ++i * Math.PI * 2 / Size; var realList = realData.Advance(); // The datapoint that will be changed. var imaginaryList = imaginaryData.Advance(); // By the end of this method, these lists will contain data for the newest sample. for (int k = 0; k < DFTSize; ++k) //Runs through all frequencies. f = samplerate/(2*DFTSize)*k { real[k] -= realList[k]; // Subtracts the now disappearing data. realList[k] = (float)(sample * Math.Cos(k * radFreq)); // Replaces the disappearing data with data from the new sample. real[k] += realList[k]; // Adds the data from the new sample. imaginary[k] -= imaginaryList[k]; imaginaryList[k] = (float)(sample * -Math.Sin(k * radFreq)); imaginary[k] += imaginaryList[k]; } }