• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 org.drrickorang.loopback;
18 
19 
20 /**
21  * This file stores constants that are used across multiple files.
22  */
23 
24 public class Constant {
25     public static final double TWO_PI = 2.0 * Math.PI;
26     public static final long   NANOS_PER_MILLI = 1000000;
27     public static final int    MILLIS_PER_SECOND = 1000;
28     public static final int    SECONDS_PER_HOUR = 3600;
29 
30     // Must match constants in jni/loopback.h
31     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_LATENCY = 222;
32     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_BUFFER_PERIOD = 223;
33     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_CALIBRATION = 224;
34 
35     // Keys for CTS Loopback invocation
36     public static final String KEY_CTSINVOCATION = "CTS-Test";
37     public static final String KEY_NUMITERATIONS = "NumIterations";
38 
39     public static final int AUDIO_THREAD_TYPE_JAVA = 0;
40     public static final int AUDIO_THREAD_TYPE_NATIVE_SLES = 1;
41     public static final int AUDIO_THREAD_TYPE_NATIVE_AAUDIO = 2;
42 
43     public static final int BYTES_PER_SHORT = 2;
44     public static final int SHORTS_PER_INT = 2;
45     // FIXME Assumes 16-bit and mono, will not work for other bit depths or multi-channel.
46     public static final int BYTES_PER_FRAME = 2;    // bytes per sample
47 
48     // prime numbers that don't overlap with FFT frequencies
49     public static final double PRIME_FREQUENCY_1 = 703.0;
50     public static final double PRIME_FREQUENCY_2 = 719.0;
51 
52     // amplitude for ToneGeneration
53     public static final double SINE_WAVE_AMPLITUDE = 0.8;
54     public static final double TWO_SINE_WAVES_AMPLITUDE = 0.4;
55 
56     // the number used to configured PipeShort/PipeByteBuffer
57     public static final int MAX_SHORTS = 65536;
58 
59     // used to identify a variable is currently unknown
60     public static final int UNKNOWN = -1;
61 
62     // used when joining a thread
63     public static final int JOIN_WAIT_TIME_MS = 1000;
64 
65     // Loopback on Java thread test audio tone constants
66     public static final int LOOPBACK_SAMPLE_FRAMES = 300;
67     public static final double LOOPBACK_AMPLITUDE = 0.95;
68     public static final int LOOPBACK_FREQUENCY = 4000;
69 
70     // Settings Activity and ADB constants
71     public static final int SAMPLING_RATE_MAX = 48000;
72     public static final int SAMPLING_RATE_MIN = 8000;
73     public static final int CORRELATION_BLOCK_SIZE_MAX = 8192;
74     public static final int CORRELATION_BLOCK_SIZE_MIN = 2048;
75     public static final int DEFAULT_CORRELATION_BLOCK_SIZE = 4096;
76     public static final int PLAYER_BUFFER_FRAMES_MAX = 8000;
77     public static final int PLAYER_BUFFER_FRAMES_MIN = 16;
78     public static final int RECORDER_BUFFER_FRAMES_MAX = 8000;
79     public static final int RECORDER_BUFFER_FRAMES_MIN = 16;
80     public static final int BUFFER_TEST_DURATION_SECONDS_MAX = 36000;
81     public static final int BUFFER_TEST_DURATION_SECONDS_MIN = 1;
82     public static final int BUFFER_TEST_WAVE_PLOT_DURATION_SECONDS_MAX = 120;
83     public static final int BUFFER_TEST_WAVE_PLOT_DURATION_SECONDS_MIN = 1;
84     public static final int MAX_NUM_LOAD_THREADS = 20;
85     public static final int MIN_NUM_LOAD_THREADS = 0;
86     public static final int MIN_NUM_CAPTURES = 1;
87     public static final int MAX_NUM_CAPTURES = 100;
88     public static final int DEFAULT_NUM_CAPTURES = 5;
89     public static final int MIN_IGNORE_FIRST_FRAMES = 0;
90     // impulse happens after 300 ms and shouldn't be ignored
91     public static final int MAX_IGNORE_FIRST_FRAMES = SAMPLING_RATE_MAX * 3 / 10;
92     public static final int DEFAULT_IGNORE_FIRST_FRAMES = 0;
93 
94     // Controls size of pre allocated timestamp arrays
95     public static final int MAX_RECORDED_LATE_CALLBACKS_PER_SECOND = 2;
96     // Ignore first few buffer callback periods
97     public static final int BUFFER_PERIOD_DISCARD = 10;
98 }
99