Skip to content

Commit

Permalink
smooth spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanu Frechen committed Feb 14, 2024
1 parent e2d1a42 commit 9d5ecf3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Software/Software.ino
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ unsigned long trigger_time = 0; // time when trigger was set
int input; // serial input
char command[1]; // serial command
float spectrum[1024]; // spectral data
float spectrum_smoothed[1024]={0}; //smoothed spectral data for noise floor
int smooth_n=1000; // number of samples used for smoothing the spectrum
float peak; // highest peak-to-peak distance of the signal (if >= 1 clipping occurs)
uint16_t iq_offset; // offset used for IQ calculation
uint16_t send_min_fft_bin;
Expand Down Expand Up @@ -255,6 +257,11 @@ void loop() {
float* pointer = fft_IQ1024.getData();
for (int kk=0; kk<1024; kk++) spectrum[kk]= *(pointer + kk);

for (i = 0; i < 1024; i++) {
spectrum_smoothed[i] = ((smooth_n-1)*spectrum_smoothed[i] + spectrum[i])/smooth_n;
}
noise_floor = spectrum_smoothed;

// detect highest frequency
max_amplitude = -200.0;
max_freq_Index = 0;
Expand Down

0 comments on commit 9d5ecf3

Please sign in to comment.