Home | History | Annotate | Download | only in loopback
      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     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_LATENCY = 222;
     31     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_BUFFER_PERIOD = 223;
     32     public static final int LOOPBACK_PLUG_AUDIO_THREAD_TEST_TYPE_CALIBRATION = 224;
     33 
     34     public static final int AUDIO_THREAD_TYPE_JAVA = 0;
     35     public static final int AUDIO_THREAD_TYPE_NATIVE = 1;
     36 
     37     public static final int BYTES_PER_SHORT = 2;
     38     public static final int SHORTS_PER_INT = 2;
     39     // FIXME Assumes 16-bit and mono, will not work for other bit depths or multi-channel.
     40     public static final int BYTES_PER_FRAME = 2;    // bytes per sample
     41 
     42     // prime numbers that don't overlap with FFT frequencies
     43     public static final double PRIME_FREQUENCY_1 = 703.0;
     44     public static final double PRIME_FREQUENCY_2 = 719.0;
     45 
     46     // amplitude for ToneGeneration
     47     public static final double SINE_WAVE_AMPLITUDE = 0.8;
     48     public static final double TWO_SINE_WAVES_AMPLITUDE = 0.4;
     49 
     50     // the number used to configured PipeShort/PipeByteBuffer
     51     public static final int MAX_SHORTS = 65536;
     52 
     53     // used to identify a variable is currently unknown
     54     public static final int UNKNOWN = -1;
     55 
     56     // used when joining a thread
     57     public static final int JOIN_WAIT_TIME_MS = 1000;
     58 
     59     // Loopback on Java thread test audio tone constants
     60     public static final int LOOPBACK_SAMPLE_FRAMES = 300;
     61     public static final double LOOPBACK_AMPLITUDE = 0.95;
     62     public static final int LOOPBACK_FREQUENCY = 4000;
     63 
     64     // Settings Activity and ADB constants
     65     public static final int SAMPLING_RATE_MAX = 48000;
     66     public static final int SAMPLING_RATE_MIN = 8000;
     67     public static final int PLAYER_BUFFER_FRAMES_MAX = 8000;
     68     public static final int PLAYER_BUFFER_FRAMES_MIN = 16;
     69     public static final int RECORDER_BUFFER_FRAMES_MAX = 8000;
     70     public static final int RECORDER_BUFFER_FRAMES_MIN = 16;
     71     public static final int BUFFER_TEST_DURATION_SECONDS_MAX = 36000;
     72     public static final int BUFFER_TEST_DURATION_SECONDS_MIN = 1;
     73     public static final int BUFFER_TEST_WAVE_PLOT_DURATION_SECONDS_MAX = 120;
     74     public static final int BUFFER_TEST_WAVE_PLOT_DURATION_SECONDS_MIN = 1;
     75     public static final int MAX_NUM_LOAD_THREADS = 20;
     76     public static final int MIN_NUM_LOAD_THREADS = 0;
     77     public static final int MIN_NUM_CAPTURES = 1;
     78     public static final int MAX_NUM_CAPTURES = 100;
     79     public static final int DEFAULT_NUM_CAPTURES = 5;
     80     public static final int MIN_IGNORE_FIRST_FRAMES = 0;
     81     // impulse happens after 300 ms and shouldn't be ignored
     82     public static final int MAX_IGNORE_FIRST_FRAMES = SAMPLING_RATE_MAX * 3 / 10;
     83     public static final int DEFAULT_IGNORE_FIRST_FRAMES = 0;
     84 
     85 
     86     // Controls size of pre allocated timestamp arrays
     87     public static final int MAX_RECORDED_LATE_CALLBACKS_PER_SECOND = 2;
     88     // Ignore first few buffer callback periods
     89     public static final int BUFFER_PERIOD_DISCARD = 10;
     90 }
     91