Move dead submodules in-tree
Signed-off-by: swurl <swurl@swurl.xyz>
14
externals/oboe/apps/fxlab/.gitignore
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
16
externals/oboe/apps/fxlab/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
# How to Contribute
|
||||
|
||||
We'd love to accept your patches and contributions to this project. There are
|
||||
just a few small guidelines you need to follow.
|
||||
|
||||
## Code reviews
|
||||
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use GitHub pull requests for this purpose. Consult
|
||||
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
||||
information on using pull requests.
|
||||
|
||||
## Community Guidelines
|
||||
|
||||
This project follows [Google's Open Source Community
|
||||
Guidelines](https://opensource.google.com/conduct/).
|
202
externals/oboe/apps/fxlab/LICENSE
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
30
externals/oboe/apps/fxlab/README.md
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Android FXLab
|
||||
|
||||
## Features
|
||||
This app performs real-time audio effects with low latency using the [oboe](https://www.github.com/google/oboe) API.
|
||||
|
||||
The audio effects are written natively (in C++), with Kotlin used for the UI.
|
||||
|
||||
Supported features include a linear pipeline of real-time effects with re-ordering, enable/disable, and parameter modification.
|
||||
|
||||
The effects used should be portable as they operate entirely on numeric type iterators.
|
||||
|
||||
## Setup
|
||||
Connect the android device to the correct audio input and output devices. A simple use-case could be a headset with a microphone while singing or playing an acoustic instrument near the mic. More complicated setups could involve USB audio interfaces, devices such as the iRig 2 interface for guitar effects/amplification or routing audio output to a computer for a recording.
|
||||
|
||||
## Layout
|
||||
|
||||

|
||||
|
||||
Tap the plus button to add various effects. The current list of effects being applied to the input audio will be shown on the main screen (in order from top to bottom). Use the drag handles on the right of the effect to re-order the effects. Swiping the effect near the title to the right or left will remove the effect. Use the sliders to modify the parameters of each audio effect. Some effect combinations or parameters might lead to unpleasant sounds!
|
||||
|
||||
By default the sound output is off when you start the app (this is to avoid a feedback loop if you're not using headphones). Tap the "Unmute" button in the top right corner to enable sound output.
|
||||
|
||||
## Development
|
||||
|
||||
A guide to the code, as well as a pdf of a slideshow discussing the code in depth are in the [docs](docs) folder.
|
||||
|
||||
## Credits
|
||||
This app was written by [Atneya Nair](https://www.github.com/atneya)
|
||||
as a sample app using Oboe to publish on the Play store for an internship on
|
||||
the Android Audio team at Google.
|
1
externals/oboe/apps/fxlab/app/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
79
externals/oboe/apps/fxlab/app/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
# For more information about using CMake with Android Studio, read the
|
||||
# documentation: https://d.android.com/studio/projects/add-native-code.html
|
||||
|
||||
# Sets the minimum version of CMake required to build the native library.
|
||||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
# Require C++17 compiler with no extensions
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
link_directories(${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
|
||||
# Creates and names a library, sets it as either STATIC
|
||||
# or SHARED, and provides the relative paths to its source code.
|
||||
# You can define multiple libraries, and CMake builds them for you.
|
||||
# Gradle automatically packages shared libraries with your APK.
|
||||
|
||||
add_library( # Sets the name of the library.
|
||||
native-lib
|
||||
# Sets the library as a shared library.
|
||||
SHARED
|
||||
# Provides a relative path to your source file(s).
|
||||
src/main/cpp/native-lib.cpp
|
||||
src/main/cpp/DuplexEngine.cpp
|
||||
)
|
||||
|
||||
# Compile with warnings for safety
|
||||
if(MSVC)
|
||||
target_compile_options(native-lib PRIVATE /W4 /WX)
|
||||
else()
|
||||
target_compile_options(native-lib PRIVATE -Wall -Wextra -pedantic)
|
||||
endif()
|
||||
|
||||
target_compile_options(native-lib PRIVATE -Ofast)
|
||||
|
||||
# Searches for a specified prebuilt library and stores the path as a
|
||||
# variable. Because CMake includes system libraries in the search path by
|
||||
# default, you only need to specify the name of the public NDK library
|
||||
# you want to add. CMake verifies that the library exists before
|
||||
# completing its build.
|
||||
|
||||
find_library( # Sets the name of the path variable.
|
||||
log-lib
|
||||
# Specifies the name of the NDK library that
|
||||
# you want CMake to locate.
|
||||
log)
|
||||
|
||||
|
||||
### INCLUDE OBOE LIBRARY ###
|
||||
|
||||
# Set the path to the Oboe library directory
|
||||
set (OBOE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||
|
||||
# Add the Oboe library as a subproject. Since Oboe is an out-of-tree source library we must also
|
||||
# specify a binary directory
|
||||
add_subdirectory(${OBOE_DIR} ./oboe-bin)
|
||||
|
||||
# Specify the path to the Oboe header files and the source.
|
||||
include_directories(
|
||||
${OBOE_DIR}/include
|
||||
${OBOE_DIR}/src
|
||||
)
|
||||
|
||||
### END OBOE INCLUDE SECTION ###
|
||||
|
||||
|
||||
# Specifies libraries CMake should link to your target library. You
|
||||
# can link multiple libraries, such as libraries you define in this
|
||||
# build script, prebuilt third-party libraries, or system libraries.
|
||||
|
||||
target_link_libraries( # Specifies the target library.
|
||||
native-lib
|
||||
oboe
|
||||
# Links the target library to the log library
|
||||
# included in the NDK.
|
||||
${log-lib})
|
||||
target_link_options(native-lib PRIVATE "-Wl,-z,max-page-size=16384")
|
69
externals/oboe/apps/fxlab/app/build.gradle
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.mobileer.androidfxlab"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 35
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_18
|
||||
targetCompatibility = JavaVersion.VERSION_18
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "18"
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "./CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
namespace 'com.mobileer.androidfxlab'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation 'androidx.core:core-ktx:1.15.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.4.0'
|
||||
implementation 'com.google.android.material:material:1.12.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test:runner:1.6.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
|
||||
}
|
21
externals/oboe/apps/fxlab/app/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
40
externals/oboe/apps/fxlab/app/src/main/AndroidManifest.xml
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name="com.mobileer.androidfxlab.MainActivity"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
|
||||
</manifest>
|
80
externals/oboe/apps/fxlab/app/src/main/cpp/DuplexCallback.h
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_DUPLEXCALLBACK_H
|
||||
#define ANDROID_FXLAB_DUPLEXCALLBACK_H
|
||||
|
||||
#include <oboe/Oboe.h>
|
||||
|
||||
|
||||
|
||||
// This callback handles mono in, stereo out synchronized audio passthrough.
|
||||
// It takes a function which operates on two pointers (beginning and end)
|
||||
// of underlying data.
|
||||
|
||||
template<class numeric_type>
|
||||
class DuplexCallback : public oboe::AudioStreamCallback {
|
||||
public:
|
||||
|
||||
DuplexCallback(oboe::AudioStream &inStream,
|
||||
std::function<void(numeric_type *, numeric_type *)> fun,
|
||||
size_t buffer_size, std::function<void(void)> restartFunction) :
|
||||
kBufferSize(buffer_size), inRef(inStream), f(fun), restart(restartFunction) {}
|
||||
|
||||
|
||||
oboe::DataCallbackResult
|
||||
onAudioReady(oboe::AudioStream *outputStream, void *audioData, int32_t numFrames) override {
|
||||
auto *outputData = static_cast<numeric_type *>(audioData);
|
||||
auto outputChannelCount = outputStream->getChannelCount();
|
||||
|
||||
// Silence first to simplify glitch detection
|
||||
std::fill(outputData, outputData + numFrames * outputChannelCount, 0);
|
||||
oboe::ResultWithValue<int32_t> result = inRef.read(inputBuffer.get(), numFrames, 0);
|
||||
int32_t framesRead = result.value();
|
||||
if (!result) {
|
||||
inRef.requestStop();
|
||||
return oboe::DataCallbackResult::Stop;
|
||||
}
|
||||
if (mSpinUpCallbacks > 0 && framesRead > 0) {
|
||||
mSpinUpCallbacks--;
|
||||
return oboe::DataCallbackResult::Continue;
|
||||
}
|
||||
f(inputBuffer.get(), inputBuffer.get() + framesRead);
|
||||
for (int i = 0; i < framesRead; i++) {
|
||||
for (size_t j = 0; j < outputChannelCount; j++) {
|
||||
*outputData++ = inputBuffer[i];
|
||||
}
|
||||
}
|
||||
return oboe::DataCallbackResult::Continue;
|
||||
}
|
||||
|
||||
void onErrorAfterClose(oboe::AudioStream *, oboe::Result result) override {
|
||||
inRef.close();
|
||||
if (result == oboe::Result::ErrorDisconnected) {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
int mSpinUpCallbacks = 10; // We will let the streams sync for the first few valid frames
|
||||
const size_t kBufferSize;
|
||||
oboe::AudioStream &inRef;
|
||||
std::function<void(numeric_type *, numeric_type *)> f;
|
||||
std::function<void(void)> restart;
|
||||
std::unique_ptr<numeric_type[]> inputBuffer = std::make_unique<numeric_type[]>(kBufferSize);
|
||||
};
|
||||
|
||||
#endif //ANDROID_FXLAB_DUPLEXCALLBACK_H
|
93
externals/oboe/apps/fxlab/app/src/main/cpp/DuplexEngine.cpp
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "DuplexEngine.h"
|
||||
#include "effects/Effects.h"
|
||||
|
||||
DuplexEngine::DuplexEngine() {
|
||||
beginStreams();
|
||||
}
|
||||
|
||||
void DuplexEngine::beginStreams() {
|
||||
// This ordering is extremely important
|
||||
openInStream();
|
||||
if (inStream->getFormat() == oboe::AudioFormat::Float) {
|
||||
functionList.emplace<FunctionList<float *>>();
|
||||
createCallback<float_t>();
|
||||
} else if (inStream->getFormat() == oboe::AudioFormat::I16) {
|
||||
createCallback<int16_t>();
|
||||
} else {
|
||||
stopStreams();
|
||||
}
|
||||
SAMPLE_RATE = inStream->getSampleRate();
|
||||
openOutStream();
|
||||
|
||||
oboe::Result result = startStreams();
|
||||
if (result != oboe::Result::OK) stopStreams();
|
||||
}
|
||||
|
||||
template<class numeric>
|
||||
void DuplexEngine::createCallback() {
|
||||
mCallback = std::make_unique<DuplexCallback<numeric>>(
|
||||
*inStream, [&functionStack = this->functionList](numeric *beg, numeric *end) {
|
||||
std::get<FunctionList<numeric *>>(functionStack)(beg, end);
|
||||
},
|
||||
inStream->getBufferCapacityInFrames(),
|
||||
std::bind(&DuplexEngine::beginStreams, this));
|
||||
}
|
||||
|
||||
|
||||
oboe::AudioStreamBuilder DuplexEngine::defaultBuilder() {
|
||||
return *oboe::AudioStreamBuilder()
|
||||
.setPerformanceMode(oboe::PerformanceMode::LowLatency)
|
||||
->setSharingMode(oboe::SharingMode::Exclusive);
|
||||
}
|
||||
|
||||
void DuplexEngine::openInStream() {
|
||||
defaultBuilder().setDirection(oboe::Direction::Input)
|
||||
->setFormat(oboe::AudioFormat::Float) // For now
|
||||
->setChannelCount(1) // Mono in for effects processing
|
||||
->openManagedStream(inStream);
|
||||
}
|
||||
|
||||
void DuplexEngine::openOutStream() {
|
||||
defaultBuilder().setCallback(mCallback.get())
|
||||
->setSampleRate(inStream->getSampleRate())
|
||||
->setFormat(inStream->getFormat())
|
||||
->setChannelCount(2) // Stereo out
|
||||
->openManagedStream(outStream);
|
||||
}
|
||||
|
||||
oboe::Result DuplexEngine::startStreams() {
|
||||
oboe::Result result = outStream->requestStart();
|
||||
int64_t timeoutNanos = 500 * 1000000; // arbitrary 1/2 second
|
||||
auto currentState = outStream->getState();
|
||||
auto nextState = oboe::StreamState::Unknown;
|
||||
while (result == oboe::Result::OK && currentState != oboe::StreamState::Started) {
|
||||
result = outStream->waitForStateChange(currentState, &nextState, timeoutNanos);
|
||||
currentState = nextState;
|
||||
}
|
||||
if (result != oboe::Result::OK) return result;
|
||||
return inStream->requestStart();
|
||||
}
|
||||
|
||||
oboe::Result DuplexEngine::stopStreams() {
|
||||
oboe::Result outputResult = inStream->requestStop();
|
||||
oboe::Result inputResult = outStream->requestStop();
|
||||
if (outputResult != oboe::Result::OK) return outputResult;
|
||||
return inputResult;
|
||||
}
|
||||
|
64
externals/oboe/apps/fxlab/app/src/main/cpp/DuplexEngine.h
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef EFFECTS_APP_DUPLEXSTREAM_H
|
||||
#define EFFECTS_APP_DUPLEXSTREAM_H
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <variant>
|
||||
|
||||
#include <oboe/Oboe.h>
|
||||
#include "FunctionList.h"
|
||||
#include "DuplexCallback.h"
|
||||
|
||||
|
||||
class DuplexEngine {
|
||||
public:
|
||||
DuplexEngine();
|
||||
|
||||
void beginStreams();
|
||||
|
||||
virtual ~DuplexEngine() = default;
|
||||
|
||||
oboe::Result startStreams();
|
||||
|
||||
oboe::Result stopStreams();
|
||||
|
||||
|
||||
std::variant<FunctionList<int16_t *>, FunctionList<float *>> functionList{
|
||||
std::in_place_type<FunctionList<int16_t *>>};
|
||||
|
||||
private:
|
||||
|
||||
void openInStream();
|
||||
|
||||
void openOutStream();
|
||||
|
||||
static oboe::AudioStreamBuilder defaultBuilder();
|
||||
|
||||
template<class numeric>
|
||||
void createCallback();
|
||||
|
||||
oboe::ManagedStream inStream;
|
||||
std::unique_ptr<oboe::AudioStreamCallback> mCallback;
|
||||
oboe::ManagedStream outStream;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //EFFECTS_APP_DUPLEXSTREAM_H
|
85
externals/oboe/apps/fxlab/app/src/main/cpp/FunctionList.h
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_FUNCTIONLIST_H
|
||||
#define ANDROID_FXLAB_FUNCTIONLIST_H
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <array>
|
||||
|
||||
template<class iter_type>
|
||||
class FunctionList {
|
||||
std::vector<std::pair<std::function<void(iter_type, iter_type)>, bool>> functionList;
|
||||
bool muted = false;
|
||||
public:
|
||||
FunctionList() = default;
|
||||
|
||||
FunctionList(const FunctionList &) = delete;
|
||||
|
||||
FunctionList &operator=(const FunctionList &) = delete;
|
||||
|
||||
|
||||
void operator()(iter_type begin, iter_type end) {
|
||||
for (auto &f : functionList) {
|
||||
if (f.second == true) std::get<0>(f)(begin, end);
|
||||
}
|
||||
if (muted) std::fill(begin, end, 0);
|
||||
}
|
||||
|
||||
void addEffect(std::function<void(iter_type, iter_type)> f) {
|
||||
functionList.emplace_back(std::move(f), true);
|
||||
}
|
||||
|
||||
void removeEffectAt(unsigned int index) {
|
||||
if (index < functionList.size()) {
|
||||
functionList.erase(std::next(functionList.begin(), index));
|
||||
}
|
||||
}
|
||||
|
||||
void rotateEffectAt(unsigned int from, unsigned int to) {
|
||||
auto &v = functionList;
|
||||
if (from >= v.size() || to >= v.size()) return;
|
||||
if (from <= to) {
|
||||
std::rotate(v.begin() + from, v.begin() + from + 1, v.begin() + to + 1);
|
||||
} else {
|
||||
from = v.size() - 1 - from;
|
||||
to = v.size() - 1 - to;
|
||||
std::rotate(v.rbegin() + from, v.rbegin() + from + 1, v.rbegin() + to + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void modifyEffectAt(size_t index, std::function<void(iter_type, iter_type)> fun) {
|
||||
functionList[index] = {std::move(fun), functionList[index].second};
|
||||
}
|
||||
|
||||
void enableEffectAt(size_t index, bool enable) {
|
||||
functionList[index].second = enable;
|
||||
}
|
||||
|
||||
void mute(bool toMute) {
|
||||
muted = toMute;
|
||||
}
|
||||
|
||||
auto getType() {
|
||||
return iter_type();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif //ANDROID_FXLAB_FUNCTIONLIST_H
|
||||
|
53
externals/oboe/apps/fxlab/app/src/main/cpp/effects/CombFilter.h
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_COMBFILTER_H
|
||||
#define ANDROID_FXLAB_COMBFILTER_H
|
||||
|
||||
#include "utils/DelayLine.h"
|
||||
|
||||
template <class iter_type>
|
||||
class CombFilter {
|
||||
|
||||
public:
|
||||
// delay > 0 in samples
|
||||
CombFilter(float blend, float feedForward, float feedBack, int delay) :
|
||||
kBlend(blend),
|
||||
kFeedForward(feedForward),
|
||||
kFeedBack(feedBack),
|
||||
kDelay(static_cast<size_t>(delay)) {}
|
||||
|
||||
|
||||
void operator () (typename std::iterator_traits<iter_type>::reference x) {
|
||||
auto delayOutput = delayLine[kDelay];
|
||||
auto delayInput = x + kFeedBack * delayOutput;
|
||||
delayLine.push(delayInput);
|
||||
x = delayInput * kBlend + delayOutput * kFeedForward;
|
||||
}
|
||||
void operator () (iter_type begin, iter_type end) {
|
||||
for (; begin != end; ++begin) {
|
||||
operator()(*begin);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Weights
|
||||
const float kBlend;
|
||||
const float kFeedForward;
|
||||
const float kFeedBack;
|
||||
const size_t kDelay;
|
||||
|
||||
DelayLine<typename std::iterator_traits<iter_type>::value_type> delayLine {kDelay + 1};
|
||||
};
|
||||
#endif //ANDROID_FXLAB_COMBFILTER_H
|
79
externals/oboe/apps/fxlab/app/src/main/cpp/effects/DelayLineEffect.h
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_DELAYLINEEFFECT_H
|
||||
#define ANDROID_FXLAB_DELAYLINEEFFECT_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "utils/SineWave.h"
|
||||
#include "utils/DelayLine.h"
|
||||
|
||||
// Abstract class for implementing delay line based effects
|
||||
// This functor retains state (it must be used sequentially)
|
||||
// Effects are float, mono, 48000 hz
|
||||
template <class iter_type>
|
||||
class DelayLineEffect {
|
||||
|
||||
public:
|
||||
// delay > 0, depth in samples, mod is control signal
|
||||
DelayLineEffect(float blend, float feedForward, float feedBack, int delay, int depth, std::function<float()> &&mod) :
|
||||
kBlend(blend),
|
||||
kFeedForward(feedForward),
|
||||
kFeedBack(feedBack),
|
||||
kDelay(delay),
|
||||
kDepth(depth),
|
||||
mMod(mod) { }
|
||||
|
||||
|
||||
void operator () (typename std::iterator_traits<iter_type>::reference x) {
|
||||
auto delayInput = x + kFeedBack * delayLine[kTap];
|
||||
auto variableDelay = mMod() * kDepth + kTap;
|
||||
int index = static_cast<int>(variableDelay);
|
||||
auto fracComp = 1 - (variableDelay - index);
|
||||
//linear
|
||||
// auto interpolated = fracComp * delayLine[index] + (1 - fracComp) * delayLine[index + 1];
|
||||
// all - pass
|
||||
float interpolated = fracComp * delayLine[index] + delayLine[index + 1]
|
||||
- fracComp * prevInterpolated;
|
||||
|
||||
prevInterpolated = interpolated;
|
||||
delayLine.push(delayInput);
|
||||
x = interpolated * kFeedForward + kBlend * delayInput;
|
||||
}
|
||||
void operator () (iter_type begin, iter_type end) {
|
||||
for (; begin != end; ++begin) {
|
||||
operator()(*begin);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Weights
|
||||
const float kBlend;
|
||||
const float kFeedForward;
|
||||
const float kFeedBack;
|
||||
const int kDelay;
|
||||
const int kDepth;
|
||||
const int kTap = kDelay + kDepth;
|
||||
|
||||
// Control function
|
||||
const std::function<float()> mMod;
|
||||
|
||||
// Memory
|
||||
float prevInterpolated = 0; // for all pass interp
|
||||
const size_t kDelayLineSize = kTap + kDepth + 1; // index one is immediate prev sample
|
||||
DelayLine<typename std::iterator_traits<iter_type>::value_type> delayLine {kDelayLineSize};
|
||||
};
|
||||
#endif //ANDROID_FXLAB_DELAYLINEEFFECT_H
|
34
externals/oboe/apps/fxlab/app/src/main/cpp/effects/DoublingEffect.h
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_DOUBLINGEFFECT_H
|
||||
#define ANDROID_FXLAB_DOUBLINGEFFECT_H
|
||||
|
||||
#include "DelayLineEffect.h"
|
||||
#include "utils/WhiteNoise.h"
|
||||
|
||||
|
||||
template <class iter_type>
|
||||
class DoublingEffect: public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
DoublingEffect(float depth_ms, float delay_ms, float noise_pass):
|
||||
DelayLineEffect<iter_type> {0.7071, 0.7071, 0,
|
||||
static_cast<int>(delay_ms * SAMPLE_RATE / 1000),
|
||||
static_cast<int>(depth_ms * SAMPLE_RATE / 1000),
|
||||
std::function<float()>{WhiteNoise{static_cast<int>(4800 * noise_pass)}}}
|
||||
{}
|
||||
};
|
||||
#
|
||||
#endif //ANDROID_FXLAB_DOUBLINGEFFECT_H
|
41
externals/oboe/apps/fxlab/app/src/main/cpp/effects/DriveControl.h
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_DRIVECONTROL_H
|
||||
#define ANDROID_FXLAB_DRIVECONTROL_H
|
||||
|
||||
|
||||
#include <functional>
|
||||
|
||||
template <class iter_type>
|
||||
|
||||
class DriveControl {
|
||||
public:
|
||||
|
||||
DriveControl(std::function<void(iter_type, iter_type)> function, double scale):
|
||||
mFunction(function), kScale(scale) {}
|
||||
|
||||
void operator() (iter_type beg, iter_type end) {
|
||||
std::for_each(beg, end, [this](auto &x){x *= kScale;});
|
||||
mFunction(beg, end);
|
||||
std::for_each(beg, end, [this](auto &x){x *= recip;});
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(iter_type, iter_type)> mFunction;
|
||||
const double kScale;
|
||||
const double recip = 1 / kScale;
|
||||
};
|
||||
#endif //ANDROID_FXLAB_DRIVECONTROL_H
|
33
externals/oboe/apps/fxlab/app/src/main/cpp/effects/EchoEffect.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_ECHOEFFECT_H
|
||||
#define ANDROID_FXLAB_ECHOEFFECT_H
|
||||
|
||||
#include "DelayLineEffect.h"
|
||||
#include "utils/WhiteNoise.h"
|
||||
|
||||
|
||||
template <class iter_type>
|
||||
class EchoEffect: public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
EchoEffect(float feedback, float delay_ms):
|
||||
DelayLineEffect<iter_type> {1, 0, feedback,
|
||||
static_cast<int>(delay_ms * SAMPLE_RATE / 1000),
|
||||
0,
|
||||
std::function<float()>{[](){return 0.0;}}}
|
||||
{}
|
||||
};
|
||||
#endif //ANDROID_FXLAB_ECHOEFFECT_H
|
61
externals/oboe/apps/fxlab/app/src/main/cpp/effects/Effects.h
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_EFFECTS_H
|
||||
#define ANDROID_FXLAB_EFFECTS_H
|
||||
|
||||
|
||||
// The Sample Rate for effects
|
||||
static int SAMPLE_RATE = 48000;
|
||||
|
||||
// This header should include the various effect descriptions
|
||||
#include "descrip/EffectDescription.h"
|
||||
#include "descrip/PassthroughDescription.h"
|
||||
#include "descrip/VibratoDescription.h"
|
||||
#include "descrip/TremoloDescription.h"
|
||||
#include "descrip/GainDescription.h"
|
||||
#include "descrip/FlangerDescription.h"
|
||||
#include "descrip/WhiteChorusDescription.h"
|
||||
#include "descrip/FIRDescription.h"
|
||||
#include "descrip/IIRDescription.h"
|
||||
#include "descrip/AllPassDescription.h"
|
||||
#include "descrip/DoublingDescription.h"
|
||||
#include "descrip/OverdriveDescription.h"
|
||||
#include "descrip/DistortionDescription.h"
|
||||
#include "descrip/EchoDescription.h"
|
||||
#include "descrip/SlapbackDescription.h"
|
||||
|
||||
constexpr std::tuple<
|
||||
Effect::PassthroughDescription,
|
||||
Effect::TremoloDescription,
|
||||
Effect::VibratoDescription,
|
||||
Effect::GainDescription,
|
||||
Effect::FlangerDescription,
|
||||
Effect::WhiteChorusDescription,
|
||||
Effect::FIRDescription,
|
||||
Effect::IIRDescription,
|
||||
Effect::AllPassDescription,
|
||||
Effect::DoublingDescription,
|
||||
Effect::OverdriveDescription,
|
||||
Effect::DistortionDescription,
|
||||
Effect::EchoDescription,
|
||||
Effect::SlapbackDescription
|
||||
> EffectsTuple{};
|
||||
|
||||
constexpr size_t numEffects = std::tuple_size<decltype(EffectsTuple)>::value;
|
||||
|
||||
|
||||
#endif //ANDROID_FXLAB_EFFECTS_H
|
29
externals/oboe/apps/fxlab/app/src/main/cpp/effects/FlangerEffect.h
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_FLANGEREFFECT_H
|
||||
#define ANDROID_FXLAB_FLANGEREFFECT_H
|
||||
|
||||
#include "DelayLineEffect.h"
|
||||
|
||||
template<class iter_type>
|
||||
class FlangerEffect : public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
// feedback should be 0.7071
|
||||
FlangerEffect(float depth_ms, float frequency, float feedback):
|
||||
DelayLineEffect<iter_type>(feedback, feedback, feedback, 0, depth_ms * SAMPLE_RATE / 1000,
|
||||
SineWave {frequency, 1, SAMPLE_RATE}) { }
|
||||
};
|
||||
#endif //ANDROID_FXLAB_FLANGEREFFECT_H
|
56
externals/oboe/apps/fxlab/app/src/main/cpp/effects/SingleFunctionEffects.h
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_SINGLEFUNCTIONEFFECTS_H
|
||||
#define ANDROID_FXLAB_SINGLEFUNCTIONEFFECTS_H
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace SingleFunctionEffects {
|
||||
|
||||
template<class floating>
|
||||
void _overdrive (floating &x) {
|
||||
static constexpr double third = (1.0 / 3.0);
|
||||
auto abs = std::abs(x);
|
||||
if (abs <= third) {
|
||||
x *= 2;
|
||||
} else if (abs <= 2 * third) {
|
||||
x = std::copysign((3 - (2 - 3 * abs) * (2 - 3 * abs)) * third, x);
|
||||
} else {
|
||||
x = std::copysign(1, x);
|
||||
}
|
||||
}
|
||||
|
||||
template <class iter_type>
|
||||
void overdrive(iter_type beg, iter_type end) {
|
||||
for (; beg != end; ++beg){
|
||||
_overdrive(*beg);
|
||||
}
|
||||
}
|
||||
|
||||
template <class floating>
|
||||
void _distortion (floating &x) {
|
||||
x = std::copysign(-std::expm1(-std::abs(x)), x);
|
||||
}
|
||||
|
||||
template <class iter_type>
|
||||
void distortion(iter_type beg, iter_type end) {
|
||||
for (; beg != end; ++beg) {
|
||||
_distortion(*beg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif //ANDROID_FXLAB_SINGLEFUNCTIONEFFECTS_H
|
30
externals/oboe/apps/fxlab/app/src/main/cpp/effects/SlapbackEffect.h
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_SLAPBACKEFFECT_H
|
||||
#define ANDROID_FXLAB_SLAPBACKEFFECT_H
|
||||
|
||||
template <class iter_type>
|
||||
class SlapbackEffect: public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
SlapbackEffect(float feedforward, float delay_ms):
|
||||
DelayLineEffect<iter_type> {1, feedforward, 0,
|
||||
static_cast<int>(delay_ms * SAMPLE_RATE / 1000),
|
||||
0,
|
||||
std::function<float()>{[](){return 0.0;}}}
|
||||
{}
|
||||
};
|
||||
#endif //ANDROID_FXLAB_SLAPBACKEFFECT_H
|
43
externals/oboe/apps/fxlab/app/src/main/cpp/effects/TremoloEffect.h
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_TREMOLOEFFECT_H
|
||||
#define ANDROID_FXLAB_TREMOLOEFFECT_H
|
||||
|
||||
|
||||
#include "utils/SineWave.h"
|
||||
|
||||
class TremoloEffect {
|
||||
public:
|
||||
TremoloEffect(float frequency, float height):
|
||||
kCenter(1 - height),
|
||||
kSignal {SineWave{frequency, height, SAMPLE_RATE}} { }
|
||||
|
||||
template <class numeric_type>
|
||||
void operator () (numeric_type &x) {
|
||||
x = x * (kSignal() + kCenter);
|
||||
}
|
||||
template <class iter_type>
|
||||
void operator () (iter_type begin, iter_type end) {
|
||||
for (; begin != end; ++begin) {
|
||||
operator()(*begin);
|
||||
}
|
||||
}
|
||||
private:
|
||||
const float kCenter;
|
||||
std::function<float()> kSignal;
|
||||
};
|
||||
#endif //ANDROID_FXLAB_TREMOLOEFFECT_H
|
27
externals/oboe/apps/fxlab/app/src/main/cpp/effects/VibratroEffect.h
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_VIBRATROEFFECT_H
|
||||
#define ANDROID_FXLAB_VIBRATROEFFECT_H
|
||||
|
||||
#include "DelayLineEffect.h"
|
||||
template <class iter_type>
|
||||
class VibratoEffect : public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
VibratoEffect(float depth_ms, float frequency):
|
||||
DelayLineEffect<iter_type>(0, 1, 0, 1, depth_ms * SAMPLE_RATE / 1000,
|
||||
SineWave {frequency, 1, SAMPLE_RATE}) { }
|
||||
};
|
||||
#endif //ANDROID_FXLAB_VIBRATROEFFECT_H
|
32
externals/oboe/apps/fxlab/app/src/main/cpp/effects/WhiteChorusEffect.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_WHITECHORUSEFFECT_H
|
||||
#define ANDROID_FXLAB_WHITECHORUSEFFECT_H
|
||||
|
||||
#include "DelayLineEffect.h"
|
||||
#include "utils/WhiteNoise.h"
|
||||
|
||||
template <class iter_type>
|
||||
class WhiteChorusEffect : public DelayLineEffect<iter_type> {
|
||||
public:
|
||||
WhiteChorusEffect(float depth_ms, float delay_ms, float noise_pass):
|
||||
DelayLineEffect<iter_type> {0.7071, 1, -0.7071f,
|
||||
static_cast<int>(delay_ms * SAMPLE_RATE / 1000),
|
||||
static_cast<int>(depth_ms * SAMPLE_RATE / 1000),
|
||||
std::function<float()>{WhiteNoise{static_cast<int>(4800 * noise_pass)}}}
|
||||
{}
|
||||
};
|
||||
#endif //ANDROID_FXLAB_WHITECHORUSEFFECT_H
|
48
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/AllPassDescription.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_ALLPASSDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_ALLPASSDESCRIPTION_H
|
||||
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../CombFilter.h"
|
||||
namespace Effect {
|
||||
class AllPassDescription: public EffectDescription<AllPassDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("AllPass");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Comb");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Delay (samples)", 1, 500, 10),
|
||||
ParamType("Scale", 0.01, 0.99, 0.5),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
CombFilter<iter_type>{paramArr[1], 1, -(paramArr[1]), static_cast<int>(paramArr[0])}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
|
||||
#endif //ANDROID_FXLAB_ALLPASSDESCRIPTION_H
|
46
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/DistortionDescription.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_DISTORTIONDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_DISTORTIONDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../SingleFunctionEffects.h"
|
||||
|
||||
namespace Effect {
|
||||
class DistortionDescription: public EffectDescription<DistortionDescription, 1> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Distortion");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Nonlinear");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Drive (db)", -10, 50, 0)
|
||||
};
|
||||
}
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
double scale = pow(2.0, paramArr[0] / 10);
|
||||
return DriveControl<iter_type> {SingleFunctionEffects::distortion<iter_type>, scale};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //ANDROID_FXLAB_DISTORTIONDESCRIPTION_H
|
33
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/DoublingDescription.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef ANDROID_FXLAB_DOUBLINGDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_DOUBLINGDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../DoublingEffect.h"
|
||||
|
||||
namespace Effect {
|
||||
class DoublingDescription: public EffectDescription<DoublingDescription, 3> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Doubling");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Depth (ms)", 10, 100, 40),
|
||||
ParamType("Delay (ms)", 1, 100, 40),
|
||||
ParamType("Noise pass", 1, 10, 4),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
DoublingEffect<iter_type>{paramArr[0], paramArr[1], paramArr[2]}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
#endif //ANDROID_FXLAB_DOUBLINGDESCRIPTION_H
|
48
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/EchoDescription.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_ECHODESCRIPTION_H
|
||||
#define ANDROID_FXLAB_ECHODESCRIPTION_H
|
||||
|
||||
#include "../EchoEffect.h"
|
||||
|
||||
namespace Effect {
|
||||
|
||||
class EchoDescription: public EffectDescription<EchoDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Echo");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Feedback", 0, 1, 0.5),
|
||||
ParamType("Delay (ms)", 50, 500, 100),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
EchoEffect<iter_type>{paramArr[0], paramArr[1]}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace Effect
|
||||
#endif //ANDROID_FXLAB_ECHODESCRIPTION_H
|
107
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/EffectDescription.h
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_EFFECTDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_EFFECTDESCRIPTION_H
|
||||
|
||||
#include <functional>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
|
||||
template<class iter_type>
|
||||
using _ef = std::function<void(iter_type, iter_type)>;
|
||||
|
||||
// Only Effect Descriptions should use this namespace
|
||||
namespace Effect {
|
||||
|
||||
class ParamType {
|
||||
public:
|
||||
constexpr ParamType(std::string_view name, float minVal, float maxVal, float defVal) :
|
||||
kName(name),
|
||||
kMinVal(minVal),
|
||||
kMaxVal(maxVal),
|
||||
kDefVal(defVal) {}
|
||||
|
||||
constexpr ParamType(const ParamType &other) = delete;
|
||||
|
||||
ParamType &operator=(const ParamType &other) = delete;
|
||||
|
||||
constexpr ParamType(ParamType &&other) = default;
|
||||
|
||||
constexpr ParamType &operator=(ParamType &&other) = delete;
|
||||
|
||||
const std::string_view kName;
|
||||
const float kMinVal, kMaxVal, kDefVal;
|
||||
};
|
||||
|
||||
|
||||
// EffectType is the description subclass, N is num of params
|
||||
// Function implementations in this class contain shared behavior
|
||||
// Which can be shadowed.
|
||||
template<class EffectType, size_t N>
|
||||
class EffectDescription {
|
||||
public:
|
||||
// These methods will be shadowed by subclasses
|
||||
|
||||
static constexpr size_t getNumParams() {
|
||||
return N;
|
||||
}
|
||||
|
||||
static constexpr std::array<float, N> getEmptyParams() {
|
||||
return std::array<float, EffectType::getNumParams()>();
|
||||
}
|
||||
|
||||
static constexpr std::string_view getName();
|
||||
|
||||
static constexpr std::string_view getCategory();
|
||||
|
||||
static constexpr std::array<ParamType, N> getParams();
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, N> paramArr);
|
||||
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildDefaultEffect() {
|
||||
auto params = EffectType::getEmptyParams();
|
||||
int i = 0;
|
||||
for (ParamType &mParam: EffectType::getParams()) {
|
||||
params[i++] = mParam.kDefVal;
|
||||
}
|
||||
return EffectType::template buildEffect<iter_type>(params);
|
||||
}
|
||||
|
||||
// The default behavior is new effect, can be shadowed
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> modifyEffect(
|
||||
_ef<iter_type> /* effect */, std::array<float, N> paramArr) {
|
||||
return EffectType::template buildEffect<iter_type>(std::move(paramArr));
|
||||
}
|
||||
template <class iter_type>
|
||||
static _ef<iter_type> modifyEffectVec(
|
||||
_ef<iter_type> effect, std::vector<float> paramVec) {
|
||||
std::array<float, N> arr;
|
||||
std::copy_n(paramVec.begin(), N, arr.begin());
|
||||
return EffectType::template modifyEffect<iter_type>(
|
||||
std::move(effect), std::move(arr));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace effect
|
||||
|
||||
|
||||
#endif //ANDROID_FXLAB_EFFECTDESCRIPTION_H
|
46
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/FIRDescription.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_FIRDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_FIRDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../CombFilter.h"
|
||||
namespace Effect {
|
||||
class FIRDescription: public EffectDescription<FIRDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("FIR");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Comb");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Delay (samples)", 1, 500, 10),
|
||||
ParamType("Gain", 0, 0.99, 0.5),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
CombFilter<iter_type>{1, paramArr[1], 0, static_cast<int>(paramArr[0])}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
#endif //ANDROID_FXLAB_FIRDESCRIPTION_H
|
50
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/FlangerDescription.h
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_FLANGERDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_FLANGERDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../FlangerEffect.h"
|
||||
|
||||
namespace Effect {
|
||||
class FlangerDescription : public EffectDescription<FlangerDescription, 3> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Flanger");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, 3> {
|
||||
ParamType("Depth (ms)", 0.1, 2, 1),
|
||||
ParamType("Frequency", 0.1, 1, 0.2),
|
||||
ParamType("Feedback", 0, 0.95, 0.7071),
|
||||
};
|
||||
}
|
||||
|
||||
template <class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return std::function<void(iter_type, iter_type)> {
|
||||
FlangerEffect<iter_type>{paramArr[0], paramArr[1], paramArr[2]}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
} // namespace Effect
|
||||
#endif //ANDROID_FXLAB_FLANGERDESCRIPTION_H
|
50
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/GainDescription.h
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_GAINDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_GAINDESCRIPTION_H
|
||||
#include "EffectDescription.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
namespace Effect {
|
||||
class GainDescription : public EffectDescription<GainDescription, 1> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Gain");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("None");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array <ParamType, getNumParams()> {
|
||||
ParamType("Gain", -30, 20, 0)
|
||||
};
|
||||
}
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
float scale = paramArr[0] / 10;
|
||||
return _ef<iter_type> {
|
||||
[=](iter_type beg, iter_type end) {
|
||||
for (; beg != end; ++beg) *beg *= pow(2.0, scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
} // namespace Effect
|
||||
#endif //ANDROID_FXLAB_GAINDESCRIPTION_H
|
50
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/IIRDescription.h
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_IIRDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_IIRDESCRIPTION_H
|
||||
|
||||
|
||||
#include "../CombFilter.h"
|
||||
|
||||
namespace Effect {
|
||||
class IIRDescription: public EffectDescription<IIRDescription, 3> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("IIR");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Comb");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Delay (samples)", 1, 500, 10),
|
||||
ParamType("Gain", 0, 0.99, 0.5),
|
||||
ParamType("Scale", 0.25, 0.99, 0.5)
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
CombFilter<iter_type>{paramArr[2], 0, paramArr[1], static_cast<int>(paramArr[0])}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
#
|
||||
#endif //ANDROID_FXLAB_IIRDESCRIPTION_H
|
51
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/OverdriveDescription.h
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
|
||||
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../SingleFunctionEffects.h"
|
||||
#include "../DriveControl.h"
|
||||
|
||||
namespace Effect {
|
||||
class OverdriveDescription : public EffectDescription<OverdriveDescription, 1> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Overdrive");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Nonlinear");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()>{
|
||||
ParamType("Drive (db)", -10, 50, 0)
|
||||
};
|
||||
}
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
double scale = pow(2.0, paramArr[0] / 10);
|
||||
return DriveControl<iter_type> {SingleFunctionEffects::overdrive<iter_type>, scale};
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif //ANDROID_FXLAB_OVERDRIVEDESCRIPTION_H
|
48
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/PassthroughDescription.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_PASSTHROUGHDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_PASSTHROUGHDESCRIPTION_H
|
||||
|
||||
|
||||
#include "EffectDescription.h"
|
||||
|
||||
namespace Effect {
|
||||
|
||||
class PassthroughDescription : public EffectDescription<PassthroughDescription, 0> {
|
||||
public:
|
||||
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Passthrough");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("None");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, 0>();
|
||||
}
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> ) {
|
||||
return [](iter_type, iter_type) {};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Effect
|
||||
|
||||
#endif //ANDROID_FXLAB_PASSTHROUGHDESCRIPTION_H
|
50
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/SlapbackDescription.h
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_SLAPBACKDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_SLAPBACKDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../SlapbackEffect.h"
|
||||
|
||||
|
||||
namespace Effect {
|
||||
|
||||
class SlapbackDescription: public EffectDescription<SlapbackDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Slapback");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Feedforward", 0, 2, 0.5),
|
||||
ParamType("Delay (ms)", 30, 100, 50),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
SlapbackEffect<iter_type>{paramArr[0], paramArr[1]}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace Effect
|
||||
#endif //ANDROID_FXLAB_SLAPBACKDESCRIPTION_H
|
46
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/TremoloDescription.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_TREMOLODESCRIPTION_H
|
||||
#define ANDROID_FXLAB_TREMOLODESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../TremoloEffect.h"
|
||||
namespace Effect {
|
||||
class TremoloDescription : public EffectDescription<TremoloDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Tremolo");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("None");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Frequency", 0.1, 5.0, 2),
|
||||
ParamType("Height", 0.05, 0.45, 0.25)
|
||||
};
|
||||
}
|
||||
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr ) {
|
||||
return _ef<iter_type> {
|
||||
TremoloEffect {paramArr[0], paramArr[1]}};
|
||||
}
|
||||
};
|
||||
} // namespace Effect
|
||||
#endif // ANDROID_FXLAB_TREMOLODESCRIPTION_H
|
47
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/VibratoDescription.h
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_VIBRATODESCRIPTION_H
|
||||
#define ANDROID_FXLAB_VIBRATODESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../VibratroEffect.h"
|
||||
|
||||
namespace Effect {
|
||||
class VibratoDescription : public EffectDescription<VibratoDescription, 2> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("Vibrato");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Depth (ms)", 0, 3, 1),
|
||||
ParamType("Frequency", 0.1, 5, 1)
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
VibratoEffect<iter_type>{paramArr[0], paramArr[1]}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
#endif //ANDROID_FXLAB_VIBRATODESCRIPTION_H
|
49
externals/oboe/apps/fxlab/app/src/main/cpp/effects/descrip/WhiteChorusDescription.h
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
|
||||
#define ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
|
||||
|
||||
#include "EffectDescription.h"
|
||||
#include "../WhiteChorusEffect.h"
|
||||
|
||||
namespace Effect {
|
||||
class WhiteChorusDescription : public EffectDescription<WhiteChorusDescription, 3> {
|
||||
public:
|
||||
static constexpr std::string_view getName() {
|
||||
return std::string_view("White Chorus");
|
||||
}
|
||||
|
||||
static constexpr std::string_view getCategory() {
|
||||
return std::string_view("Delay");
|
||||
}
|
||||
|
||||
static constexpr std::array<ParamType, getNumParams()> getParams() {
|
||||
return std::array<ParamType, getNumParams()> {
|
||||
ParamType("Depth (ms)", 1, 30, 10),
|
||||
ParamType("Delay (ms)", 1, 30, 10),
|
||||
ParamType("Noise pass", 1, 10, 4),
|
||||
};
|
||||
}
|
||||
template<class iter_type>
|
||||
static _ef<iter_type> buildEffect(std::array<float, getNumParams()> paramArr) {
|
||||
return _ef<iter_type> {
|
||||
WhiteChorusEffect<iter_type>{paramArr[0], paramArr[1], paramArr[2]}
|
||||
};
|
||||
}
|
||||
};
|
||||
} //namespace Effect
|
||||
|
||||
#endif //ANDROID_FXLAB_WHITECHORUSDESCRIPTION_H
|
44
externals/oboe/apps/fxlab/app/src/main/cpp/effects/utils/DelayLine.h
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_DELAYLINE_H
|
||||
#define ANDROID_FXLAB_DELAYLINE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
template<class T>
|
||||
class DelayLine {
|
||||
public:
|
||||
DelayLine(std::size_t size): N(size), mArr(N, 0) { }
|
||||
void push(const T& value) {
|
||||
mArr[mfront++] = value;
|
||||
if (mfront == N) mfront = 0;
|
||||
}
|
||||
// indexed from last value written backwards
|
||||
// i.e T-1 to T-N
|
||||
const T& operator[](int i) {
|
||||
int index = mfront - i;
|
||||
if (index < 0) index += N;
|
||||
return mArr[index];
|
||||
}
|
||||
|
||||
private:
|
||||
const int N;
|
||||
int mfront = 0;
|
||||
std::vector<T> mArr;
|
||||
};
|
||||
#endif //ANDROID_FXLAB_DELAYLINE_H
|
41
externals/oboe/apps/fxlab/app/src/main/cpp/effects/utils/PhaseAccumulator.h
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_PHASEACCUMULATOR_H
|
||||
#define ANDROID_FXLAB_PHASEACCUMULATOR_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
|
||||
|
||||
class PhaseAccumulator {
|
||||
public:
|
||||
PhaseAccumulator(float frequency, float sampleRate):
|
||||
f(frequency),
|
||||
fs(sampleRate) { }
|
||||
float incrementPhase() {
|
||||
mPhase += kDelta;
|
||||
if (mPhase >= kTwoPi) mPhase -= kTwoPi;
|
||||
return mPhase;
|
||||
}
|
||||
private:
|
||||
float mPhase = 0;
|
||||
const float f;
|
||||
const float fs;
|
||||
static constexpr float kTwoPi = M_PI * 2;
|
||||
const float kDelta = kTwoPi * f / fs;
|
||||
};
|
||||
#endif //ANDROID_FXLAB_PHASEACCUMULATOR_H
|
37
externals/oboe/apps/fxlab/app/src/main/cpp/effects/utils/SineWave.h
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_SINEWAVE_H
|
||||
#define ANDROID_FXLAB_SINEWAVE_H
|
||||
|
||||
#include "PhaseAccumulator.h"
|
||||
|
||||
class SineWave {
|
||||
public:
|
||||
// freq in hz
|
||||
SineWave(float frequency, float amplitude, int sampleRate):
|
||||
mPhasor(frequency, sampleRate),
|
||||
kAmplitude(amplitude) { }
|
||||
|
||||
float operator() () {
|
||||
return kAmplitude * sinf(mPhasor.incrementPhase());
|
||||
}
|
||||
|
||||
private:
|
||||
PhaseAccumulator mPhasor;
|
||||
const float kAmplitude;
|
||||
};
|
||||
#endif //ANDROID_FXLAB_SINEWAVE_H
|
36
externals/oboe/apps/fxlab/app/src/main/cpp/effects/utils/WhiteNoise.h
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_WHITENOISE_H
|
||||
#define ANDROID_FXLAB_WHITENOISE_H
|
||||
class WhiteNoise {
|
||||
const int kScale;
|
||||
public:
|
||||
WhiteNoise(int scale): kScale(scale) {}
|
||||
float operator() () {
|
||||
static int counter = 0;
|
||||
static float r_0, r_1 = 0;
|
||||
if (counter == 0) {
|
||||
r_0 = r_1;
|
||||
r_1 = (static_cast <float> (rand()) / static_cast <float> (RAND_MAX)) * 2 - 1;
|
||||
}
|
||||
float ret = r_0 + counter * (r_1 - r_0) / kScale;
|
||||
if (++counter == kScale) counter = 0;
|
||||
if (ret > 0.99) return 0.99f;
|
||||
if (ret < -0.99) return -0.99f;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
#endif //ANDROID_FXLAB_WHITENOISE_H
|
46
externals/oboe/apps/fxlab/app/src/main/cpp/logging_macros.h
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef __SAMPLE_ANDROID_DEBUG_H__
|
||||
#define __SAMPLE_ANDROID_DEBUG_H__
|
||||
#include <android/log.h>
|
||||
|
||||
#if 1
|
||||
#ifndef MODULE_NAME
|
||||
#define MODULE_NAME "AUDIO-APP"
|
||||
#endif
|
||||
|
||||
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, MODULE_NAME, __VA_ARGS__)
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, MODULE_NAME, __VA_ARGS__)
|
||||
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, MODULE_NAME, __VA_ARGS__)
|
||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,MODULE_NAME, __VA_ARGS__)
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,MODULE_NAME, __VA_ARGS__)
|
||||
#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,MODULE_NAME, __VA_ARGS__)
|
||||
|
||||
#define ASSERT(cond, ...) if (!(cond)) {__android_log_assert(#cond, MODULE_NAME, __VA_ARGS__);}
|
||||
#else
|
||||
|
||||
#define LOGV(...)
|
||||
#define LOGD(...)
|
||||
#define LOGI(...)
|
||||
#define LOGW(...)
|
||||
#define LOGE(...)
|
||||
#define LOGF(...)
|
||||
#define ASSERT(cond, ...)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __SAMPLE_ANDROID_DEBUG_H__
|
160
externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp
vendored
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "DuplexEngine.h"
|
||||
#include "effects/Effects.h"
|
||||
#include "FunctionList.h"
|
||||
|
||||
|
||||
// JNI Utility functions and globals
|
||||
static DuplexEngine *enginePtr = nullptr;
|
||||
|
||||
// Actual JNI interface
|
||||
extern "C" {
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_createAudioEngine(
|
||||
JNIEnv,
|
||||
jobject /* this */) {
|
||||
enginePtr = new DuplexEngine();
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_destroyAudioEngine(
|
||||
JNIEnv,
|
||||
jobject /* this */) {
|
||||
if (!enginePtr) return;
|
||||
delete enginePtr;
|
||||
enginePtr = nullptr;
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_getEffects(JNIEnv *env, jobject) {
|
||||
jclass jcl = env->FindClass("com/mobileer/androidfxlab/datatype/EffectDescription");
|
||||
jclass jparamcl = env->FindClass("com/mobileer/androidfxlab/datatype/ParamDescription");
|
||||
assert (jcl != nullptr && jparamcl != nullptr);
|
||||
|
||||
auto jparamMethodId = env->GetMethodID(jparamcl, "<init>", "(Ljava/lang/String;FFF)V");
|
||||
auto jMethodId = env->GetMethodID(jcl, "<init>",
|
||||
"(Ljava/lang/String;Ljava/lang/String;I[Lcom/mobileer/androidfxlab/datatype/ParamDescription;)V");
|
||||
|
||||
auto arr = env->NewObjectArray(numEffects, jcl, nullptr);
|
||||
auto lambda = [&](auto &arg, int i) {
|
||||
const auto ¶mArr = arg.getParams();
|
||||
auto jparamArr = env->NewObjectArray(paramArr.size(), jparamcl, nullptr);
|
||||
int c = 0;
|
||||
for (auto const &elem: paramArr) {
|
||||
jobject j = env->NewObject(jparamcl, jparamMethodId,
|
||||
env->NewStringUTF(std::string(elem.kName).c_str()),
|
||||
elem.kMinVal, elem.kMaxVal, elem.kDefVal);
|
||||
assert(j != nullptr);
|
||||
env->SetObjectArrayElement(jparamArr, c++, j);
|
||||
}
|
||||
jobject j = env->NewObject(jcl, jMethodId,
|
||||
env->NewStringUTF(std::string(arg.getName()).c_str()),
|
||||
env->NewStringUTF(std::string(arg.getCategory()).c_str()),
|
||||
i, jparamArr);
|
||||
assert(j != nullptr);
|
||||
env->SetObjectArrayElement(arr, i, j);
|
||||
};
|
||||
int i = 0;
|
||||
std::apply([&i, &lambda](auto &&... args) mutable { ((lambda(args, i++)), ...); },
|
||||
EffectsTuple);
|
||||
return arr;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_addDefaultEffectNative(JNIEnv *, jobject, jint jid) {
|
||||
if (!enginePtr) return;
|
||||
auto id = static_cast<int>(jid);
|
||||
|
||||
std::visit([id](auto &&stack) {
|
||||
std::function<void(decltype(stack.getType()), decltype(stack.getType()))> f;
|
||||
int i = 0;
|
||||
std::apply([id, &f, &i](auto &&... args) mutable {
|
||||
((f = (i++ == id) ?
|
||||
args.template buildDefaultEffect<decltype(stack.getType())>() : f), ...);
|
||||
}, EffectsTuple);
|
||||
stack.addEffect(std::move(f));
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_removeEffectNative(JNIEnv *, jobject, jint jind) {
|
||||
if (!enginePtr) return;
|
||||
auto ind = static_cast<size_t>(jind);
|
||||
std::visit([ind](auto &&arg) {
|
||||
arg.removeEffectAt(ind);
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_rotateEffectNative(JNIEnv *, jobject,
|
||||
jint jfrom, jint jto) {
|
||||
if (!enginePtr) return;
|
||||
auto from = static_cast<size_t>(jfrom);
|
||||
auto to = static_cast<size_t>(jto);
|
||||
|
||||
std::visit([from, to](auto &&arg) {
|
||||
arg.rotateEffectAt(from, to);
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_modifyEffectNative(
|
||||
JNIEnv *env, jobject, jint jid, jint jindex, jfloatArray params) {
|
||||
if (!enginePtr) return;
|
||||
int id = static_cast<int>(jid);
|
||||
int index = static_cast<size_t>(jindex);
|
||||
|
||||
jfloat *data = env->GetFloatArrayElements(params, nullptr);
|
||||
std::vector<float> arr{data, data + env->GetArrayLength(params)};
|
||||
env->ReleaseFloatArrayElements(params, data, 0);
|
||||
std::visit([&arr, &id, &index](auto &&stack) {
|
||||
std::function<void(decltype(stack.getType()), decltype(stack.getType()))> ef;
|
||||
int i = 0;
|
||||
std::apply([&](auto &&... args) mutable {
|
||||
((ef = (i++ == id) ?
|
||||
args.modifyEffectVec(ef, arr) : ef), ...);
|
||||
}, EffectsTuple);
|
||||
stack.modifyEffectAt(index, std::move(ef));
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_enableEffectNative(
|
||||
JNIEnv *, jobject, jint jindex, jboolean jenable) {
|
||||
if (!enginePtr) return;
|
||||
auto ind = static_cast<size_t>(jindex);
|
||||
auto enable = static_cast<bool>(jenable);
|
||||
std::visit([ind, enable](auto &&args) {
|
||||
args.enableEffectAt(ind, enable);
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mobileer_androidfxlab_NativeInterface_enablePassthroughNative(
|
||||
JNIEnv *, jobject, jboolean jenable) {
|
||||
if (!enginePtr) return;
|
||||
std::visit([enable = static_cast<bool>(jenable)](auto &&args) {
|
||||
args.mute(!enable);
|
||||
}, enginePtr->functionList);
|
||||
}
|
||||
} //extern C
|
||||
|
5
externals/oboe/apps/fxlab/app/src/main/cpp/tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
runTests
|
15
externals/oboe/apps/fxlab/app/src/main/cpp/tests/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
project(Effects_Tests)
|
||||
# We need C++17 to test
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Locate GTest
|
||||
find_package(GTest REQUIRED)
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
|
||||
# Link runTests with what we want to test and the GTest and pthread library
|
||||
add_executable(runTests testEffects.cpp)
|
||||
target_link_libraries(runTests ${GTEST_LIBRARIES} pthread)
|
52
externals/oboe/apps/fxlab/app/src/main/cpp/tests/DelayLineEffectTest.h
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_DELAYLINEEFFECTTEST_H
|
||||
#define ANDROID_FXLAB_DELAYLINEEFFECTTEST_H
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../effects/DelayLineEffect.h"
|
||||
|
||||
|
||||
namespace {
|
||||
TEST(DelayLineEffectTest, SingleFeedForwardTest) {
|
||||
DelayLineEffect<float*> e1 {0, 1, 0, 1, 0, [](){return 0;}};
|
||||
std::array<float, 5> inputData {1, 0, 0.5, 0.25, 0};
|
||||
for (int i = 0; i < 5; i++){
|
||||
e1(inputData[i]);
|
||||
}
|
||||
EXPECT_EQ(inputData[0], 0);
|
||||
EXPECT_EQ(inputData[1], 1);
|
||||
EXPECT_EQ(inputData[2], 0);
|
||||
EXPECT_EQ(inputData[3], 0.5);
|
||||
EXPECT_EQ(inputData[4], 0.25);
|
||||
}
|
||||
TEST(DelayLineEffectTest, FFandBlendTest) {
|
||||
DelayLineEffect<float*> e1 {1, 1, 0, 1, 0, [](){return 0;}};
|
||||
std::array<float, 5> inputData {1, 0, 0.5, 0.25, 0};
|
||||
for (int i = 0; i < 5; i++) {
|
||||
e1(inputData[i]);
|
||||
}
|
||||
EXPECT_EQ(inputData[0], 1);
|
||||
EXPECT_EQ(inputData[1], 1);
|
||||
EXPECT_EQ(inputData[2], 0.5);
|
||||
EXPECT_EQ(inputData[3], 0.75);
|
||||
EXPECT_EQ(inputData[4], 0.25);
|
||||
}
|
||||
}
|
||||
#endif //ANDROID_FXLAB_DELAYLINEEFFECTTEST_H
|
61
externals/oboe/apps/fxlab/app/src/main/cpp/tests/DelayLineTest.h
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_FXLAB_DELAYLINETEST_H
|
||||
#define ANDROID_FXLAB_DELAYLINETEST_H
|
||||
|
||||
#include "../effects/utils/DelayLine.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace {
|
||||
TEST(DelayLineTest, CreateAndAdd) {
|
||||
DelayLine<float> d1{10};
|
||||
d1.push(1.0);
|
||||
EXPECT_EQ(d1[1], 1.0);
|
||||
}
|
||||
TEST(DelayLineTest, UnfilledAddSequence) {
|
||||
DelayLine<float> d1{10};
|
||||
d1.push(1.0);
|
||||
d1.push(2.0);
|
||||
d1.push(3.0);
|
||||
EXPECT_EQ(d1[1], 3.0);
|
||||
EXPECT_EQ(d1[2], 2.0);
|
||||
EXPECT_EQ(d1[3], 1.0);
|
||||
}
|
||||
TEST(DelayLineTest, FilledAddSequence) {
|
||||
DelayLine<float> d1{4};
|
||||
d1.push(1.0);
|
||||
d1.push(2.0);
|
||||
d1.push(3.0);
|
||||
d1.push(4.0);
|
||||
EXPECT_EQ(d1[1], 4.0);
|
||||
EXPECT_EQ(d1[2], 3.0);
|
||||
EXPECT_EQ(d1[3], 2.0);
|
||||
EXPECT_EQ(d1[4], 1.0);
|
||||
d1.push(5.0);
|
||||
EXPECT_EQ(d1[1], 5.0);
|
||||
EXPECT_EQ(d1[2], 4.0);
|
||||
EXPECT_EQ(d1[3], 3.0);
|
||||
EXPECT_EQ(d1[4], 2.0);
|
||||
d1.push(6.0);
|
||||
EXPECT_EQ(d1[1], 6.0);
|
||||
EXPECT_EQ(d1[2], 5.0);
|
||||
EXPECT_EQ(d1[3], 4.0);
|
||||
EXPECT_EQ(d1[4], 3.0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif //ANDROID_FXLAB_DELAYLINETEST_H
|
54
externals/oboe/apps/fxlab/app/src/main/cpp/tests/TypeTests.h
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_FXLAB_TYPETESTS_H
|
||||
#define ANDROID_FXLAB_TYPETESTS_H
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../effects/Effects.h"
|
||||
#include "../FunctionList.h"
|
||||
namespace {
|
||||
TEST(TypeTests, Templating) {
|
||||
TremoloEffect t {1, 2};
|
||||
VibratoEffect<float*> v {1, 2};
|
||||
float x = 5;
|
||||
t(x);
|
||||
auto pass = std::get<0>(EffectsTuple);
|
||||
auto descrip = std::get<1>(EffectsTuple);
|
||||
auto vibdes = std::get<2>(EffectsTuple);
|
||||
auto gaindes = std::get<3>(EffectsTuple);
|
||||
auto f = descrip.buildDefaultEffect<float*>();
|
||||
auto g = vibdes.buildDefaultEffect<float*>();
|
||||
auto h = vibdes.buildDefaultEffect<float*>();
|
||||
f(&x, &x + 1); g(&x, &x + 1); h(&x, &x + 1);
|
||||
auto j = gaindes.buildDefaultEffect<float*>();
|
||||
auto k = gaindes.modifyEffect<float*>(j, std::array<float, 1> {10});
|
||||
float floatArr[4] = {1,2,3, 4};
|
||||
for (int i =0; i < 4; i++) {
|
||||
k(floatArr + i, floatArr + i + 1);
|
||||
}
|
||||
auto arr = std::array<float, 1> {10};
|
||||
auto data = std::array<int, 5> {1, 2, 3, 4, 5};
|
||||
std::function<void(int*, int*)> fe = std::get<Effect::GainDescription>(EffectsTuple).buildEffect<int*>(arr);
|
||||
fe(data.begin(), data.end());
|
||||
EXPECT_EQ(data[0], 2);
|
||||
|
||||
}
|
||||
}
|
||||
#endif //ANDROID_FXLAB_TYPETESTS_H
|
29
externals/oboe/apps/fxlab/app/src/main/cpp/tests/testEffects.cpp
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "DelayLineTest.h"
|
||||
#include "DelayLineEffectTest.h"
|
||||
#include "TypeTests.h"
|
||||
// This is the runner for the various unit tests in the test directory
|
||||
// Currently it is designed to be run on the development machine via CMAKE
|
||||
// Since this tests effects, it should be independent of Android, and simply test locally
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
210
externals/oboe/apps/fxlab/app/src/main/kotlin/com/mobileer/androidfxlab/EffectsAdapter.kt
vendored
Normal file
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.mobileer.androidfxlab.datatype.Effect
|
||||
import java.util.*
|
||||
import kotlin.concurrent.timerTask
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
object EffectsAdapter :
|
||||
RecyclerView.Adapter<EffectsAdapter.EffectsHolder>() {
|
||||
val effectList = arrayListOf<Effect>()
|
||||
lateinit var mRecyclerView: RecyclerView
|
||||
|
||||
// This class adapts view in effect_view.xml for Effect class
|
||||
class EffectsHolder(val parentView: ViewGroup) : RecyclerView.ViewHolder(parentView) {
|
||||
private val layoutContainer: LinearLayout = parentView.findViewById(R.id.effectContainer)
|
||||
lateinit var effect: Effect
|
||||
private val floatFormat = "%4.2f"
|
||||
private var index: Int = -1
|
||||
fun bindEffect(bindedEffect: Effect, position: Int) {
|
||||
effect = bindedEffect
|
||||
index = position
|
||||
// Clear all views
|
||||
layoutContainer.removeAllViews()
|
||||
View.inflate(layoutContainer.context,
|
||||
R.layout.effect_header, layoutContainer)
|
||||
val header: LinearLayout = layoutContainer.findViewById(R.id.effectHeader)
|
||||
val dragHandleView: View = header.findViewById(R.id.cat_card_list_item_drag_handle)
|
||||
val checkBoxView: SwitchMaterial = header.findViewById(R.id.effectEnabled)
|
||||
val label: TextView = header.findViewById(R.id.effectLabel)
|
||||
// Bind header views
|
||||
label.text = effect.name
|
||||
checkBoxView.isChecked = effectList[index].enable
|
||||
checkBoxView.setOnCheckedChangeListener { _, checked ->
|
||||
effectList[index].enable = checked
|
||||
NativeInterface.enableEffectAt(checked, index)
|
||||
}
|
||||
dragHandleView.setOnTouchListener { _, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
itemTouchHelper.startDrag(this@EffectsHolder)
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
header.setOnTouchListener { _, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
itemTouchHelper.startSwipe(this@EffectsHolder)
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
// Add correct number of SeekBars based on effect
|
||||
for (ind in effect.effectDescription.paramValues.withIndex()) {
|
||||
val param = ind.value
|
||||
val counter = ind.index
|
||||
val view = View.inflate(layoutContainer.context,
|
||||
R.layout.param_seek, null)
|
||||
layoutContainer.addView(view)
|
||||
val paramWrapper: LinearLayout = view.findViewById(R.id.paramWrapper)
|
||||
val paramLabelView: TextView = paramWrapper.findViewById(R.id.paramLabel)
|
||||
val minLabelView: TextView = paramWrapper.findViewById(R.id.minLabel)
|
||||
val maxLabelView: TextView = paramWrapper.findViewById(R.id.maxLabel)
|
||||
val curLabelView: TextView = paramWrapper.findViewById(R.id.curLabel)
|
||||
val seekBar: SeekBar = paramWrapper.findViewById(R.id.seekBar)
|
||||
paramLabelView.text = param.paramName
|
||||
minLabelView.text = floatFormat.format(param.minValue)
|
||||
maxLabelView.text = floatFormat.format(param.maxValue)
|
||||
seekBar.progress =
|
||||
((effectList[index].paramValues[counter] - param.minValue) * 100 / (param.maxValue
|
||||
- param.minValue)).toInt()
|
||||
curLabelView.text = floatFormat.format(effectList[index].paramValues[counter])
|
||||
// Bind param listeners to effects
|
||||
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
val paramInd = counter
|
||||
var timer : Timer? = null
|
||||
|
||||
override fun onStartTrackingTouch(p0: SeekBar?) {}
|
||||
|
||||
override fun onStopTrackingTouch(seekbar: SeekBar?) {}
|
||||
|
||||
override fun onProgressChanged(
|
||||
seekBar: SeekBar?, progress: Int, fromUser: Boolean
|
||||
) {
|
||||
val fracprogress =
|
||||
((seekBar!!.progress / 100f) * (param.maxValue - param.minValue) + param.minValue)
|
||||
curLabelView.text = floatFormat.format(fracprogress)
|
||||
|
||||
timer?.cancel()
|
||||
timer = Timer()
|
||||
timer?.schedule(timerTask { updateEffectParam(fracprogress) }, 100)
|
||||
}
|
||||
|
||||
fun updateEffectParam(fracprogress : Float){
|
||||
effectList[index].paramValues[paramInd] = fracprogress
|
||||
NativeInterface.updateParamsAt(effect, index)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): EffectsHolder {
|
||||
val myView = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.effect_view, parent, false)
|
||||
return EffectsHolder(myView as ViewGroup)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: EffectsHolder, position: Int) {
|
||||
holder.bindEffect(effectList[position], position)
|
||||
}
|
||||
|
||||
override fun getItemCount() = effectList.size
|
||||
|
||||
override fun onAttachedToRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView)
|
||||
mRecyclerView = recyclerView
|
||||
itemTouchHelper.attachToRecyclerView(mRecyclerView)
|
||||
}
|
||||
|
||||
private val itemTouchHelper = ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(
|
||||
ItemTouchHelper.UP or ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT or ItemTouchHelper.LEFT
|
||||
) {
|
||||
|
||||
var dragFrom = -1
|
||||
var dragTo = -1
|
||||
override fun onMove(
|
||||
recyclerView: RecyclerView,
|
||||
viewHolder: RecyclerView.ViewHolder,
|
||||
target: RecyclerView.ViewHolder
|
||||
): Boolean {
|
||||
|
||||
val fromPos = viewHolder.adapterPosition
|
||||
val toPos = target.adapterPosition
|
||||
if (dragFrom == -1) {
|
||||
dragFrom = fromPos
|
||||
}
|
||||
dragTo = toPos
|
||||
effectList.add(toPos, effectList.removeAt(fromPos))
|
||||
recyclerView.adapter?.notifyItemMoved(fromPos, toPos)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
|
||||
val position = viewHolder.adapterPosition
|
||||
effectList.removeAt(position)
|
||||
mRecyclerView.adapter?.notifyItemRemoved(position)
|
||||
NativeInterface.removeEffectAt(position)
|
||||
for (i in position until effectList.size) {
|
||||
var holder = mRecyclerView.findViewHolderForAdapterPosition(i) as EffectsHolder
|
||||
holder.bindEffect(holder.effect, i)
|
||||
}
|
||||
}
|
||||
|
||||
override fun clearView(
|
||||
recyclerView: RecyclerView,
|
||||
viewHolder: RecyclerView.ViewHolder
|
||||
) {
|
||||
super.clearView(recyclerView, viewHolder)
|
||||
if (dragFrom != -1 && dragTo != -1 && dragFrom != dragTo) {
|
||||
rotateItems(dragFrom, dragTo)
|
||||
}
|
||||
dragFrom = -1
|
||||
dragTo = -1
|
||||
}
|
||||
|
||||
override fun isLongPressDragEnabled(): Boolean = false
|
||||
override fun isItemViewSwipeEnabled(): Boolean = false
|
||||
|
||||
fun rotateItems(fromPos: Int, toPos: Int) {
|
||||
val a = min(fromPos, toPos)
|
||||
val b = max(fromPos, toPos)
|
||||
for (i in a..b) {
|
||||
var holder = mRecyclerView.findViewHolderForAdapterPosition(i) as EffectsHolder
|
||||
holder.bindEffect(holder.effect, i)
|
||||
}
|
||||
NativeInterface.rotateEffectAt(fromPos, toPos)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
219
externals/oboe/apps/fxlab/app/src/main/kotlin/com/mobileer/androidfxlab/MainActivity.kt
vendored
Normal file
|
@ -0,0 +1,219 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.media.midi.MidiDeviceInfo
|
||||
import android.media.midi.MidiManager
|
||||
import android.media.midi.MidiReceiver
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.SubMenu
|
||||
import android.view.WindowManager
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.mobileer.androidfxlab.databinding.ActivityMainBinding
|
||||
import com.mobileer.androidfxlab.datatype.Effect
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var TAG: String = this.toString()
|
||||
lateinit var binding: ActivityMainBinding
|
||||
private var isAudioEnabled: Boolean = false
|
||||
|
||||
val MY_PERMISSIONS_RECORD_AUDIO = 17
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
|
||||
!= PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
arrayOf(Manifest.permission.RECORD_AUDIO),
|
||||
MY_PERMISSIONS_RECORD_AUDIO
|
||||
)
|
||||
}
|
||||
|
||||
binding.effectListView.adapter = EffectsAdapter
|
||||
|
||||
binding.floatingAddButton.setOnClickListener { view ->
|
||||
val popup = PopupMenu(this, view)
|
||||
popup.menuInflater.inflate(R.menu.add_menu, popup.menu)
|
||||
val menuMap = HashMap<String, SubMenu>()
|
||||
for (effectName in NativeInterface.effectDescriptionMap.keys) {
|
||||
val cat = NativeInterface.effectDescriptionMap.getValue(effectName).category
|
||||
if (cat == "None") {
|
||||
popup.menu.add(effectName)
|
||||
} else {
|
||||
val subMenu = menuMap[cat] ?: popup.menu.addSubMenu(cat)
|
||||
subMenu.add(effectName)
|
||||
menuMap[cat] = subMenu
|
||||
}
|
||||
}
|
||||
popup.setOnMenuItemClickListener { menuItem ->
|
||||
NativeInterface.effectDescriptionMap[menuItem.title]?.let {
|
||||
val toAdd = Effect(it)
|
||||
EffectsAdapter.effectList.add(toAdd)
|
||||
NativeInterface.addEffect(toAdd)
|
||||
EffectsAdapter.notifyItemInserted(EffectsAdapter.effectList.size - 1)
|
||||
true
|
||||
}
|
||||
false
|
||||
}
|
||||
popup.show()
|
||||
}
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
||||
handleMidiDevices()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
// Clear the FX UI
|
||||
EffectsAdapter.effectList.clear()
|
||||
EffectsAdapter.notifyDataSetChanged()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
// Shutdown Engine
|
||||
NativeInterface.destroyAudioEngine()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
// Startup Engine
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO)
|
||||
== PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
NativeInterface.createAudioEngine()
|
||||
NativeInterface.enable(isAudioEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
when (requestCode) {
|
||||
MY_PERMISSIONS_RECORD_AUDIO -> {
|
||||
if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
NativeInterface.createAudioEngine()
|
||||
} else {
|
||||
val builder = AlertDialog.Builder(this).apply {
|
||||
setMessage(
|
||||
"Audio effects require audio input permissions! \n" +
|
||||
"Enable permissions and restart app to use."
|
||||
)
|
||||
setTitle("Permission Error")
|
||||
}
|
||||
builder.create().show()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun handleMidiDevices() {
|
||||
|
||||
val midiManager = getSystemService(Context.MIDI_SERVICE) as MidiManager
|
||||
midiManager.registerDeviceCallback(object : MidiManager.DeviceCallback() {
|
||||
override fun onDeviceAdded(device: MidiDeviceInfo) {
|
||||
|
||||
// open this device
|
||||
midiManager.openDevice(device, {
|
||||
Log.d(TAG, "Opened MIDI device")
|
||||
|
||||
val targetSeekBar = findViewById<SeekBar>(R.id.seekBar)
|
||||
if (targetSeekBar != null) {
|
||||
|
||||
val midiReceiver = MyMidiReceiver(targetSeekBar)
|
||||
val outputPort = it.openOutputPort(0)
|
||||
outputPort?.connect(midiReceiver)
|
||||
}
|
||||
|
||||
}, Handler())
|
||||
}
|
||||
}, Handler())
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
getMenuInflater().inflate(R.menu.toolbar_menu, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||
R.id.action_toggle_mute -> {
|
||||
isAudioEnabled = !isAudioEnabled
|
||||
NativeInterface.enable(isAudioEnabled)
|
||||
|
||||
if (isAudioEnabled) {
|
||||
item.setIcon(R.drawable.ic_baseline_audio_is_enabled_24)
|
||||
} else {
|
||||
item.setIcon(R.drawable.ic_baseline_audio_is_disabled_24)
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> {
|
||||
super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
class MyMidiReceiver(var seekBar: SeekBar) : MidiReceiver() {
|
||||
|
||||
private val TAG: String = "MyMidiReceiver"
|
||||
|
||||
override fun onSend(data: ByteArray?, offset: Int, count: Int, timestamp: Long) {
|
||||
|
||||
Log.d(TAG, "Got midi message, offset " + offset + " count " + count)
|
||||
Log.d(TAG, "Byte 0 " + Integer.toHexString(data!![offset].toInt()))
|
||||
Log.d(TAG, "Byte 1 " + Integer.toHexString(data[offset+1].toInt()))
|
||||
Log.d(TAG, "Byte 2 " + data[offset+2].toInt())
|
||||
|
||||
val CONTROL_CHANGE_CH1 : Byte = 0xB0.toByte()
|
||||
|
||||
if (data[offset] == CONTROL_CHANGE_CH1){
|
||||
seekBar.progress = (data[offset+2].toInt() / 1.27).toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
110
externals/oboe/apps/fxlab/app/src/main/kotlin/com/mobileer/androidfxlab/NativeInterface.kt
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab
|
||||
|
||||
import android.util.Log
|
||||
import com.mobileer.androidfxlab.datatype.Effect
|
||||
import com.mobileer.androidfxlab.datatype.EffectDescription
|
||||
|
||||
object NativeInterface {
|
||||
// Used to load the 'native-lib' library on application startup.
|
||||
val effectDescriptionMap: Map<String, EffectDescription>
|
||||
|
||||
init {
|
||||
System.loadLibrary("native-lib")
|
||||
effectDescriptionMap = getEffects()
|
||||
.associateBy { it.name }
|
||||
Log.d("MAP", effectDescriptionMap.toString())
|
||||
}
|
||||
|
||||
// Functions/Members called by UI code
|
||||
// Adds effect at end of effect list
|
||||
fun addEffect(effect: Effect) {
|
||||
Log.d("INTERFACE", String.format("Effect %s added", effect.name))
|
||||
addDefaultEffectNative(
|
||||
convertEffectToId(
|
||||
effect
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// Enables effect at index
|
||||
fun enableEffectAt(turnOn: Boolean, index: Int) {
|
||||
Log.d("INTERFACE", String.format("Effect %b at index %d", turnOn, index))
|
||||
enableEffectNative(index, turnOn)
|
||||
}
|
||||
|
||||
// Signals params were updated at index
|
||||
fun updateParamsAt(effect: Effect, index: Int) {
|
||||
Log.d(
|
||||
"INTERFACE",
|
||||
String.format(
|
||||
"Params were updated at index %d to %f",
|
||||
index,
|
||||
effect.paramValues[0]
|
||||
)
|
||||
)
|
||||
modifyEffectNative(
|
||||
convertEffectToId(
|
||||
effect
|
||||
), index, effect.paramValues
|
||||
)
|
||||
}
|
||||
|
||||
// Removes effect at index
|
||||
fun removeEffectAt(index: Int) {
|
||||
Log.d("INTERFACE", String.format("Effect was removed at index %d", index))
|
||||
removeEffectNative(index)
|
||||
}
|
||||
|
||||
// Rotates existing effect from index to another
|
||||
fun rotateEffectAt(from: Int, to: Int) {
|
||||
Log.d("INTERFACE", String.format("Effect was rotated from %d to %d", from, to))
|
||||
rotateEffectNative(from, to)
|
||||
}
|
||||
|
||||
fun enable(enable: Boolean) {
|
||||
Log.d("INTERFACE", "Enabling effects: $enable")
|
||||
enablePassthroughNative(enable)
|
||||
}
|
||||
|
||||
// State of audio engine
|
||||
external fun createAudioEngine()
|
||||
|
||||
external fun destroyAudioEngine()
|
||||
|
||||
// These functions populate effectDescriptionMap
|
||||
private external fun getEffects(): Array<EffectDescription>
|
||||
|
||||
// These functions mutate the function list
|
||||
// Adds effect at index
|
||||
private external fun addDefaultEffectNative(id: Int)
|
||||
|
||||
private external fun removeEffectNative(index: Int)
|
||||
|
||||
private external fun rotateEffectNative(from: Int, to: Int)
|
||||
|
||||
private external fun modifyEffectNative(id: Int, index: Int, params: FloatArray)
|
||||
|
||||
private external fun enableEffectNative(index: Int, enable: Boolean)
|
||||
|
||||
private external fun enablePassthroughNative(enable: Boolean)
|
||||
|
||||
// These are utility functions
|
||||
private fun convertEffectToId(effect: Effect): Int =
|
||||
effectDescriptionMap[effect.name]?.id ?: -1
|
||||
}
|
28
externals/oboe/apps/fxlab/app/src/main/kotlin/com/mobileer/androidfxlab/datatype/Effect.kt
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab.datatype
|
||||
|
||||
/**
|
||||
* Class which represents an audio effect
|
||||
*/
|
||||
data class Effect(val effectDescription: EffectDescription) {
|
||||
val name = effectDescription.name
|
||||
val paramValues = FloatArray(effectDescription.paramValues.size) {
|
||||
i -> effectDescription.paramValues[i].defaultValue
|
||||
}
|
||||
var enable: Boolean = true
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab.datatype
|
||||
|
||||
data class EffectDescription(
|
||||
val name: String,
|
||||
val category: String,
|
||||
val id: Int,
|
||||
val paramValues: Array<ParamDescription>
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as EffectDescription
|
||||
if (id != other.id) return false
|
||||
return true
|
||||
}
|
||||
override fun hashCode(): Int = id
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.mobileer.androidfxlab.datatype
|
||||
|
||||
data class ParamDescription (
|
||||
val paramName: String,
|
||||
val minValue: Float,
|
||||
val maxValue: Float,
|
||||
val defaultValue: Float)
|
50
externals/oboe/apps/fxlab/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0"/>
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
25
externals/oboe/apps/fxlab/app/src/main/res/drawable/ic_add.xml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</vector>
|
10
externals/oboe/apps/fxlab/app/src/main/res/drawable/ic_baseline_audio_is_disabled_24.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z"/>
|
||||
</vector>
|
10
externals/oboe/apps/fxlab/app/src/main/res/drawable/ic_baseline_audio_is_enabled_24.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/>
|
||||
</vector>
|
25
externals/oboe/apps/fxlab/app/src/main/res/drawable/ic_baseline_drag_indicator.xml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/colorAccent"
|
||||
android:pathData="M11,18c0,1.1 -0.9,2 -2,2s-2,-0.9 -2,-2 0.9,-2 2,-2 2,0.9 2,2zM9,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM9,4c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM15,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM15,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM15,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
90
externals/oboe/apps/fxlab/app/src/main/res/drawable/ic_launcher_background.xml
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="108dp"
|
||||
android:width="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path android:fillColor="#008577"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</vector>
|
63
externals/oboe/apps/fxlab/app/src/main/res/layout/activity_main.xml
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<layout>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<!-- Main content -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/effect_list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/floating_add_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_margin="16dp"
|
||||
app:srcCompat="@drawable/ic_add" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</layout>
|
65
externals/oboe/apps/fxlab/app/src/main/res/layout/effect_header.xml
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/effectHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/effectLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/effectEnabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:enabled="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cat_card_list_item_drag_handle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
app:srcCompat="@drawable/ic_baseline_drag_indicator"
|
||||
tools:targetApi="jelly_bean" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
38
externals/oboe/apps/fxlab/app/src/main/res/layout/effect_view.xml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/cat_card_list_item_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:minHeight="118dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/effectContainer"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
59
externals/oboe/apps/fxlab/app/src/main/res/layout/param_seek.xml
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/paramWrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/paramLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/curLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/minLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/maxLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.25"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption" />
|
||||
|
||||
</LinearLayout>
|
19
externals/oboe/apps/fxlab/app/src/main/res/menu/add_menu.xml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<menu>
|
||||
</menu>
|
12
externals/oboe/apps/fxlab/app/src/main/res/menu/toolbar_menu.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<!-- Add a mute toggle action to our Toolbar-->
|
||||
<item
|
||||
android:id="@+id/action_toggle_mute"
|
||||
android:icon="@drawable/ic_baseline_audio_is_disabled_24"
|
||||
android:title="@string/action_toggle_mute"
|
||||
app:showAsAction="ifRoom"
|
||||
/>
|
||||
</menu>
|
21
externals/oboe/apps/fxlab/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
21
externals/oboe/apps/fxlab/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-hdpi/ic_launcher.png
vendored
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
vendored
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-mdpi/ic_launcher.png
vendored
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
vendored
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xhdpi/ic_launcher.png
vendored
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
vendored
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
vendored
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
vendored
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
vendored
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
externals/oboe/apps/fxlab/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
vendored
Normal file
After Width: | Height: | Size: 15 KiB |
23
externals/oboe/apps/fxlab/app/src/main/res/values/colors.xml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<color name="colorPrimary">#6200EE</color>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
<color name="colorAccent">#03DAC6</color>
|
||||
<color name="colorAccentDark">#018786</color>
|
||||
</resources>
|
20
externals/oboe/apps/fxlab/app/src/main/res/values/strings.xml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">AndroidFX Lab</string>
|
||||
<string name="action_toggle_mute">Toggle volume</string>
|
||||
</resources>
|
27
externals/oboe/apps/fxlab/app/src/main/res/values/styles.xml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<!--
|
||||
~ Copyright 2019 Google LLC
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ https://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
45
externals/oboe/apps/fxlab/build.gradle
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '2.1.10'
|
||||
}
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.9.0'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('clean', Delete) {
|
||||
delete rootProject.layout.buildDirectory
|
||||
}
|
46
externals/oboe/apps/fxlab/docs/Dev-Guide.md
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Development
|
||||
|
||||
The effects included are designed to be as portable as possible, as well as making it easy to add additional effects.
|
||||
|
||||
## Building
|
||||
|
||||
To build the app, simply open the project in android studio and build. The app integrates Oboe via a git submodule. Make sure
|
||||
when cloning the repository to clone the submodule as well using `git clone --recursive`, or `git submodule update --init --recursive`.
|
||||
|
||||
To update the version of Oboe being used, descend into the Oboe repository [(oboe location)](../app/src/main/cpp)
|
||||
and 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.
|
||||
|
||||
Although the CMake file requires android headers (to use Oboe), the effects themselves can be compiled with any C++17 compliant compiler.
|
||||
|
||||
## Architecture
|
||||
|
||||
The UI code (Kotlin) calls native code through the JNI bridge to query information about the various effects implemented,
|
||||
and how to render the effect information in the UI. This means that adding an effect only needs to be done on the
|
||||
native side. The JNI bridge passes information regarding implemented effects descriptions to the UI as well as functions
|
||||
called when the user modifies effects in the UI.
|
||||
|
||||
The `DuplexEngine` is responsible for managing and syncing the input and output Oboe streams for rendering audio
|
||||
with as low latency as possible. The `FunctionList` class contains the a vector of effects that correspond to the list of
|
||||
effects (and their parameters) that the user wants to use to process their audio. Effects (and the `FunctionList`) overload
|
||||
their function operator to take in two numeric iterator types. E.g `<template iter_type> void operator()
|
||||
(iter_type begin, iter_type end)`, where the `iter_types` correspond to C++ iterators carrying audio data. To erase the type
|
||||
of different objects, the `FunctionList` holds objects of types `std::function<void(iter_type, iter_type)>` i.e. functions
|
||||
which operate on the range between two numeric iterators in place. The `DuplexEngine`simply calls the `FunctionList` on every
|
||||
buffer of samples it receives.
|
||||
|
||||
The effects folder contains the classes of various implemented effects. It also contains `Effects.h` where a global tuple of
|
||||
all the Effect descriptions implemented lives. The description folder contains the description for all of the effects.
|
||||
Each description takes the form of a class with static methods providing information regarding the effect (including name,
|
||||
category, parameters, and a factory method).
|
||||
|
||||
## Adding Effects
|
||||
To 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
|
||||
to an effect, or pointing to a standalone function. Adding new effects is welcome!
|
||||
|
||||
## Existing Effects
|
||||
A instructional implemented effect to examine is the `TremoloEffect.h` (a modulating gain).
|
||||
Many of the effects in the delay category
|
||||
inherit from `DelayLineEffect` which provides a framework to easily implement many delay based effects, as well as
|
||||
the comb filter effects (FIR, IIR, allpass). The slides have a block diagram displaying the mathematical basis of the effect.
|
||||
The nonlinear effects (distortion and overdrive) are implemented using a standalone function (from `SingleEffectFunctions.h`.
|
||||
The gain effect is implemented by a simple lambda in its description class.
|
BIN
externals/oboe/apps/fxlab/docs/Presentation.pdf
vendored
Normal file
4
externals/oboe/apps/fxlab/docs/README.md
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Docs for Android FX Lab
|
||||
|
||||
* [How to Build the App](Dev-Guide.md)
|
||||
* [Slides for Internal Architecture (PDF)](Presentation.pdf)
|
40
externals/oboe/apps/fxlab/gradle.properties
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# Copyright 2019 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
BIN
externals/oboe/apps/fxlab/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
externals/oboe/apps/fxlab/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Tue Mar 11 13:58:39 EDT 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
172
externals/oboe/apps/fxlab/gradlew
vendored
Executable file
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
externals/oboe/apps/fxlab/gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
BIN
externals/oboe/apps/fxlab/screenshot.png
vendored
Normal file
After Width: | Height: | Size: 105 KiB |
17
externals/oboe/apps/fxlab/settings.gradle
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
include ':app'
|