xref: /aosp_15_r20/external/oboe/apps/fxlab/docs/Dev-Guide.md (revision 05767d913155b055644481607e6fa1e35e2fe72c)
1*05767d91SRobert Wu# Development
2*05767d91SRobert Wu
3*05767d91SRobert WuThe effects included are designed to be as portable as possible, as well as making it easy to add additional effects.
4*05767d91SRobert Wu
5*05767d91SRobert Wu## Building
6*05767d91SRobert Wu
7*05767d91SRobert WuTo build the app, simply open the project in android studio and build. The app integrates Oboe via a git submodule. Make sure
8*05767d91SRobert Wuwhen cloning the repository to clone the submodule as well using `git clone --recursive`, or `git submodule update --init --recursive`.
9*05767d91SRobert Wu
10*05767d91SRobert WuTo update the version of Oboe being used, descend into the Oboe repository [(oboe location)](../app/src/main/cpp)
11*05767d91SRobert Wuand update from its remote. Then, call `git submodule update` in this repository. Alternatively `git submodule update --recursive --remote` will pull the latest version of Oboe from remote.
12*05767d91SRobert Wu
13*05767d91SRobert WuAlthough the CMake file requires android headers (to use Oboe), the effects themselves can be compiled with any C++17 compliant compiler.
14*05767d91SRobert Wu
15*05767d91SRobert Wu## Architecture
16*05767d91SRobert Wu
17*05767d91SRobert WuThe UI code (Kotlin) calls native code through the JNI bridge to query information about the various effects implemented,
18*05767d91SRobert Wuand how to render the effect information in the UI. This means that adding an effect only needs to be done on the
19*05767d91SRobert Wunative side. The JNI bridge passes information regarding implemented effects descriptions to the UI as well as functions
20*05767d91SRobert Wucalled when the user modifies effects in the UI.
21*05767d91SRobert Wu
22*05767d91SRobert WuThe `DuplexEngine` is responsible for managing and syncing the input and output Oboe streams for rendering audio
23*05767d91SRobert Wuwith as low latency as possible. The `FunctionList` class contains the a vector of effects that correspond to the list of
24*05767d91SRobert Wueffects (and their parameters) that the user wants to use to process their audio. Effects (and the `FunctionList`) overload
25*05767d91SRobert Wutheir function operator to take in two numeric iterator types. E.g `<template iter_type> void operator()
26*05767d91SRobert Wu(iter_type begin, iter_type end)`, where the `iter_types` correspond to C++ iterators carrying audio data. To erase the type
27*05767d91SRobert Wuof different objects, the `FunctionList` holds objects of types `std::function<void(iter_type, iter_type)>` i.e. functions
28*05767d91SRobert Wuwhich operate on the range between two numeric iterators in place. The `DuplexEngine`simply calls the `FunctionList` on every
29*05767d91SRobert Wubuffer of samples it receives.
30*05767d91SRobert Wu
31*05767d91SRobert WuThe effects folder contains the classes of various implemented effects. It also contains `Effects.h` where a global tuple of
32*05767d91SRobert Wuall the Effect descriptions implemented lives. The description folder contains the description for all of the effects.
33*05767d91SRobert WuEach description takes the form of a class with static methods providing information regarding the effect (including name,
34*05767d91SRobert Wucategory, parameters, and a factory method).
35*05767d91SRobert Wu
36*05767d91SRobert Wu## Adding Effects
37*05767d91SRobert WuTo add an effect, simply add a Description class similar to the existing classes, and add the class to the tuple in `Effects.h`. The description must provide a way to build the effect by either constructing another class corresponding
38*05767d91SRobert Wuto an effect, or pointing to a standalone function. Adding new effects is welcome!
39*05767d91SRobert Wu
40*05767d91SRobert Wu## Existing Effects
41*05767d91SRobert WuA instructional implemented effect to examine is the `TremoloEffect.h` (a modulating gain).
42*05767d91SRobert WuMany of the effects in the delay category
43*05767d91SRobert Wuinherit from `DelayLineEffect` which provides a framework to easily implement many delay based effects, as well as
44*05767d91SRobert Wuthe comb filter effects (FIR, IIR, allpass). The slides have a block diagram displaying the mathematical basis of the effect.
45*05767d91SRobert WuThe nonlinear effects (distortion and overdrive) are implemented using a standalone function (from `SingleEffectFunctions.h`.
46*05767d91SRobert WuThe gain effect is implemented by a simple lambda in its description class.
47