-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,920 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# CAVA on android | ||
|
||
## FFTW3 | ||
|
||
To build cava on android you need to get the fftw3 library. | ||
Luckily someone has made a repository for compiling FFTW3 on Android. | ||
Just make sure ndk-build is in your path before running the build script. | ||
|
||
|
||
``` | ||
git clone https://github.com/Lauszus/fftw3-android | ||
cd fftw3-android | ||
./build.sh | ||
``` | ||
|
||
By default we will look for the fftw3 lib in a folder called fftw3-android besides the cava dir: | ||
|
||
``` | ||
./ | ||
../ | ||
cava/ | ||
fftw3-android/ | ||
``` | ||
|
||
Edit the cmake argument in the app gradle file for setting it to some other place. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import com.android.build.api.dsl.LintOptions | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
signingConfigs { | ||
getByName("debug") { | ||
storeFile = file("../keystore.jks") | ||
storePassword = "cava123" | ||
keyPassword = "cava123" | ||
keyAlias = "key0" | ||
} | ||
create("release") { | ||
storeFile = file("../keystore.jks") | ||
storePassword = "cava123" | ||
keyPassword = "cava123" | ||
keyAlias = "key0" | ||
} | ||
} | ||
namespace = "com.karlstav.cava" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
applicationId = "com.karlstav.cava" | ||
minSdk = 30 | ||
targetSdk = 33 | ||
versionCode = 14 | ||
versionName = "@string/app_ver" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
/* | ||
ndk { | ||
abiFilters += listOf("arm64-v8a") | ||
} | ||
*/ | ||
externalNativeBuild { | ||
|
||
// For ndk-build, instead use the ndkBuild block. | ||
cmake { | ||
|
||
// Passes optional arguments to CMake. | ||
arguments("-DFFTW_DIR=${projectDir}/../../../fftw3-android") | ||
} | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
isDebuggable = false | ||
signingConfig = signingConfigs.getByName("release") | ||
} | ||
} | ||
// Encapsulates your external native build configurations. | ||
externalNativeBuild { | ||
|
||
// Encapsulates your CMake build configurations. | ||
cmake { | ||
// Provides a relative path to your CMake build script. | ||
path = file("../../CMakeLists.txt") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.4.3" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
|
||
implementation("androidx.core:core-ktx:1.9.0") | ||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") | ||
implementation("androidx.activity:activity-compose:1.7.0") | ||
implementation ("androidx.appcompat:appcompat:1.3.1") | ||
implementation("androidx.preference:preference-ktx:1.2.0") | ||
|
||
implementation(platform("androidx.compose:compose-bom:2023.03.00")) | ||
implementation("androidx.compose.ui:ui") | ||
implementation("androidx.compose.ui:ui-graphics") | ||
implementation("androidx.compose.ui:ui-tooling-preview") | ||
implementation("androidx.compose.material3:material3") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) | ||
androidTestImplementation("androidx.compose.ui:ui-test-junit4") | ||
debugImplementation("androidx.compose.ui:ui-tooling") | ||
debugImplementation("androidx.compose.ui:ui-test-manifest") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
41 changes: 41 additions & 0 deletions
41
cavandroid/app/src/androidTest/java/com/example/cava/CavaCoreTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.karlstav.cava | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class CavaCoreTest { | ||
external fun InitCava(pInt: Int): Int | ||
external fun ExecCava(pDoubleArray: DoubleArray, pInt: Int): DoubleArray | ||
|
||
@Test | ||
fun cavaExec_null_test() { | ||
System.loadLibrary("cavacore") | ||
|
||
val numberOfBars = 10 | ||
val cavaData = DoubleArray(256) | ||
val barsData = FloatArray(10) | ||
|
||
|
||
for (i in 0 until 256) { | ||
cavaData[i] = 0.0 | ||
} | ||
val rc = InitCava(numberOfBars) | ||
|
||
var cavaOut = ExecCava(cavaData, 256); | ||
|
||
|
||
for (i in 0 until numberOfBars) { | ||
assertEquals(0.0f, barsData[0]) | ||
} | ||
} | ||
} |
Oops, something went wrong.