Home | History | Annotate | Download | only in audioquality
      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 LINEARITY_TEST_H
     18 #define LINEARITY_TEST_H
     19 
     20 /* error codes returned */
     21 // The input signals or sample counts are missing.
     22 const int ERROR_INPUT_SIGNAL_MISSING       = -1;
     23 // The number of input signals is < 2.
     24 const int ERROR_INPUT_SIGNAL_NUMBERS       = -2;
     25 // The specified sample rate is <= 4000.0
     26 const int ERROR_SAMPLE_RATE_TOO_LOW        = -3;
     27 // The dB step size for the increase in stimulus level is <= 0.0
     28 const int ERROR_NEGATIVE_STEP_SIZE         = -4;
     29 // The specified reference stimulus number is out of range.
     30 const int ERROR_STIMULUS_NUMBER            = -5;
     31 // One or more of the stimuli is too short in duration.
     32 const int ERROR_STIMULI_TOO_SHORT          = -6;
     33 // cannot find linear fitting for the given data
     34 const int ERROR_LINEAR_FITTING             = -7;
     35 
     36 /* There are numSignals int16 signals in pcms.  sampleCounts is an
     37    integer array of length numSignals containing their respective
     38    lengths in samples.  They are all sampled at sampleRate.  The pcms
     39    are ordered by increasing stimulus level.  The level steps between
     40    successive stimuli were of size dbStepSize dB.  The signal with
     41    index referenceStim (0 <= referenceStim < numSignals) should be in
     42    an amplitude range that is reasonably certain to be linear (e.g. at
     43    normal speaking levels).  The maximum deviation in linearity found
     44    (in dB) is returned in maxDeviation.  The function returns 1 if
     45    the measurements could be made, or a negative number that
     46    indicates the error, as defined above. */
     47 int linearityTest(short** pcms, int* sampleCounts, int numSignals,
     48                   float sampleRate, float dbStepSize,
     49                   int referenceStim, float* maxDeviation);
     50 
     51 /* a version using RMS of the whole signal and linear fitting */
     52 int linearityTestRms(short** pcms, int* sampleCounts, int numSignals,
     53                   float sampleRate, float dbStepSize,
     54                   float* maxDeviation);
     55 
     56 
     57 #endif /* LINEARITY_TEST_H */
     58