xref: /aosp_15_r20/external/oboe/apps/OboeTester/docs/Usage.md (revision 05767d913155b055644481607e6fa1e35e2fe72c)
1*05767d91SRobert Wu[Home](README.md)
2*05767d91SRobert Wu
3*05767d91SRobert Wu# How to Use OboeTester
4*05767d91SRobert Wu
5*05767d91SRobert Wu## Loopback Adapter Needed for Some Tests
6*05767d91SRobert Wu
7*05767d91SRobert WuSome of these tests require an [audio Loopback Adapter](https://source.android.com/devices/audio/latency/loopback) that plugs into a 3.5 mm jack.
8*05767d91SRobert WuIf the phone does not have a 3.5 mm jack then you can combine that with a USB to 3.5mm adapter.
9*05767d91SRobert Wu
10*05767d91SRobert WuLoopback adapters can be purchased from [PassMark Software](https://www.passmark.com/products/audio-loopback-plug/).
11*05767d91SRobert Wu
12*05767d91SRobert Wu## Test Activities
13*05767d91SRobert Wu
14*05767d91SRobert WuLaunch OboeTester and then select one of the test Activities.
15*05767d91SRobert Wu
16*05767d91SRobert Wu### Test Output
17*05767d91SRobert Wu
18*05767d91SRobert WuTap the green bar to expand the Settings display.
19*05767d91SRobert Wu
20*05767d91SRobert WuTest opening, starting, stopping and closing a stream.
21*05767d91SRobert WuVarious stream parameters can be selected before opening.
22*05767d91SRobert WuWhile the stream is playing, the frame counts and stream state are displayed.
23*05767d91SRobert WuThe latency is estimated based on the timestamp information.
24*05767d91SRobert Wu
25*05767d91SRobert WuExperiment with changing the buffer size to see if there are glitches when the size is high or low.
26*05767d91SRobert Wu
27*05767d91SRobert WuExperiment with changing the "Workload".
28*05767d91SRobert WuWatch the "% CPU" and the #XRuns.
29*05767d91SRobert WuThe audio is expected to glitch when the workload is high because there is too much work
30*05767d91SRobert Wuand the audio task misses its delivery deadlines.
31*05767d91SRobert Wu
32*05767d91SRobert WuThe extra workload is generated by calculating a number of classic synthesizer voices with two oscillators, two envelopes and a resonant filter.
33*05767d91SRobert WuYou can see the affect of the changing workload in the "% cpu" report in the status area.
34*05767d91SRobert WuThe extra workload will always cause glitching when you get close to 100% CPU load.
35*05767d91SRobert WuIf the workload is causing glitching at a low % CPU load then there may be a problem with the callback timing.
36*05767d91SRobert Wu
37*05767d91SRobert WuA variety of output signals can be played including frequency sweeps and white noise.
38*05767d91SRobert WuThe default output sound is a sine wave on each channel. The base frequency is 330 Hz
39*05767d91SRobert Wuand increases by a ratio of 4:3 (a perfect fourth) for each channel.
40*05767d91SRobert Wu
41*05767d91SRobert WuInstructions for using TEST OUTPUT for 4 or more chanels is in
42*05767d91SRobert Wu[Wiki/OboeTester_MultiChannelOutput](https://github.com/google/oboe/wiki/OboeTester_MultiChannelOutput).
43*05767d91SRobert Wu
44*05767d91SRobert Wu### Test Input
45*05767d91SRobert Wu
46*05767d91SRobert WuTest input streams. Displays current volume as VU bars.
47*05767d91SRobert Wu
48*05767d91SRobert Wu### Tap to Tone Latency
49*05767d91SRobert Wu
50*05767d91SRobert WuMeasure touch screen latency plus audio output latency.
51*05767d91SRobert WuPress START then tap on the screen with your fingertip.
52*05767d91SRobert WuThe app will listen for the sound of your fingernail tapping the screen
53*05767d91SRobert Wuand the resulting beep, and then measure the time between them.
54*05767d91SRobert Wu
55*05767d91SRobert WuIf you use headphones then you can eliminate the latency caused by speaker protection.
56*05767d91SRobert WuIf you use USB-MIDI input then you can eliminate the latency due to the touch screen, which is around 15-30 msec.
57*05767d91SRobert WuMIDI latency is generally under 1 msec.
58*05767d91SRobert WuThis test works well for measuring the output latency of Bluetooth headsets.
59*05767d91SRobert Wu
60*05767d91SRobert WuMore instructions in the [Wiki/OboeTester_TapToTone](https://github.com/google/oboe/wiki/OboeTester_TapToTone).
61*05767d91SRobert Wu
62*05767d91SRobert Wu### Echo Input to Output
63*05767d91SRobert Wu
64*05767d91SRobert WuThis test copies input to output and adds up to 3 seconds of delay.
65*05767d91SRobert WuThis can be used to simulate high latency on a phone that supports low latency.
66*05767d91SRobert WuTry putting the phone to your ear with the added delay at 0 and try talking.
67*05767d91SRobert WuThen set it to about 700 msec and try talking on the phone. Notice how the echo can be very confusing.
68*05767d91SRobert Wu
69*05767d91SRobert WuThe test will also display estimated "cold start latency" for full duplex streams.
70*05767d91SRobert Wu
71*05767d91SRobert Wu### Round Trip Latency
72*05767d91SRobert Wu
73*05767d91SRobert WuThis test works with either a [loopback adapter](https://source.android.com/devices/audio/latency/loopback) or through speakers.
74*05767d91SRobert WuLatency through the speakers will probably be higher.
75*05767d91SRobert WuIt measures the input and output latency combined.
76*05767d91SRobert Wu
77*05767d91SRobert Wu1. Set the Input or Output settings by tapping the green bar to expose the controls.
78*05767d91SRobert Wu2. Set the volume somewhere above the middle. The test works at almost any volume. But the confidence will be higher at higher volumes.
79*05767d91SRobert Wu3. Tap "MEASURE" to make a single measurement.
80*05767d91SRobert Wu4. Or tap "AVERAGE" to run the test several times and report an average and Mean Absolute Deviation.
81*05767d91SRobert Wu
82*05767d91SRobert WuThe test starts by setting up a stable full-duplex stream.
83*05767d91SRobert WuThen it outputs a random series of bits encoded using smoothed Manchester Encoding.
84*05767d91SRobert WuWe record the Input and Output stream together for about a second.
85*05767d91SRobert WuThen we correlate the two streams by sliding the portion of the output stream that contains the random bits over the input stream at different time offsets.
86*05767d91SRobert WuThe Manchaster Encoded signal provide a very sharp peak when the offset matches the combined input and output latency.
87*05767d91SRobert Wu
88*05767d91SRobert WuSource code for the analyzer in [LatencyAnalyzer.h](https://github.com/google/oboe/blob/main/apps/OboeTester/app/src/main/cpp/analyzer/LatencyAnalyzer.h).
89*05767d91SRobert Wu
90*05767d91SRobert Wu### Record and Play
91*05767d91SRobert Wu
92*05767d91SRobert Wu* Tap RECORD to record several seconds of audio. You should see the red VU meters move.
93*05767d91SRobert Wu* Tap STOP then PLAY to play it back.
94*05767d91SRobert Wu* Tap SHARE button to the recorded WAV file to GDrive, GMail or another app.
95*05767d91SRobert WuYou can then examine the WAV file using a program like Audacity.
96*05767d91SRobert Wu
97*05767d91SRobert Wu### Glitch Test
98*05767d91SRobert Wu
99*05767d91SRobert WuThis test works best with a loopback adapter. But it can also work in a quiet room.
100*05767d91SRobert WuIt plays a sine wave and then tries to record and lock onto that sine wave.
101*05767d91SRobert WuIf the actual input does not match the expected sine wave value then it is counted as a glitch.
102*05767d91SRobert WuThe test will display the maximum time that it ran without seeing a glitch.
103*05767d91SRobert Wu
104*05767d91SRobert Wu1. Plug in loopback adapter. (Optional)
105*05767d91SRobert Wu2. Press green bars to show input and output settings. Make changes. (optional)
106*05767d91SRobert Wu3. Press START button.
107*05767d91SRobert Wu4. Watch for state=LOCKED, which means it has detected and locked onto the sine wave output.
108*05767d91SRobert Wu5. Note the glitch count, which should be zero.
109*05767d91SRobert Wu6. Also the "max.time.no.glitches" should be as long as you run the test.
110*05767d91SRobert Wu7. Press STOP button.
111*05767d91SRobert Wu8. Press SHARE button to send a WAV file recording of the last glitch by email to yourself.
112*05767d91SRobert Wu
113*05767d91SRobert WuLook for the #XRuns display.
114*05767d91SRobert WuIf #XRuns increments when a glitch occurs then the glitch is probably due to preemption of the audio task.
115*05767d91SRobert WuIf #XRuns is not incrementing then the glitches may be due to AAudio MMAP tuning errors in the HAL.
116*05767d91SRobert Wu
117*05767d91SRobert Wu### Auto Glitch Test
118*05767d91SRobert Wu
119*05767d91SRobert WuMeasure glitches for various combinations of input and output settings.
120*05767d91SRobert WuChange the test duration to a high value and let it run for a while.
121*05767d91SRobert WuIf you get glitches in one configuration then you can investigate using the previous manual Glitch Test.
122*05767d91SRobert WuThe Share button will let you email the report to yourself.
123*05767d91SRobert Wu
124*05767d91SRobert Wu### Test Disconnect
125*05767d91SRobert Wu
126*05767d91SRobert WuYou can test whether the disconnect logic is working in Android by plugging or unplugging a headset.
127*05767d91SRobert WuJust follow the instructions in red. You will get a report at the end that you can SHARE by GMail or Drive.
128*05767d91SRobert Wu
129*05767d91SRobert Wu### Device Report
130*05767d91SRobert Wu
131*05767d91SRobert WuProvides a device report. This report includes info about the features enabled, the properties set, audio
132*05767d91SRobert Wupaths, and microphones.
133*05767d91SRobert WuYou can share this report by first pressing the icon with the three vertical dots at the top right of OboeTester.
134*05767d91SRobert WuAfter that, simply press the share button and you should be able to email this to yourself.
135*05767d91SRobert Wu
136*05767d91SRobert Wu### Data Paths
137*05767d91SRobert Wu
138*05767d91SRobert WuThis checks for dead speaker and mic channels, dead Input Presets and other audio data path problems.
139*05767d91SRobert Wu
140*05767d91SRobert Wu1. Tap "DATA PATHS" button.
141*05767d91SRobert Wu1. Unplug or disconnect any headphones.
142*05767d91SRobert Wu1. Set volume to medium high.
143*05767d91SRobert Wu1. Place the phone on a table in a quiet room and hit START.
144*05767d91SRobert Wu1. Wait a few minutes, quietly, for the test to complete. You will hear some sine tones.
145*05767d91SRobert Wu1. You will get a report at the end that you can SHARE by GMail or Drive.
146*05767d91SRobert Wu
147*05767d91SRobert Wu### External Tap-to-Tone
148*05767d91SRobert Wu
149*05767d91SRobert WuThis lets you measure the latency between touching a screen to the sound coming out on a second device.
150*05767d91SRobert WuYou could use this to measure, for example, the latency on an iPhone.
151*05767d91SRobert Wu
152*05767d91SRobert Wu1. Launch OboeTester on Android device (A) in a quiet room.
153*05767d91SRobert Wu2. Tap "EXTRAS..." button.
154*05767d91SRobert Wu3. Tap "EXTERNAL TAP" button.
155*05767d91SRobert Wu4. Launch a program on a second device (B) that will make a sound when you touch the screen. A good example would be an interactive drum pad.
156*05767d91SRobert Wu5. Tap "START" button to start listening on device (A).
157*05767d91SRobert Wu6. Tap on the app on the device (B) with your fingertip. You need to make a noise with your fingernail.
158*05767d91SRobert Wu7. Quickly tap the "ANALYSE" button on device (A).
159*05767d91SRobert Wu8. OboeTester will now look for two sounds in the recording and measure the time between them.
160*05767d91SRobert Wu
161*05767d91SRobert Wu### Plug Latency
162*05767d91SRobert WuMeasures the time it takes to close, open, and start streams as audio devices are plugged in and removed.
163*05767d91SRobert Wu
164*05767d91SRobert Wu### Error Callback Test
165*05767d91SRobert WuLets you delete an error callback while it is used by Oboe. Targeted test for issue #1603.
166*05767d91SRobert Wu
167*05767d91SRobert Wu### Route Callback Test
168*05767d91SRobert WuChanges the VoiceCommunication route while playing audio. Targeted test for issue #1763.
169*05767d91SRobert Wu
170*05767d91SRobert Wu### CPU Load
171*05767d91SRobert WuThis test plays a tone and alternates between low and high workloads.
172*05767d91SRobert WuIt exercises the kernel's CPU scheduler, which controls CPU frequency and core migration.
173*05767d91SRobert WuMoredetails on the [wiki/OboeTester_DynamicCpuLoad](https://github.com/google/oboe/wiki/OboeTester_DynamicCpuLoad).
174