• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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.google.sample.oboe.manualtest;
18 
19 import android.media.audiofx.Equalizer;
20 import android.media.audiofx.PresetReverb;
21 import android.util.Log;
22 import android.widget.SeekBar;
23 import android.widget.TextView;
24 
25 import java.io.IOException;
26 
27 
28 abstract class TestOutputActivityBase extends TestAudioActivity {
29     AudioOutputTester mAudioOutTester;
30 
31     private BufferSizeView mBufferSizeView;
32     private WorkloadView mWorkloadView;
33 
isOutput()34     @Override boolean isOutput() { return true; }
35 
36     @Override
resetConfiguration()37     protected void resetConfiguration() {
38         super.resetConfiguration();
39         mAudioOutTester.reset();
40     }
41 
findAudioCommon()42     protected void findAudioCommon() {
43         super.findAudioCommon();
44         mBufferSizeView = (BufferSizeView) findViewById(R.id.buffer_size_view);
45         mWorkloadView = (WorkloadView) findViewById(R.id.workload_view);
46     }
47 
48     @Override
addAudioOutputTester()49     public AudioOutputTester addAudioOutputTester() {
50         AudioOutputTester audioOutTester = super.addAudioOutputTester();
51         mWorkloadView.setAudioStreamTester(audioOutTester);
52         return audioOutTester;
53     }
54 
55     @Override
openAudio()56     public void openAudio() throws IOException {
57         super.openAudio();
58         if (mBufferSizeView != null) {
59             mBufferSizeView.onStreamOpened((OboeAudioStream) mAudioOutTester.getCurrentAudioStream());
60         }
61     }
62 
63     // TODO Add editor
setupEqualizer(int sessionId)64     public void setupEqualizer(int sessionId) {
65         Equalizer equalizer = new Equalizer(0, sessionId);
66         int numBands = equalizer.getNumberOfBands();
67         Log.d(TAG, "numBands " + numBands);
68         for (short band = 0; band < numBands; band++) {
69             String msg = "band " + band
70                     + ", center = " + equalizer.getCenterFreq(band)
71                     + ", level = " + equalizer.getBandLevel(band);
72             Log.d(TAG, msg);
73             equalizer.setBandLevel(band, (short)40);
74         }
75 
76         equalizer.setBandLevel((short) 1, (short) 300);
77     }
78 
setupReverb(int sessionId)79     public void setupReverb(int sessionId) {
80         PresetReverb effect = new PresetReverb(0, sessionId);
81     }
82 
83     @Override
setupEffects(int sessionId)84     public void setupEffects(int sessionId) {
85         // setupEqualizer(sessionId);
86         // setupReverb(sessionId);
87     }
88 }