From c2769cdf217c5cd65b728e47da8bc6a13895d5a2 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Wed, 26 Jul 2023 18:38:21 +0200 Subject: [PATCH] beginning of android + moved config.js files to src + temp warn fix in bw_one_pole --- examples/common/android/AndroidManifest.xml | 14 +++ examples/common/android/MainActivity.java | 23 +++++ examples/common/android/android.mk | 87 +++++++++++++++++++ examples/common/android/index.html | 14 +++ examples/common/android/jni.cpp | 0 examples/common/android/platform.h | 0 examples/common/web/web.mk | 8 +- examples/fx_ap1/{web => src}/config.js | 0 examples/fx_ap2/{web => src}/config.js | 0 examples/fx_balance/{web => src}/config.js | 0 examples/fx_bitcrush/{web => src}/config.js | 0 examples/fx_chorus/{web => src}/config.js | 0 examples/fx_clip/{web => src}/config.js | 0 examples/fx_comb/{web => src}/config.js | 0 examples/fx_comp/{web => src}/config.js | 0 examples/fx_delay/{web => src}/config.js | 0 examples/fx_dist/{web => src}/config.js | 0 examples/fx_drive/{web => src}/config.js | 0 examples/fx_eq_3band/{web => src}/config.js | 0 examples/fx_flanger/{web => src}/config.js | 0 examples/fx_fuzz/{web => src}/config.js | 0 examples/fx_hp1/{web => src}/config.js | 0 examples/fx_hs1/{web => src}/config.js | 0 examples/fx_lp1/{web => src}/config.js | 0 examples/fx_ls1/{web => src}/config.js | 0 examples/fx_mm1/{web => src}/config.js | 0 examples/fx_mm2/{web => src}/config.js | 0 examples/fx_noise_gate/{web => src}/config.js | 0 examples/fx_notch/{web => src}/config.js | 0 examples/fx_one_pole/android/Makefile | 6 ++ examples/fx_one_pole/{web => src}/config.js | 0 examples/fx_pan/{web => src}/config.js | 0 examples/fx_phaser/{web => src}/config.js | 0 examples/fx_reverb/{web => src}/config.js | 0 examples/fx_satur/{web => src}/config.js | 0 examples/fx_slew_lim/{web => src}/config.js | 0 examples/fx_svf/{web => src}/config.js | 0 examples/fx_trem/{web => src}/config.js | 0 examples/fx_vibrato/{web => src}/config.js | 0 examples/fx_wah/{web => src}/config.js | 0 examples/synth_mono/{web => src}/config.js | 0 examples/synth_poly/{web => src}/config.js | 0 examples/synth_simple/{web => src}/config.js | 0 include/bw_one_pole.h | 1 + 44 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 examples/common/android/AndroidManifest.xml create mode 100644 examples/common/android/MainActivity.java create mode 100644 examples/common/android/android.mk create mode 100644 examples/common/android/index.html create mode 100644 examples/common/android/jni.cpp create mode 100644 examples/common/android/platform.h rename examples/fx_ap1/{web => src}/config.js (100%) rename examples/fx_ap2/{web => src}/config.js (100%) rename examples/fx_balance/{web => src}/config.js (100%) rename examples/fx_bitcrush/{web => src}/config.js (100%) rename examples/fx_chorus/{web => src}/config.js (100%) rename examples/fx_clip/{web => src}/config.js (100%) rename examples/fx_comb/{web => src}/config.js (100%) rename examples/fx_comp/{web => src}/config.js (100%) rename examples/fx_delay/{web => src}/config.js (100%) rename examples/fx_dist/{web => src}/config.js (100%) rename examples/fx_drive/{web => src}/config.js (100%) rename examples/fx_eq_3band/{web => src}/config.js (100%) rename examples/fx_flanger/{web => src}/config.js (100%) rename examples/fx_fuzz/{web => src}/config.js (100%) rename examples/fx_hp1/{web => src}/config.js (100%) rename examples/fx_hs1/{web => src}/config.js (100%) rename examples/fx_lp1/{web => src}/config.js (100%) rename examples/fx_ls1/{web => src}/config.js (100%) rename examples/fx_mm1/{web => src}/config.js (100%) rename examples/fx_mm2/{web => src}/config.js (100%) rename examples/fx_noise_gate/{web => src}/config.js (100%) rename examples/fx_notch/{web => src}/config.js (100%) create mode 100644 examples/fx_one_pole/android/Makefile rename examples/fx_one_pole/{web => src}/config.js (100%) rename examples/fx_pan/{web => src}/config.js (100%) rename examples/fx_phaser/{web => src}/config.js (100%) rename examples/fx_reverb/{web => src}/config.js (100%) rename examples/fx_satur/{web => src}/config.js (100%) rename examples/fx_slew_lim/{web => src}/config.js (100%) rename examples/fx_svf/{web => src}/config.js (100%) rename examples/fx_trem/{web => src}/config.js (100%) rename examples/fx_vibrato/{web => src}/config.js (100%) rename examples/fx_wah/{web => src}/config.js (100%) rename examples/synth_mono/{web => src}/config.js (100%) rename examples/synth_poly/{web => src}/config.js (100%) rename examples/synth_simple/{web => src}/config.js (100%) diff --git a/examples/common/android/AndroidManifest.xml b/examples/common/android/AndroidManifest.xml new file mode 100644 index 0000000..f3f3b03 --- /dev/null +++ b/examples/common/android/AndroidManifest.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/examples/common/android/MainActivity.java b/examples/common/android/MainActivity.java new file mode 100644 index 0000000..595fd73 --- /dev/null +++ b/examples/common/android/MainActivity.java @@ -0,0 +1,23 @@ +package com.orastron.@NAME@; + +import android.app.Activity; +import android.os.Bundle; +import android.webkit.WebView; +import android.webkit.WebSettings; +import android.webkit.WebChromeClient; +import android.webkit.WebViewClient; + +public class MainActivity extends Activity { + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + WebView webView = new WebView(this); + setContentView(webView); + WebSettings webSettings = webView.getSettings(); + webSettings.setJavaScriptEnabled(true); + webView.setWebChromeClient(new WebChromeClient()); + webView.setWebViewClient(new WebViewClient()); + webSettings.setDomStorageEnabled(true); + webView.loadUrl("file:///android_asset/index.html"); + } +} diff --git a/examples/common/android/android.mk b/examples/common/android/android.mk new file mode 100644 index 0000000..ad78fc9 --- /dev/null +++ b/examples/common/android/android.mk @@ -0,0 +1,87 @@ +COMMON_DIR := ${ROOT_DIR}/../../common/android +BUILD_TOOLS_DIR := ${HOME}/Android/Sdk/build-tools/34.0.0 +JAR_FILE := ${HOME}/Android/Sdk/platforms/android-34/android.jar + +JAVAC := javac +KOTLINC := kotlinc +KEYTOOL := keytool +CXX := ${HOME}/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi23-clang++ +ADB := ${HOME}/Android/Sdk/platform-tools/adb +APKSIGNER := ${BUILD_TOOLS_DIR}/apksigner +ZIPALIGN := ${BUILD_TOOLS_DIR}/zipalign +AAPT := ${BUILD_TOOLS_DIR}/aapt +D8 := ${BUILD_TOOLS_DIR}/d8 + +CXXFLAGS := \ + -fPIC \ + -DNDEBUG \ + -I${ROOT_DIR}/../src \ + -I${COMMON_DIR} \ + -I${ROOT_DIR}/../../../include \ + -O3 \ + -Wall \ + -Wextra \ + -Wpedantic \ + -std=c++20 +LDFLAGS := \ + -shared \ + -static-libstdc++ \ + -ljnigraphics \ + -llog \ + -landroid + +SOURCES_COMMON := \ + ${COMMON_DIR}/jni.cpp + +all: build/${NAME}.apk + +build/${NAME}.apk: build/gen/${NAME}.aligned.apk build/apk/lib/armeabi-v7a/lib${NAME}.so build/gen/keystore.jks + ${APKSIGNER} sign --ks build/gen/keystore.jks --ks-key-alias androidkey --ks-pass pass:android --key-pass pass:android --out $@ build/gen/${NAME}.aligned.apk + +build/gen/keystore.jks: | build/gen + ${KEYTOOL} -genkeypair -keystore $@ -alias androidkey -dname "CN=orastron.com, OU=ID, O=ORASTRON, L=Abc, S=Xyz, C=IT" -validity 10000 -keyalg RSA -keysize 2048 -storepass android -keypass android + +build/gen/${NAME}.aligned.apk: build/gen/${NAME}.unsigned.apk + ${ZIPALIGN} -f -p 4 $^ $@ + +build/gen/${NAME}.unsigned.apk: build/apk/classes.dex build/gen/AndroidManifest.xml build/assets/index.html build/assets/config.js | build/gen + #${AAPT} package -f -M build/gen/AndroidManifest.xml -I ${JAR_FILE} -F $@ build/apk + #${AAPT} package -f -M build/gen/AndroidManifest.xml -S ${COMMON_DIR}/res -I ${JAR_FILE} -F $@ build/apk + ${AAPT} package -f -M build/gen/AndroidManifest.xml -A build/assets -I ${JAR_FILE} -F $@ build/apk + +build/apk/classes.dex: build/apk/my_classes.jar + cd build/apk && ${BUILD_TOOLS_DIR}/d8 ../../$^ ${JAR_FILE} && cd ../.. + +build/apk/my_classes.jar: build/obj/com/orastron/${NAME}/MainActivity.class | build/apk + ${D8} build/obj/com/orastron/${NAME}/MainActivity.class --output $@ --no-desugaring + #${D8} $^ --output $@ --no-desugaring + +build/apk/lib/armeabi-v7a/lib${NAME}.so: ${SOURCES} | build/apk/lib/armeabi-v7a + ${CXX} $^ ${CXXFLAGS} ${LDFLAGS} -o $@ + +build/obj/com/orastron/${NAME}/MainActivity.class: build/gen/com/orastron/${NAME}/MainActivity.java | build/obj + ${JAVAC} -classpath ${JAR_FILE} -d build/obj build/gen/com/orastron/${NAME}/MainActivity.java + +build/gen/com/orastron/${NAME}/MainActivity.java: ${COMMON_DIR}/MainActivity.java | build/gen/com/orastron/${NAME} + cat $^ | sed s:@NAME@:${NAME}:g > $@ + +build/gen/AndroidManifest.xml: ${COMMON_DIR}/AndroidManifest.xml | build/gen/com/orastron/${NAME} + cat $^ | sed s:@NAME@:${NAME}:g > $@ + +build/assets/index.html: ${COMMON_DIR}/index.html | build/assets + cp $^ $@ + +build/assets/config.js: ${ROOT_DIR}/../src/config.js | build/assets + cp $^ $@ + +build/apk build/apk/lib/armeabi-v7a build/obj build/gen/com/orastron/${NAME} build/gen build/assets: + mkdir -p $@ + +clean: + rm -fr build + +install: build/${NAME}.apk + [ -n "`${ADB} shell pm list packages | grep ^package:com.orastron.${NAME}$$`" ] && ${ADB} uninstall com.orastron.${NAME}; exit 0 + ${ADB} install $^ + +.PHONY: all clean install diff --git a/examples/common/android/index.html b/examples/common/android/index.html new file mode 100644 index 0000000..171eeaf --- /dev/null +++ b/examples/common/android/index.html @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/examples/common/android/jni.cpp b/examples/common/android/jni.cpp new file mode 100644 index 0000000..e69de29 diff --git a/examples/common/android/platform.h b/examples/common/android/platform.h new file mode 100644 index 0000000..e69de29 diff --git a/examples/common/web/web.mk b/examples/common/web/web.mk index 7b165dd..50f433d 100644 --- a/examples/common/web/web.mk +++ b/examples/common/web/web.mk @@ -58,11 +58,11 @@ build/web/module.wasm: ${SOURCES} | build/web build/web/index.html: ${INDEX} | build/web cp ${INDEX} $@ -build/web/processor.js: ${ROOT_DIR}/config.js ${ROOT_DIR}/../../common/web/processor.js | build/web - cat ${ROOT_DIR}/config.js ${ROOT_DIR}/../../common/web//processor.js > $@ +build/web/processor.js: ${ROOT_DIR}/../src/config.js ${ROOT_DIR}/../../common/web/processor.js | build/web + cat ${ROOT_DIR}/../src/config.js ${ROOT_DIR}/../../common/web//processor.js > $@ -build/web/config.js: ${ROOT_DIR}/config.js | build/web - cp ${ROOT_DIR}/config.js $@ +build/web/config.js: ${ROOT_DIR}/../src/config.js | build/web + cp $^ $@ build/web/key.pem: build/web/cert.pem diff --git a/examples/fx_ap1/web/config.js b/examples/fx_ap1/src/config.js similarity index 100% rename from examples/fx_ap1/web/config.js rename to examples/fx_ap1/src/config.js diff --git a/examples/fx_ap2/web/config.js b/examples/fx_ap2/src/config.js similarity index 100% rename from examples/fx_ap2/web/config.js rename to examples/fx_ap2/src/config.js diff --git a/examples/fx_balance/web/config.js b/examples/fx_balance/src/config.js similarity index 100% rename from examples/fx_balance/web/config.js rename to examples/fx_balance/src/config.js diff --git a/examples/fx_bitcrush/web/config.js b/examples/fx_bitcrush/src/config.js similarity index 100% rename from examples/fx_bitcrush/web/config.js rename to examples/fx_bitcrush/src/config.js diff --git a/examples/fx_chorus/web/config.js b/examples/fx_chorus/src/config.js similarity index 100% rename from examples/fx_chorus/web/config.js rename to examples/fx_chorus/src/config.js diff --git a/examples/fx_clip/web/config.js b/examples/fx_clip/src/config.js similarity index 100% rename from examples/fx_clip/web/config.js rename to examples/fx_clip/src/config.js diff --git a/examples/fx_comb/web/config.js b/examples/fx_comb/src/config.js similarity index 100% rename from examples/fx_comb/web/config.js rename to examples/fx_comb/src/config.js diff --git a/examples/fx_comp/web/config.js b/examples/fx_comp/src/config.js similarity index 100% rename from examples/fx_comp/web/config.js rename to examples/fx_comp/src/config.js diff --git a/examples/fx_delay/web/config.js b/examples/fx_delay/src/config.js similarity index 100% rename from examples/fx_delay/web/config.js rename to examples/fx_delay/src/config.js diff --git a/examples/fx_dist/web/config.js b/examples/fx_dist/src/config.js similarity index 100% rename from examples/fx_dist/web/config.js rename to examples/fx_dist/src/config.js diff --git a/examples/fx_drive/web/config.js b/examples/fx_drive/src/config.js similarity index 100% rename from examples/fx_drive/web/config.js rename to examples/fx_drive/src/config.js diff --git a/examples/fx_eq_3band/web/config.js b/examples/fx_eq_3band/src/config.js similarity index 100% rename from examples/fx_eq_3band/web/config.js rename to examples/fx_eq_3band/src/config.js diff --git a/examples/fx_flanger/web/config.js b/examples/fx_flanger/src/config.js similarity index 100% rename from examples/fx_flanger/web/config.js rename to examples/fx_flanger/src/config.js diff --git a/examples/fx_fuzz/web/config.js b/examples/fx_fuzz/src/config.js similarity index 100% rename from examples/fx_fuzz/web/config.js rename to examples/fx_fuzz/src/config.js diff --git a/examples/fx_hp1/web/config.js b/examples/fx_hp1/src/config.js similarity index 100% rename from examples/fx_hp1/web/config.js rename to examples/fx_hp1/src/config.js diff --git a/examples/fx_hs1/web/config.js b/examples/fx_hs1/src/config.js similarity index 100% rename from examples/fx_hs1/web/config.js rename to examples/fx_hs1/src/config.js diff --git a/examples/fx_lp1/web/config.js b/examples/fx_lp1/src/config.js similarity index 100% rename from examples/fx_lp1/web/config.js rename to examples/fx_lp1/src/config.js diff --git a/examples/fx_ls1/web/config.js b/examples/fx_ls1/src/config.js similarity index 100% rename from examples/fx_ls1/web/config.js rename to examples/fx_ls1/src/config.js diff --git a/examples/fx_mm1/web/config.js b/examples/fx_mm1/src/config.js similarity index 100% rename from examples/fx_mm1/web/config.js rename to examples/fx_mm1/src/config.js diff --git a/examples/fx_mm2/web/config.js b/examples/fx_mm2/src/config.js similarity index 100% rename from examples/fx_mm2/web/config.js rename to examples/fx_mm2/src/config.js diff --git a/examples/fx_noise_gate/web/config.js b/examples/fx_noise_gate/src/config.js similarity index 100% rename from examples/fx_noise_gate/web/config.js rename to examples/fx_noise_gate/src/config.js diff --git a/examples/fx_notch/web/config.js b/examples/fx_notch/src/config.js similarity index 100% rename from examples/fx_notch/web/config.js rename to examples/fx_notch/src/config.js diff --git a/examples/fx_one_pole/android/Makefile b/examples/fx_one_pole/android/Makefile new file mode 100644 index 0000000..b6c155b --- /dev/null +++ b/examples/fx_one_pole/android/Makefile @@ -0,0 +1,6 @@ +ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + +NAME := bw_example_fx_one_pole +SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_one_pole.c + +include ${ROOT_DIR}/../../common/android/android.mk diff --git a/examples/fx_one_pole/web/config.js b/examples/fx_one_pole/src/config.js similarity index 100% rename from examples/fx_one_pole/web/config.js rename to examples/fx_one_pole/src/config.js diff --git a/examples/fx_pan/web/config.js b/examples/fx_pan/src/config.js similarity index 100% rename from examples/fx_pan/web/config.js rename to examples/fx_pan/src/config.js diff --git a/examples/fx_phaser/web/config.js b/examples/fx_phaser/src/config.js similarity index 100% rename from examples/fx_phaser/web/config.js rename to examples/fx_phaser/src/config.js diff --git a/examples/fx_reverb/web/config.js b/examples/fx_reverb/src/config.js similarity index 100% rename from examples/fx_reverb/web/config.js rename to examples/fx_reverb/src/config.js diff --git a/examples/fx_satur/web/config.js b/examples/fx_satur/src/config.js similarity index 100% rename from examples/fx_satur/web/config.js rename to examples/fx_satur/src/config.js diff --git a/examples/fx_slew_lim/web/config.js b/examples/fx_slew_lim/src/config.js similarity index 100% rename from examples/fx_slew_lim/web/config.js rename to examples/fx_slew_lim/src/config.js diff --git a/examples/fx_svf/web/config.js b/examples/fx_svf/src/config.js similarity index 100% rename from examples/fx_svf/web/config.js rename to examples/fx_svf/src/config.js diff --git a/examples/fx_trem/web/config.js b/examples/fx_trem/src/config.js similarity index 100% rename from examples/fx_trem/web/config.js rename to examples/fx_trem/src/config.js diff --git a/examples/fx_vibrato/web/config.js b/examples/fx_vibrato/src/config.js similarity index 100% rename from examples/fx_vibrato/web/config.js rename to examples/fx_vibrato/src/config.js diff --git a/examples/fx_wah/web/config.js b/examples/fx_wah/src/config.js similarity index 100% rename from examples/fx_wah/web/config.js rename to examples/fx_wah/src/config.js diff --git a/examples/synth_mono/web/config.js b/examples/synth_mono/src/config.js similarity index 100% rename from examples/synth_mono/web/config.js rename to examples/synth_mono/src/config.js diff --git a/examples/synth_poly/web/config.js b/examples/synth_poly/src/config.js similarity index 100% rename from examples/synth_poly/web/config.js rename to examples/synth_poly/src/config.js diff --git a/examples/synth_simple/web/config.js b/examples/synth_simple/src/config.js similarity index 100% rename from examples/synth_simple/web/config.js rename to examples/synth_simple/src/config.js diff --git a/include/bw_one_pole.h b/include/bw_one_pole.h index b9e5ad7..bd3361e 100644 --- a/include/bw_one_pole.h +++ b/include/bw_one_pole.h @@ -910,6 +910,7 @@ static inline char bw_one_pole_coeffs_is_valid(const bw_one_pole_coeffs *BW_REST if (coeffs->hash != bw_hash_sdbm("bw_one_pole_coeffs")) return 0; #endif + (void)coeffs; //... return 1;