Skip to content

Commit

Permalink
Fix bug in ZCR final calculation performed as int instead of float.
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-carlos committed Oct 25, 2024
1 parent d0c9552 commit f34b52a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mlrunner/mldataprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ MldpReturn_t filterMean(const float *data_in, const int in_size, float *data_out
for (int i = 0; i < in_size; i++) {
sum += data_in[i];
}
*data_out = sum / in_size;
*data_out = sum / (float)in_size;

return MLDP_SUCCESS;
}
Expand All @@ -74,7 +74,7 @@ MldpReturn_t filterStdDev(const float *data_in, const int in_size, float *data_o
f = data_in[i] - mean;
std += f * f;
}
std /= in_size;
std /= (float)in_size;
*data_out = sqrtf(std);

return MLDP_SUCCESS;
Expand Down Expand Up @@ -173,7 +173,7 @@ MldpReturn_t filterZcr(const float *data_in, const int in_size, float *data_out,
count++;
}
}
*data_out = count / (in_size - 1);
*data_out = (float)count / (float)(in_size - 1);

return MLDP_SUCCESS;
}
Expand All @@ -188,7 +188,7 @@ MldpReturn_t filterRms(const float *data_in, const int in_size, float *data_out,
for (int i = 0; i < in_size; i++) {
rms += data_in[i] * data_in[i];
}
*data_out = sqrtf(rms / in_size);
*data_out = sqrtf(rms / (float)in_size);

return MLDP_SUCCESS;
}
Expand Down

0 comments on commit f34b52a

Please sign in to comment.