• 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");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of 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,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.cts.verifier.audioquality;
18 
19 /**
20  * Interface to native (C++) DSP code.
21  */
22 public class Native {
generateSinusoid(float freq, float duration, float sampleRate, float amplitude, float ramp)23     public native short[] generateSinusoid(float freq, float duration,
24             float sampleRate, float amplitude, float ramp);
measureRms(short[] pcm, float sampleRate, float onsetThresh)25     public native float[] measureRms(short[] pcm, float sampleRate,
26             float onsetThresh);
glitchTest(float sampleRate, float stimFreq, float onsetThresh, float dbSnrThresh, short[] pcm)27     public native float[] glitchTest(float sampleRate, float stimFreq,
28             float onsetThresh, float dbSnrThresh, short[] pcm);
overflowCheck(short[] pcm, float sampleRate)29     public native float[] overflowCheck(short[] pcm, float sampleRate);
compareSpectra(short[] pcm, short[] refPcm, float sampleRate)30     public native float[] compareSpectra(short[] pcm, short[] refPcm,
31             float sampleRate);
linearityTest(short[][] pcms, float sampleRate, float dbStepSize, int referenceStim)32     public native float linearityTest(short[][] pcms,
33         float sampleRate, float dbStepSize, int referenceStim);
34 
35     // The following indexes must match those in wrapper.cc
36     public static final int MEASURE_RMS_RMS = 0;
37     public static final int MEASURE_RMS_STD_DEV = 1;
38     public static final int MEASURE_RMS_DURATION = 2;
39     public static final int MEASURE_RMS_MEAN = 3;
40 
41     public static final int OVERFLOW_DELTAS = 0;
42     public static final int OVERFLOW_ERROR = 1;
43     public static final int OVERFLOW_DURATION = 2;
44     public static final int OVERFLOW_ONSET = 3;
45     public static final int OVERFLOW_OFFSET = 4;
46     public static final int OVERFLOW_MAX = 5;
47     public static final int OVERFLOW_MIN = 6;
48 
49     public static final int GLITCH_COUNT = 0;
50     public static final int GLITCH_ERROR = 1;
51     public static final int GLITCH_DURATION = 2;
52 
53     public static final int SPECTRUM_MAX_DEVIATION = 0;
54     public static final int SPECTRUM_ERROR = 1;
55     public static final int SPECTRUM_RMS_DEVIATION = 2;
56 
57     private static Native mInstance = null;
58 
59     static {
60         System.loadLibrary("audioquality");
61     }
62 
Native()63     private Native() {}
64 
getInstance()65     public static Native getInstance() {
66         if (mInstance == null) {
67             mInstance = new Native();
68         }
69         return mInstance;
70     }
71 }
72