Skip to content

Commit

Permalink
NAM compiles and runs, but doesnt work
Browse files Browse the repository at this point in the history
:sad:
  • Loading branch information
Shaji Khan committed Apr 18, 2024
1 parent a0ab50d commit 730983c
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"-1": {
"Plugin": true,
"AmplifierPlugin": true,
"optionalFeature": "http://lv2plug.in/ns/lv2core#hardRTCapable",
"port": "_:n62c4bb580b1c42edb579f4b1e2d6cc04b8",
"project": "http://lv2plug.in/ns/lv2",
"http://usefulinc.com/ns/doap#license": "http://opensource.org/licenses/isc",
"http://usefulinc.com/ns/doap#name": "Looper Plugin",
"pluginName": "Neural Amp Modeler"
},
"0": {
"InputPort": true,
"ControlPort": true,
"default": "1.0",
"index": 2,
"maximum": 6,
"minimum": 0,
"name": "Input Level",
"symbol": "input_level"
},
"1": {
"InputPort": true,
"ControlPort": true,
"default": "1.0",
"index": 3,
"maximum": 6,
"minimum": 0,
"name": "Output Level",
"symbol": "output_level"
},
"2": {
"AudioPort": true,
"InputPort": true,
"index": 0,
"name": "In",
"symbol": "audio_in"
},
"3": {
"AudioPort": true,
"OutputPort": true,
"index": 1,
"name": "Out",
"symbol": "audio_out"
}
}
6 changes: 6 additions & 0 deletions app/src/main/assets/lv2_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -1336,5 +1336,11 @@
"id": 8100,
"index": 0,
"library": "liblooper.so"
},
"33000": {
"name": "Neural Amp Modeler",
"id": 8101,
"index": 0,
"library": "neural_amp_modeler.so"
}
}
3 changes: 3 additions & 0 deletions app/src/main/assets/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"Looper": [
8100
],
"Neural Amp Modelling": [
8101
],
"Cabinet": [
2592, 2601, 2606, 2589, 15012, 8095, 8018, 24700, 7037, 5006, 5004,
6004,5033,4065,2603,2607,7033,7035,8027,8060,8092,7038,8029
Expand Down
1 change: 0 additions & 1 deletion app/src/main/cpp/SharedLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ public boolean onTouch(View v, MotionEvent event) {
}

Button fileChooser = null;
if (pluginName .equals( "Looper")) {
if (pluginName .equals( "Looper") || pluginName.equals("Neural Amp Modeler")) {
fileChooser = new Button(mainActivity);
fileChooser.setText("Load file");
if (mainActivity.useTheme)
Expand All @@ -647,7 +647,10 @@ public boolean onTouch(View v, MotionEvent event) {
@Override
public void onClick(View v) {
Intent intent_upload = new Intent();
intent_upload.setType("audio/*");
if (pluginName.equals("Looper"))
intent_upload.setType("audio/*");
else
intent_upload.setType("*/*");
intent_upload.setAction(Intent.ACTION_OPEN_DOCUMENT);
intent_upload.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
intent_upload.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/com/shajikhan/ladspa/amprack/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,23 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
4. maybe a switch here, if NAM do this, if Looper do that
*/

int plugin = requestCode - 5000 ;
Uri returnUri = data.getData();
if (returnUri != null) {
String mimeType = getContentResolver().getType(returnUri);
if (!mimeType.startsWith("audio")) {
String path = returnUri.getPath();
if (path != null) {
Log.d(TAG, String.format ("setFileName: %s", returnUri.getPath()));
String s = getFileContent(returnUri);
Log.d(TAG, String.format ("[content]: %s", s));
AudioEngine.setPluginFilename(s, plugin);
}
return;
}
}

AudioDecoder audioDecoder = new AudioDecoder(this);
MediaCodecList supported = new MediaCodecList(MediaCodecList.ALL_CODECS);
int numCodecs = MediaCodecList.getCodecCount();
Expand Down Expand Up @@ -3660,4 +3676,30 @@ public static abstract class OnEngineStartListener {
engineStartListeners.add(this);
}
}

public String getFileContent(Uri uri) {
InputStreamReader inputStreamReader = null;
try {
inputStreamReader = new InputStreamReader(getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
Log.e(TAG, "getFileContent: ", e);
throw new RuntimeException(e);
}

BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuilder sb = new StringBuilder();
String s;
while (true) {
try {
if (!((s = bufferedReader.readLine()) != null)) break;
} catch (IOException e) {
Log.e(TAG, "getFileContent: ", e);
throw new RuntimeException(e);
}

sb.append(s);
}
String fileContent = sb.toString();
return fileContent;
}
}
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/jniLibs/x86/neural_amp_modeler.so
Binary file not shown.
Binary file added app/src/main/jniLibs/x86_64/neural_amp_modeler.so
Binary file not shown.
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
<item>libgnuitar-distort.lv2.so</item>
<item>libgnuitar-distort2.lv2.so</item>
<item>liblooper.so</item>
<item>neural_amp_modeler.so</item>
</string-array>
<string name="title_activity_settings">Settings</string>

Expand Down

0 comments on commit 730983c

Please sign in to comment.