Problem: I'm getting totally different MFCC coefficients for identical and near identical sounds like several finger snaps or several desk taps. What am I missing? I thought since the timbre doesn't really change, the coefficients wouldn't be that much different.

I'm using the aubio library to extract the MFCCs from microphone input, with a 44.1KHz sample rate, 1028 buffer length, and 512 hop size. When an onset is detected in a 512 sample buffer called in, for example, I send in to the MFCC extraction function.

Here's the callback that is called when there's a buffer full of audio ready to be processed:

int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
         double streamTime, RtAudioStreamStatus status, void *userData )
   if (status)
      std::cout << "Stream overflow detected!" << std::endl;

   // Do something with the data in the "inputBuffer" buffer.
   smpl_t * input = (smpl_t *) inputBuffer;

   InputData * data = (InputData *) userData;

   //only hop_size length samples allowed in in->data; must loop to fill bit by bit.
   while (data->offset < 1024) 
      std::copy(input + data->offset, input + data->offset + 511, in->data);


      //do something with the onsets  

      if (out->data[0] != 0) 
         fprintf(stderr, "ONSET DETECTED! \n");

         //compute mag spectrum (pv- phase vocoder obj; in- takes hop_size input; fftgrain- spectrum output.
         aubio_pvoc_do (pv, in, fftgrain); 

         //compute mfccs (mfcc-mfcc object, mfcc_out- 13 MFCC coefficients)
         aubio_mfcc_do(mfcc, fftgrain, mfcc_out);


    data->offset += 512;            

    data->offset = 0;
    if (streamTime > 4) 
       return 1; //abort the stream at 4 seconds

    return 0; //continue normal stream operation
  • $\begingroup$ How you define totally different in case of your MFCC's? Why do you think that finger snap and tapping the desk is same sound? To me it isn't, thus coefficients shouldn't be the same. $\endgroup$ – jojek Mar 11 '15 at 8:12
  • $\begingroup$ @jojek My mistake, I meant to say that the sounds that I repeated were either finger snaps or desk taps. So though I try to snap my finger the same way several times, there are slight changes, so the sounds are near identical, yet it yields coefficients like this: -1.161888 -0.626341 -0.613739 -0.973267 1.470265 -0.401083 0.929119 -0.060884 -0.266733 0.149294 -0.006134 0.050592 AND then this: -0.838373 0.437632 -0.281759 -0.536697 0.855297 0.096851 0.740829 0.012935 -0.275263 -0.109955 -0.063118 0.089827 $\endgroup$ – Andrew B. Mar 12 '15 at 2:32
  • $\begingroup$ There is nie way to say whether these two points in 16 dimensional space are close or not... You don't have any measure to say that. What's more, there is no trivial relation between each coefficient and type of signal. $\endgroup$ – jojek Mar 12 '15 at 7:42
  • $\begingroup$ @jojek Thank you! I'm just learning; I've come so far, so to clarify: Even though I record two finger snaps back to back I shouldn't necessarily expect to receive the same MFCC coefficients for each? How else do I tell that I'm dealing with the same sound? (I just saw you say "please don't try to analyse by eye inspection" on a question I was about to post myself! haha) So how do I know that I've received a match? I must be interpreting MFCCs wrong, because I thought I could just look at the 12 coefficients for both finger snap 1 & 2 and they should look the same. Got any advice or resources? $\endgroup$ – Andrew B. Mar 12 '15 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.