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

Method MfccComputePreFeature

samples/common/src/Audio/MFCC.cpp:226–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void MFCC::MfccComputePreFeature(const std::vector<float>& audioData)
227{
228 this->InitMelFilterBank();
229
230 auto size = std::min(std::min(this->m_frame.size(), audioData.size()),
231 static_cast<size_t>(this->m_params.m_frameLen)) * sizeof(float);
232 std::memcpy(this->m_frame.data(), audioData.data(), size);
233
234 /* Apply window function to input frame. */
235 for(size_t i = 0; i < this->m_params.m_frameLen; i++)
236 {
237 this->m_frame[i] *= this->m_windowFunc[i];
238 }
239
240 /* Set remaining frame values to 0. */
241 std::fill(this->m_frame.begin() + this->m_params.m_frameLen,this->m_frame.end(), 0);
242
243 /* Compute FFT. */
244 MathUtils::FftF32(this->m_frame, this->m_buffer);
245
246 /* Convert to power spectrum. */
247 this->ConvertToPowerSpectrum();
248
249 /* Apply mel filterbanks. */
250 if (!this->ApplyMelFilterBank(this->m_buffer,
251 this->m_melFilterBank,
252 this->m_filterBankFilterFirst,
253 this->m_filterBankFilterLast,
254 this->m_melEnergies))
255 {
256 printf("Failed to apply MEL filter banks\n");
257 }
258
259 /* Convert to logarithmic scale. */
260 this->ConvertToLogarithmicScale(this->m_melEnergies);
261}
262
263std::vector<float> MFCC::MfccCompute(const std::vector<float>& audioData)
264{

Callers 2

MfccComputeMethod · 0.95
MfccComputeQuantMethod · 0.95

Calls 9

InitMelFilterBankMethod · 0.95
ApplyMelFilterBankMethod · 0.95
fillFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected