for (j = 0; j < f->length; j++) {
energy += SQR (f->data[j]);
}
- return energy;
+ return energy / f->length;
}
smpl_t
smpl_t
aubio_db_spl (fvec_t * o)
{
- smpl_t val = SQRT (fvec_local_energy (o));
- val /= (smpl_t) o->length;
- return LIN2DB (val);
+ return 10. * LOG10 (fvec_local_energy (o));
}
uint_t
/** compute the energy of a vector
- This function compute the sum of the squared elements of a vector.
+ This function compute the sum of the squared elements of a vector, normalised
+ by its length.
\param v vector to get the energy from
for (j = 0; j < newmag->length; j++)
newmag->data[j] = fftgrain->norm[j];
/* detect only if local energy > 10. */
- //if (fvec_local_energy(newmag)>10.) {
+ //if (fvec_local_energy(newmag) * newmag->length > 10.) {
//hfc = fvec_local_hfc(newmag); //not used
aubio_pitchmcomb_spectral_pp (p, newmag);
aubio_pitchmcomb_combdet (p, newmag);
for (j = 0; j < newmag->length; j++)
newmag->data[j] = fftgrain->norm[j];
/* detect only if local energy > 10. */
- if (fvec_local_energy (newmag) > 10.) {
+ if (fvec_local_energy (newmag) * newmag->length > 10.) {
/* hfc = fvec_local_hfc(newmag); do not use */
aubio_pitchmcomb_spectral_pp (p, newmag);
aubio_pitchmcomb_combdet (p, newmag);