void fft::calculateFFT(wavedata &wave){ filldata(wave); fftprocess(); scale(); fftsize=samplerate/2-1; info.clear(); info.append("FFT Process: \ndata[100]: "); info+=QString::number((this->fftdata[100])); info.append("\ndata[200]: "); info+=QString::number((this->fftdata[200])); emit FFTstandbyT(info); emit FFTstandby(*this); }
/** Run the plugin to obtain n_samples of output. * * @param instance A Handler for the LV2 Plugin Instance. * @param n_samples number of samples to operate on. */ void run(LV2_Handle instance, uint32_t n_samples) { Amp *amp = (Amp *) instance; const float *const input = amp->input; float *const output = amp->output; uint32_t io_index = 0; uint32_t readcount; *(amp->latency) = (float) FOURIER_SIZE *2; do { uint32_t bufferlength = (uint32_t) (FOURIER_SIZE - (amp->buffer_index % FOURIER_SIZE)); assert(bufferlength <= FOURIER_SIZE); readcount = n_samples; // make sure to stop at readbuffer lengths if (io_index + readcount > n_samples) { readcount = n_samples - io_index; } // make sure to stop at FOURIER_SIZE lengths if ((amp->buffer_index % FOURIER_SIZE) + readcount > bufferlength) { readcount = bufferlength; } assert(readcount <= FOURIER_SIZE); assert(readcount + (amp->buffer_index % FOURIER_SIZE) <= FOURIER_SIZE); // read input and write output write_buffer(amp->in_buffer, input + io_index, readcount); /* for (i = 0; i < readcount; i++) { in_buffer[(amp->buffer_index + i) % BUFFER_SIZE] = input[io_index + i]; output[io_index + i] = amp->out_buffer[amp->buffer_index + i]; }*/ read_buffer(output + io_index, amp->out_buffer, readcount); if ((amp->buffer_index + readcount) % FOURIER_SIZE == 0) { fftprocess(amp); } amp->buffer_index = (int) (amp->buffer_index + readcount) % BUFFER_SIZE; io_index += readcount; } while (io_index < n_samples); }