Skip to content

Commit

Permalink
ladies and gentlemen, NAM
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Apr 17, 2024
1 parent 6eb264a commit a0ab50d
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/cpp/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/cpp/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ std::string LIBRARY_PATH ;

public:
double getLatency(bool input);

void setPluginFilename(std::string filename, int plugin);
} ;

#endif // __ENGINE__H
4 changes: 4 additions & 0 deletions app/src/main/cpp/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
2 changes: 2 additions & 0 deletions app/src/main/cpp/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Plugin {
void load();

int addPluginControl(const LV2_Descriptor *_descriptor, nlohmann::json _j);

void setFileName(std::string filename);
};

template<class UnaryFunction>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/SharedLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/cpp/native-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="app_name">Amp Rack</string>
<string name="app_version">Version 4 Razor</string>
<string name="build_id">593</string>
<string name="build_id">596</string>
<string name="onboard_description">
[new] Video Recorder\n\n
Welcome to Version 4: \n\n
Expand Down

0 comments on commit a0ab50d

Please sign in to comment.