MCPcopy Create free account
hub / github.com/ARM-software/armnn / MfccComputeQuant

Method MfccComputeQuant

samples/common/include/Audio/MFCC.hpp:81–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 **/
80 template<typename T>
81 std::vector<T> MfccComputeQuant(const std::vector<float>& audioData,
82 const float quantScale,
83 const int quantOffset)
84 {
85 this->MfccComputePreFeature(audioData);
86 float minVal = std::numeric_limits<T>::min();
87 float maxVal = std::numeric_limits<T>::max();
88
89 std::vector<T> mfccOut(this->m_params.m_numMfccFeatures);
90 const size_t numFbankBins = this->m_params.m_numFbankBins;
91
92 /* Take DCT. Uses matrix mul. */
93 for (size_t i = 0, j = 0; i < mfccOut.size(); ++i, j += numFbankBins)
94 {
95 float sum = 0;
96 for (size_t k = 0; k < numFbankBins; ++k)
97 {
98 sum += this->m_dctMatrix[j + k] * this->m_melEnergies[k];
99 }
100 /* Quantize to T. */
101 sum = std::round((sum / quantScale) + quantOffset);
102 mfccOut[i] = static_cast<T>(std::min<float>(std::max<float>(sum, minVal), maxVal));
103 }
104
105 return mfccOut;
106 }
107
108 MfccParams m_params;
109

Callers

nothing calls this directly

Calls 3

MfccComputePreFeatureMethod · 0.95
roundFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected