Neural Amp Modeler and LV2

Turns out Zynthian already has mod-base and mod-ui integrated as an engine. Question is whether Aida-x is also installed or whether it could be installed. This seems to be the repo for Aida: GitHub - AidaDSP/aidadsp-lv2: Aida DSP's audio plugins in lv2 format

NAM is based on Wavenet, Aida is based on RTNeural. From what I could read in the discussions between the developers, RTNeural is lighter than Wavenet, whereas Wavenet is more accurate.

Hi,
I am running Manjaro on an X96Max+ TV box (CPU: Amlogic S905X3, 4 x Cortex A55) and have successfully compiled the NAM lv2 plugin. It is working well when using Ardour as a host but I have to set buffer up to 720 to not get audio glitches. I guess it is due to running full KDE desktop and Ardour. Therefore, I would like to run the plugin on a headless server image.
When using mod-host & mod-ui I am not able to set the amp model because the plugin does not have a UI.

Can you tell me how to load the model when using JALV?
I tried typing ‘model = “/home/themojoman/xyz.nam”’ but this did not work. JALV reported back that there is no ‘model’ parameter although showing it when typing ‘controls’.

Thanks!

1 Like

If you run a GUI version of jalv, e.g. jalv.gtk then it provides a file selector for the model file but you can’t access this with the command line version. I have worked around this by writing a Python script that creates a preset for each model file. You call load presets in jalv.

[Edit] The script:

# Create LV2 manifest.ttl for Neural Amp Modeler from model files in ~/.lv2/Neural_Amp_Modeler.lv2/model directory
from os import listdir
from urllib.parse import quote
import json
username = "username_goes_here"
root_dir = f"/home/{username}/.lv2/Neural_Amp_Modeler.lv2"
with open(f"{root_dir}/manifest.ttl", "w") as file:
    file.write("@prefix atom: <http://lv2plug.in/ns/ext/atom#> .\n")
    file.write("@prefix lv2: <http://lv2plug.in/ns/lv2core#> .\n")
    file.write("@prefix pset: <http://lv2plug.in/ns/ext/presets#> .\n")
    file.write("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n")
    file.write("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n")
    file.write("@prefix state: <http://lv2plug.in/ns/ext/state#> .\n")
    file.write("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n")
    for fname in listdir(f"{root_dir}/models"):
        if fname.endswith(".nam"):
            name = fname[:-4]
            url = quote(name)
            file.write(f"<{url}>\n")
            file.write(f"\ta pset:Preset ;\n")
            file.write(f'\trdfs:label "{name}" ;\n')
            file.write("\tlv2:appliesTo <http://github.com/mikeoliphant/neural-amp-modeler-lv2> ;\n")
            file.write(f"\tstate:state [ <http://github.com/mikeoliphant/neural-amp-modeler-lv2#model> <models/{url}.nam> ] .\n\n")

You should create the folder ~/.lv2/Neural_Amp_Modeler.lv2/models and put the model files in it then run the python script which creates a preset for each .nam file if finds in that directory. You can then launch jalv by jalv http://github.com/mikeoliphant/neural-amp-modeler-lv2 but you then need to manually load the preset within the command line interface thus: preset file:///zynthian/zynthian-data/presets/lv2/Neural_Amp_Modeler_feather-mdl.lv2/33. You can get the list of preset urls by entering presets in the jalv CLI.

3 Likes

@riban This works perfectly - thank you so much!!!

(I tried on my own before you added the script and description where to put the files but could not make it work with presets; could only load saved state with ‘jalv -l’ command)

@riban Wow - and the presets now also show up when using MOD-UI. Perfect!

Be aware that the script replaces the preset file each time it is run with the names of the files in the model directory. This means you may rename the files and re-run the script if you don’t like the names of the preset but also means that old references to presets will no longer work. It relies on the filename of the model being the same as when the preset was created so if you change the name of a model file you must run the script again. It stores the presets in a manifest file in a folder within the user’s home directory. In Zynthian we put them elsewhere. (I modified my script to show here for general use. LV2 subsystem looks in various places for configurations.) It also sticks all the presets in the manifest file which may be slightly unorthodox but was simple hence I could bash it out quickly. I am glad it helped you. We may integrate this into Zynthian if we find time…

2 Likes

I was able to build the current nam-lv2 version succesfully on an RPI 4 (build files attached) and run the Python script to generate the presets on a copy placed at ~/.lv2/Neural_Amp_Modeler.lv2/, with some *.nam files under ./modes
However, it seems neither jalv http://github.com/mikeoliphant/neural-amp-modeler-lv2 nor mod-ui is able to find the plugin.

@riban , @TheMojoMan : Was there any other step necessary in order to run the plugin in jalv or mod-ui or any hints how you got it running? Would you mind sharing your nam-plugin folder for debugging purposes?

Thanks! :blush:

neural_amp_modeler.lv2.zip (94.8 KB)

jalv uses environmental variable LV2_PATH to find plugins and presets. I tend to put plugins in ~/.lv2 when I am testing then we integrate them into Zynthian by putting them in a more appropriate location.

2 Likes

Thanks @riban ! Now mod-ui is now able to find to plugin and I only need to figure out the preset generation

Neat, just got everything working and the performance and sound is excellent, much better imho than AIDA-X. Feather and lite models run flawlessly while standard models start to crackle heavily.

1 Like

@chopsuey I would like to suggest to also have a look at PiPedal. This allows to choose the .nam profiles directly without the need to create presets first. You can find it here: PiPedal | PiPedal guitar effects pedal for Raspberry Pi.

The only reason we use the script to create presets is because otherwise we need to run the GUI which is not optimal workflow on Zynthian. PiPedal looks like a LV2 host (like what Zynthian is) so wouldn’t run nicely on a Zynthian.

Looks like a while since any updates. Does NAM get any further on Pram now?