diff --git a/app/build.gradle b/app/build.gradle index ab24831e..9706e9a3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.shajikhan.ladspa.amprack" minSdk 24 targetSdk 33 - versionCode 83 - versionName '4.04' + versionCode 84 + versionName '4.05' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { diff --git a/app/src/main/cpp/Engine.cpp b/app/src/main/cpp/Engine.cpp index 20e04d08..d07b4e65 100644 --- a/app/src/main/cpp/Engine.cpp +++ b/app/src/main/cpp/Engine.cpp @@ -532,6 +532,14 @@ int Engine::addPlugintoRackByName (std::string pluginName) { return 0 ; } +void Engine::setPluginFilename (std::string filename, int plugin) { + IN + mFullDuplexPass.bypass = true; + activePlugins.at(plugin)->setFileName(filename); + mFullDuplexPass.bypass = false; + OUT +} + bool Engine::setPluginBuffer (float * buffer, int buffer_size, int plugin) { IN // LOGD("plugins in queue %d requested %d", activePlugins.size(), plugin); diff --git a/app/src/main/cpp/Engine.h b/app/src/main/cpp/Engine.h index c0642b14..326655b2 100644 --- a/app/src/main/cpp/Engine.h +++ b/app/src/main/cpp/Engine.h @@ -115,6 +115,8 @@ std::string LIBRARY_PATH ; public: double getLatency(bool input); + + void setPluginFilename(std::string filename, int plugin); } ; #endif // __ENGINE__H \ No newline at end of file diff --git a/app/src/main/cpp/Plugin.cpp b/app/src/main/cpp/Plugin.cpp index 1b3fe7e2..0583f657 100644 --- a/app/src/main/cpp/Plugin.cpp +++ b/app/src/main/cpp/Plugin.cpp @@ -288,4 +288,8 @@ void Plugin::setBuffer (float * buffer, int read_bytes) { lv2Descriptor->connect_port(handle, 9, & read_bytes); lv2Descriptor->connect_port(handle, 2, buffer); OUT +} + +void Plugin::setFileName (std::string filename) { + lv2Descriptor->connect_port(handle, 4, (void *) filename.c_str()); } \ No newline at end of file diff --git a/app/src/main/cpp/Plugin.h b/app/src/main/cpp/Plugin.h index 2768e699..732f1412 100644 --- a/app/src/main/cpp/Plugin.h +++ b/app/src/main/cpp/Plugin.h @@ -43,6 +43,8 @@ class Plugin { void load(); int addPluginControl(const LV2_Descriptor *_descriptor, nlohmann::json _j); + + void setFileName(std::string filename); }; template diff --git a/app/src/main/cpp/SharedLibrary.h b/app/src/main/cpp/SharedLibrary.h index b21b6abf..237869b5 100644 --- a/app/src/main/cpp/SharedLibrary.h +++ b/app/src/main/cpp/SharedLibrary.h @@ -83,6 +83,7 @@ class SharedLibrary { unsigned long sampleRate ; LADSPA_Descriptor_Function descriptorFunction ; LV2_Descriptor_Function lv2DescriptorFunction ; + (void)(LV2_Handle, ) void setSampleRate(unsigned long _sampleRate); char *load(); diff --git a/app/src/main/cpp/native-lib.cpp b/app/src/main/cpp/native-lib.cpp index de693203..9371356f 100644 --- a/app/src/main/cpp/native-lib.cpp +++ b/app/src/main/cpp/native-lib.cpp @@ -845,4 +845,18 @@ Java_com_shajikhan_ladspa_amprack_AudioEngine_getLatency(JNIEnv *env, jclass cla return -1.0; return engine->getLatency(input); +} +extern "C" +JNIEXPORT void JNICALL +Java_com_shajikhan_ladspa_amprack_AudioEngine_setPluginFilename(JNIEnv *env, jclass clazz, + jstring filename, jint plugin) { + if (!engine) + return; + + const char *nativeString = env->GetStringUTFChars(filename, 0); + + // use your string + + engine->setPluginFilename(std::string (nativeString), plugin); + env->ReleaseStringUTFChars(filename, nativeString); } \ No newline at end of file diff --git a/app/src/main/java/com/shajikhan/ladspa/amprack/AudioEngine.java b/app/src/main/java/com/shajikhan/ladspa/amprack/AudioEngine.java index 0cdd06fc..3685f180 100644 --- a/app/src/main/java/com/shajikhan/ladspa/amprack/AudioEngine.java +++ b/app/src/main/java/com/shajikhan/ladspa/amprack/AudioEngine.java @@ -74,6 +74,7 @@ public class AudioEngine { static native void testLV2 (); static native void setPluginBuffer (float [] data, int plugin); + static native void setPluginFilename (String filename, int plugin); static native String tuneLatency (); static void setDefaultStreamValues(Context context) { diff --git a/app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java b/app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java index 999747b5..50f1cd89 100644 --- a/app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java +++ b/app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java @@ -1674,6 +1674,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { } if (resultCode == RESULT_OK && requestCode > 4999 && requestCode < 5020) { + /* todo: + 1. Check if file is audio OR better plugin name + 2. If it is, do below + 3. If it is not, send filename to NAM plugin + 4. maybe a switch here, if NAM do this, if Looper do that + + */ int plugin = requestCode - 5000 ; AudioDecoder audioDecoder = new AudioDecoder(this); MediaCodecList supported = new MediaCodecList(MediaCodecList.ALL_CODECS); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ccdb7800..372b4c54 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ Amp Rack Version 4 Razor - 593 + 596 [new] Video Recorder\n\n Welcome to Version 4: \n\n