aquila icon indicating copy to clipboard operation
aquila copied to clipboard

MFCC, unnecessary DCT reuse

Open sonicmouse opened this issue 10 years ago • 1 comments

In the class Mfcc.cpp, you have this function "calculate()",

   32     std::vector Mfcc::calculate(const SignalSource &source,
   33                                         std::size_t numFeatures)
   34     {
   35         auto spectrum = m_fft->fft(source.toArray());
   36 
   37         Aquila::MelFilterBank bank(source.getSampleFrequency(), m_inputSize);
   38         auto filterOutput = bank.applyAll(spectrum);
   39 
   40         Aquila::Dct dct;
   41         return dct.dct(filterOutput, numFeatures);
   42     }

Every time you call "calculate()", a new DCT is created (line 40). You need to pull the DCT object out of the calculate() scope and put it in the class scope privately.

You have a lot of heavy lifting in DCT, especially with the cosign tables. You even go through all the trouble of caching the cosine tables! So, take advantage of that.

The MFCC calculation will speed up tremendously, especially if you are doing tons of calculations on data that is the same size.

Great job on the library... I have been using it successfully. Ported most of it back to C++98 (had to -- working on a legacy project)

Thanks!

sonicmouse avatar Jan 20 '15 01:01 sonicmouse

@sonicmouse Hi, i am trying to port aquila to C++98, too. How is your porting library going? Any open source plan?

sqbing avatar Mar 20 '15 03:03 sqbing