I call AudioLocalMeasurements as follows:

AudioLocalMeasurements[audio, {"MFCC", 13, 26, 300, 6000},
PartitionGranularity -> {Quantity[25, "ms"], Quantity[25, "ms"]}][

where the duration of 'audio' is exactly 25ms. I get back two (different) MFCC frames rather than one which I expected.

I might note in passing that if I implement the MFCC computation using more basic Mathematica routines (PeriodogramArray, FourierDCT, etc.) I am unable to reproduce either of the two that AudioLocalMeasurements returns but that may be because of undocumented transformations taking place inside AudioLocalMeasurements such as a default windowing and liftering.


There seem to be two things between you and your expected result:

  1. You are getting one more window than you expect.
  2. You aren't sure what windowing is done.

1: You are seeing two MFCC frames returned because there is a non-zero Automatic PaddingSize.

It sounds like you expected the first window to begin at time 0, and the next window to look to start at 25 ms, where it would find no more audio left.

Let's use "Power" measurements since their values are just a single real to see what padding size does.

aud = Audio[RandomReal[{-1, 1}, 2205], SampleRate -> 88200];
AudioLocalMeasurements[aud, "Power", PartitionGranularity -> {Quantity[25, "ms"], Quantity[25, "ms"]}, Alignment -> Left]["Path"]

returns: (with variation from the random aud generation)

{{-0.0125, 0.160936}, {0.0125, 0.169722}}

The times are the interesting bit; your first window's earliest point is padded values from -12.5 ms.

To get your expected result without padding, you can use:

AudioLocalMeasurements[aud, "Power", PartitionGranularity -> {Quantity[25, "ms"], Quantity[25, "ms"]}, PaddingSize -> 0]["Path"]


{{0.0125, 0.330658}}

2: The default PartitionGranularity is listed as Automatic, but we can see with:

AudioLocalMeasurements[aud, "MFCC", PartitionGranularity -> {Quantity[25, "ms"], Quantity[25, "ms"], HannWindow},  PaddingSize -> 0] === AudioLocalMeasurements[aud, "MFCC", PartitionGranularity -> {Quantity[25, "ms"], Quantity[25, "ms"]}, PaddingSize -> 0]

that the HannWindow function is used.

  • $\begingroup$ Even with these suggestions I am still unable to replicate Mathematica's MFCC computation. Since I don't want any windowing I set myWindow[x_] := DirichletWindow[x/1000000] and then enter AudioLocalMeasurements[putAudioFrame, "MFCC", PartitionGranularity -> {Quantity[frameSize, "ms"], Quantity[frameStep, "ms"], myWindow[#] &}, PaddingSize -> 0]["Values"] I suspect that one or the other or both of liftering and pre-emphasis transformations are being applied but if so the parameters of these adjustments aren't stated. $\endgroup$ – Scott Guthery Oct 14 '17 at 21:58
  • $\begingroup$ As far as I can tell, PaddingSize has no effect on MFCC computation. That is, I get the same result with or without PaddingSize->0. $\endgroup$ – Scott Guthery Oct 21 '17 at 14:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.