• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 #ifndef COMPARE_SPECTRA_H
18 #define COMPARE_SPECTRA_H
19 
20 /* Compare the average magnitude spectra of the signals in pcm and
21    refPcm, which are of length numSamples and nRefSamples,
22    respectively; both sampled at sample_rate.  The maximum deviation
23    between average spectra, expressed in dB, is returned in
24    maxDeviation, and the rms of all dB variations is returned in
25    rmsDeviation.  Note that a lower limit is set on the frequencies that
26    are compared so as to ignore irrelevant DC and rumble components.  If
27    the measurement fails for some reason, return 0; else return 1, for
28    success.  Causes for failure include the amplitude of one or both of
29    the signals being too low, or the duration of the signals being too
30    short.
31 
32    Note that the expected signal collection scenario is that the phone
33    would be stimulated with a broadband signal as in a recognition
34    attempt, so that there will be some "silence" regions at the start and
35    end of the pcm signals.  The preferred stimulus would be pink noise,
36    but any broadband signal should work. */
37 
38 int compareSpectra(short* pcm, int numSamples, short* refPcm,
39                    int nRefSamples, float sampleRate,
40                    float* maxDeviation, float* rmsDeviation);
41 
42 #endif // COMPARE_SPECTRA_H
43