private void FormMain_Load(object sender, EventArgs e) { _waveformBitmap = new DirectBitmap(pictureBoxWaveform.Width, pictureBoxWaveform.Height); _spectrumBitmap = new DirectBitmap(pictureBoxRealtimeSpectrum.Width, pictureBoxRealtimeSpectrum.Height); _volumeBitmap = new DirectBitmap(pictureBoxVolume.Width, pictureBoxVolume.Height); _trueVolumeProvider = new TrueVolumeProvider(); SetPlayerProvider(); SetFFTProvider(); SetVolumeDrawer(); SetSpectrumDrawer(); FileLoader.OnBeginMp3Decompression += () => { SetLabelStatusText("Begin Mp3 Decompression"); }; FileLoader.OnBeginWavWriting += () => { SetLabelStatusText("Begin Wav Writing"); }; Application.Idle += OnApplicationIdle; //выводим коэффициенты на форму numericUpDownEasing.Value = (int)(EasingCoef * 10); numericUpDownPow2Spectrum.Value = FastPowLog2Provider.FastLog2(SpectrumUseSamples); trackBarTrimFrequency.Value = TrimFrequency; checkBoxApplyTimeThinning.Checked = ApplyTimeThinning; labelMaxFrequency.Text = "Max Frequency: " + TrimFrequency; }
protected override void Algorithm() { int power = FastPowLog2Provider.FastLog2(Samples); int middle = Samples >> 1; int j = 0; for (int i = 0; i < Samples - 1; i++) { if (i < j) { var tmp = ValuesBuffer[i]; ValuesBuffer[i] = ValuesBuffer[j]; ValuesBuffer[j] = tmp; } int k = middle; while (k <= j) { j -= k; k >>= 1; } j += k; } r.Re = -1; r.Im = 0; int l2 = 1; for (int l = 0; l < power; l++) { int l1 = l2; l2 <<= 1; r2.Re = 1; r2.Im = 0; for (int n = 0; n < l1; n++) { for (int i = n; i < Samples; i += l2) { int i1 = i + l1; Complex tmp = r2 * ValuesBuffer[i1]; ValuesBuffer[i1] = ValuesBuffer[i] - tmp; ValuesBuffer[i] += tmp; } r2 = r2 * r; } r.Im = -Math.Sqrt((1 - r.Re) / 2d); r.Re = Math.Sqrt((1 + r.Re) / 2d); } }
private void InitAllCache() { int base2 = FastPowLog2Provider.FastLog2(Samples); _cacheLevels = new Complex[base2 + 1][]; int samples = Samples; while (base2 > 0) { Complex[] cache = new Complex[samples]; for (int i = 0; i < samples; i++) { cache[i] = W(i, samples); } _cacheLevels[base2] = cache; base2--; samples /= 2; } }
protected override Complex W(int x, int n) { int base2 = FastPowLog2Provider.FastLog2(n); return(_cacheLevels[base2][x]); }