Commit 02872801 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

divise the result by the number of values (normalize)

parent d8bf8345
......@@ -34,8 +34,6 @@ void spectrum_loop(int period){
blc_fprint_float_graph(stderr, output.floats, output.total_length, "spectrum", columns_nb, rows_nb, 1, 0, "Frequency", "Intensity");
blc_eprint_cursor_up(rows_nb);
}
if (record_file) fprint_tsv_floats(record_file, output.floats, output.total_length);
}
fftwf_destroy_plan(fftw_plan);
blc_eprint_cursor_down(rows_nb);
......@@ -44,13 +42,20 @@ void spectrum_loop(int period){
void standard_loop(int period){
fftwf_plan fftw_plan;
fftw_plan = fftwf_plan_r2r_1d(input.total_length, input.floats, output.floats , FFTW_R2HC, FFTW_ESTIMATE);
float *tmp_values;
tmp_values=fftwf_alloc_real(output.total_length);
fftw_plan = fftwf_plan_r2r_1d(input.total_length, input.floats, tmp_values , FFTW_R2HC, FFTW_ESTIMATE);
BLC_COMMAND_LOOP(period*1000){
fftwf_execute(fftw_plan); /* repeat as needed */
FOR(i, output.total_length){
output.floats[i]=tmp_values[i]/output.total_length;
}
if(display){
blc_fprint_float_graph(stderr, output.floats, output.total_length, "spectrum", columns_nb, rows_nb, 1, 0, "Frequency", "Intensity");
blc_fprint_float_graph(stderr, output.floats, output.total_length, "fft", columns_nb, rows_nb, 1, 0, "real | imaginary", "Intensity");
blc_eprint_cursor_up(rows_nb);
}
}
......@@ -99,9 +104,10 @@ int main(int argc, char**argv){
output.publish();
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
blc_loop_try_add_waiting_semaphore(output.sem_ack_data);
blc_loop_try_add_posting_semaphore(output.sem_new_data);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment