Add support for audio pre-processing (MFCC extraction)
This is the complete code change for adding audio pre-processing block (MFCC feature extraction).
The code was re-written in C based on http://google3/audio/dsp/mfcc/mfcc_mel.py, with necessary simplifications.
We also integrated audio pre-processing into daredevil, to allow for end-to-end simulations with .wav audio input.
Numerical correctness has been validated: extracted MFCC matches with
the reference (golden_whistle_spectrogram) and returned output is
correct (Whistling). Unit tests passed.
Profiling result: https://docs.google.com/document/d/1vAgRgZeVyOwIniiIp8RrmEvg3CB_p0PFgB2X9NLN4Fo
The pre-processing block adds a relatively constant number of extra instructions. So the percentage depends on the computational complexity of audio models (for daredevil: 65%)
Change-Id: I662914e68170e5e28384960ad345c3366f9fb627
diff --git a/samples/audio_prep/util.h b/samples/audio_prep/util.h
new file mode 100644
index 0000000..ade1610
--- /dev/null
+++ b/samples/audio_prep/util.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SAMPLES_AUDIO_PREP_UTIL_H_
+#define SAMPLES_AUDIO_PREP_UTIL_H_
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+// Evenly linear spaced array
+void linspace(float* x, float start, float end, int n);
+
+// Calculate the dot product of two vectors
+float dot_product(float* v, float* u, int n);
+
+/*---------------------------------------------------------------------------
+ * FUNCTION NAME: rfft
+ *
+ * PURPOSE: Real valued, in-place split-radix FFT
+ *
+ * INPUT:
+ * x Pointer to input and output array
+ * m 2^m = n is the Length of FFT
+ *
+ * OUTPUT Output order
+ * Re(0), Re(1), ..., Re(n/2), Im(N/2-1), ..., Im(1)
+ *
+ * RETURN VALUE
+ * none
+ *
+ *---------------------------------------------------------------------------*/
+void rfft(float* x, int m);
+
+#endif // SAMPLES_AUDIO_PREP_UTIL_H_