Skip to content

Commit

Permalink
Fix final fft result not being set to zeroes on init
Browse files Browse the repository at this point in the history
Since we use the previous value for averaging over time if the initial
value is unitialized memory we will get undefined values for first sample.
  • Loading branch information
HunterWhyte committed Jan 6, 2023
1 parent b3afde2 commit 85fe539
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions jumaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ ma_int32 jum_startPlayback(jum_AudioSetup* setup, const char* filepath, ma_int32
}
}

printf("Starting playback of '%s', on device [%d]'%s'\n", filepath, device_index, selected_device_name);
printf("Starting playback of '%s', on device [%d]'%s'\n", filepath, device_index,
selected_device_name);
jum_printAudioInfo(setup->info);
#endif

Expand Down Expand Up @@ -520,9 +521,9 @@ jum_FFTSetup* jum_initFFT(const float freq_points[][2], ma_int32 freqs_sz,
jum_FFTSetup* setup = (jum_FFTSetup*)malloc(sizeof(jum_FFTSetup));

initPFFFT(&setup->pffft, fft_sz);
setup->raw = (float*)malloc(num_bins * sizeof(float));
setup->averaged = (float*)malloc(num_bins * sizeof(float));
setup->result = (float*)malloc(num_bins * sizeof(float));
setup->raw = (float*)calloc(num_bins, sizeof(float));
setup->averaged = (float*)calloc(num_bins, sizeof(float));
setup->result = (float*)calloc(num_bins, sizeof(float));

setup->luts.freqs = (float*)malloc(num_bins * sizeof(float));
buildFreqTable(setup->luts.freqs, num_bins, freq_points, freqs_sz);
Expand Down

0 comments on commit 85fe539

Please sign in to comment.