xref: /aosp_15_r20/external/oboe/samples/LiveEffect/README.md (revision 05767d913155b055644481607e6fa1e35e2fe72c)
1*05767d91SRobert WuLiveEffect Sample
2*05767d91SRobert Wu============
3*05767d91SRobert Wu
4*05767d91SRobert WuThis sample simply loops audio from input stream to output stream to demonstrate
5*05767d91SRobert Wuthe usage of the 2 stream interfaces.
6*05767d91SRobert Wu
7*05767d91SRobert WuScreenshots
8*05767d91SRobert Wu-----------
9*05767d91SRobert Wu
10*05767d91SRobert Wu![Screenshot](screenshot.png)
11*05767d91SRobert Wu
12*05767d91SRobert Wu
13*05767d91SRobert Wu### Stream Configurations
14*05767d91SRobert Wu- 48kHz
15*05767d91SRobert Wu- oboe::I16
16*05767d91SRobert Wu- stereo or mono
17*05767d91SRobert Wu
18*05767d91SRobert Wu### Customizing the App
19*05767d91SRobert Wu
20*05767d91SRobert WuIf you want to customize the effects processing then modify the
21*05767d91SRobert WuonBothStreamsReady() method in "src/main/cpp/FullDuplexPass.h"
22*05767d91SRobert Wu
23*05767d91SRobert Wu### Caveats
24*05767d91SRobert WuOpenES SL does not allow setting the recording or playback device.
25*05767d91SRobert Wu
26*05767d91SRobert WuSynchronizing input and output streams for full-duplex operation is tricky. 
27*05767d91SRobert Wu
28*05767d91SRobert WuInput and output have different startup times. The input side may have to charge up the microphone circuit.
29*05767d91SRobert WuAlso the initial timing for the output callback may be bursty as it fills the buffer up.
30*05767d91SRobert WuSo when the output stream makes its first callback, the input buffer may be overflowing or empty or partially full.
31*05767d91SRobert Wu
32*05767d91SRobert WuIn order to get into sync we go through a few phases.
33*05767d91SRobert Wu
34*05767d91SRobert Wu* In Phase 1 we always drain the input buffer as much as possible, more than the output callback asks for. When we have done this for a while, we move to phase 2.
35*05767d91SRobert Wu* In Phase 2 we optionally skip reading the input once to allow it to fill up with one burst. This makes it less likely to underflow on future reads.
36*05767d91SRobert Wu* In Phase 3 we should be in a stable situation where the output is nearly full and the input is nearly empty.  You should be able to run for hours like this with no glitches.
37