Skip to content

Commit

Permalink
Remove averaging
Browse files Browse the repository at this point in the history
  • Loading branch information
duembgen committed Apr 22, 2021
1 parent c9566d7 commit 7cf34bb
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions firmware/audio_shield_firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,14 @@ int main(void) {
// where N is FFTSIZE_SENT-1
uint16_t i_array = 0;
for (int i_fbin = 0; i_fbin < FFTSIZE_SENT; i_fbin++) {
mics_f_sum[i_array] += mic0_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] += mic1_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] += mic2_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] += mic3_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] += mic0_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] += mic1_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] += mic2_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] += mic3_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] = mic0_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] = mic1_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] = mic2_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] = mic3_f[2 * selected_indices[i_fbin]]; i_array += 1;
mics_f_sum[i_array] = mic0_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] = mic1_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] = mic2_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
mics_f_sum[i_array] = mic3_f[2 * selected_indices[i_fbin] + 1]; i_array += 1;
}
f_avg_counter++;
fill_tx_buffer();
Expand Down Expand Up @@ -1168,25 +1168,27 @@ void fill_tx_buffer() {
// the package is not valid.
spi_tx_buffer[SPI_N_BYTES - 1] = 0;

// NOTE: cannot do this inplace because we call fill_tx_buffer
// multiple times on the same buffer.
/*
for (int i = 0; i < 4 * 2 * FFTSIZE_SENT; i++) {
mics_f_sum[i] /= f_avg_counter;
}
memcpy(&spi_tx_buffer, &mics_f_sum, sizeof(mics_f_sum));
*/
memcpy(spi_tx_buffer, mics_f_sum, sizeof(mics_f_sum));
i_array = sizeof(mics_f_sum);

/*
// NOTE: cannot do this inplace because we call fill_tx_buffer
// multiple times on the same buffer.
int i_array = 0;
/*
i_array = 0;
float averaged_value;
for (int i = 0; i < N_MICS * 2 * FFTSIZE_SENT; i++) {
averaged_value = mics_f_sum[i]/f_avg_counter;
memcpy(&spi_tx_buffer[i_array], &averaged_value, sizeof(mics_f_sum[i]));
i_array += sizeof(mics_f_sum[i]);
}
*/
//memcpy(&spi_tx_buffer[0], mics_f_sum, sizeof(mics_f_sum));


// Fill with bins indices
Expand Down

0 comments on commit 7cf34bb

Please sign in to comment.