src/mathutils.h: move fvec_local_energy to aubio_level_lin, move to musicutils.h
authorPaul Brossier <piem@piem.org>
Sun, 17 Nov 2013 17:23:34 +0000 (18:23 +0100)
committerPaul Brossier <piem@piem.org>
Sun, 17 Nov 2013 17:23:34 +0000 (18:23 +0100)
examples/aubiopitch.c
src/mathutils.c
src/mathutils.h
src/musicutils.h
src/pitch/pitchmcomb.c

index 078f125..fcffce6 100644 (file)
@@ -40,8 +40,7 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) {
       /* block loop */
       aubio_pitch_do (o, ibuf, pitch);
       smpl_t freq = fvec_read_sample(pitch, 0);
-      smpl_t amp = powf(10., aubio_db_spl(ibuf)*.05 );
-      aubio_wavetable_set_amp ( wavetable, amp );
+      aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
       if (freq != 0.0) {
         aubio_wavetable_set_freq ( wavetable, freq );
       } else {
index 812e297..86d8f1a 100644 (file)
@@ -263,7 +263,7 @@ fvec_shift (fvec_t * s)
 }
 
 smpl_t
-fvec_local_energy (fvec_t * f)
+aubio_level_lin (fvec_t * f)
 {
   smpl_t energy = 0.;
   uint_t j;
@@ -508,7 +508,7 @@ aubio_next_power_of_two (uint_t a)
 smpl_t
 aubio_db_spl (fvec_t * o)
 {
-  return 10. * LOG10 (fvec_local_energy (o));
+  return 10. * LOG10 (aubio_level_lin (o));
 }
 
 uint_t
index 913c6d7..d9b6042 100644 (file)
@@ -108,18 +108,6 @@ void fvec_shift (fvec_t * v);
 */
 smpl_t fvec_sum (fvec_t * v);
 
-/** compute the energy 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 
-
-  \return the energy of v
-*/
-smpl_t fvec_local_energy (fvec_t * v);
-
 /** compute the High Frequency Content of a vector
 
   The High Frequency Content is defined as \f$ \sum_0^{N-1} (k+1) v[k] \f$.
index 8ad29f0..4c823fd 100644 (file)
@@ -100,10 +100,23 @@ void aubio_cleanup (void);
 */
 smpl_t aubio_zero_crossing_rate (fvec_t * v);
 
+/** compute sound level on a linear
+
+  This gives the average of the square amplitudes.
+
+  \param v vector to compute dB SPL from
+
+  \return level of v
+
+*/
+smpl_t aubio_level_lin (fvec_t * v);
+
 /** compute sound pressure level (SPL) in dB
 
   This quantity is often wrongly called 'loudness'.
 
+  This gives ten times the log10 of the average of the square amplitudes.
+
   \param v vector to compute dB SPL from
 
   \return level of v in dB SPL
index 3425aa0..fee030e 100644 (file)
@@ -111,7 +111,7 @@ aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output)
   for (j = 0; j < newmag->length; j++)
     newmag->data[j] = fftgrain->norm[j];
   /* detect only if local energy > 10. */
-  //if (fvec_local_energy(newmag) * newmag->length > 10.) {
+  //if (aubio_level_lin (newmag) * newmag->length > 10.) {
   //hfc = fvec_local_hfc(newmag); //not used
   aubio_pitchmcomb_spectral_pp (p, newmag);
   aubio_pitchmcomb_combdet (p, newmag);
@@ -146,7 +146,7 @@ aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands)
   for (j = 0; j < newmag->length; j++)
     newmag->data[j] = fftgrain->norm[j];
   /* detect only if local energy > 10. */
-  if (fvec_local_energy (newmag) * newmag->length > 10.) {
+  if (aubio_level_lin (newmag) * newmag->length > 10.) {
     /* hfc = fvec_local_hfc(newmag); do not use */
     aubio_pitchmcomb_spectral_pp (p, newmag);
     aubio_pitchmcomb_combdet (p, newmag);