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?

Hi all and happy new year!

I played around with NAM and MOD-UI/HOST on zynthian recently, and wanted to share some limited insights:

Not knowing enough on how those mod-guis and ttl files work, i tried to put the replace the lv2 .so file in the patchstorage build with the .so file from the optimized build, but it didn’t work.
I think we are almost there, especially if we figure out where and how to apply the optimizations described in the mod forum to the patchstorage lv2 builder (for compiling rpi lv2 on x86-64) or to the lv2 nam repo (for native rpi4 compilation) and document them. Probably a PR would be very much appreaciated by the maintainers of the repo.
Unfortunately such contributions is out of my reach at the moment.

Thanks everyone and hope the insights above can be useful!

3 Likes

HI @zynthian lovers!

We have very good news regarding model-loader simulators like NAM, AIDA-X, etc.

  • First, NAM is now installed in vangelis (testing branch), including the native GUI.
  • Second, and better, LV2’s atom:Path has been implemented and fully integrated in Vangelis (testing branch). Ups! This sound quite weird, right? Well … what about loading neural models and IRs from the zynthian-UI without needing the native GUIs for this anymore? Ohhh! Yes … this sound much better!!

I will elaborate a little bit because it’s a very special feature that open many doors.
Now, when available for the plugin, you will see the new “file” parameters in the control view, as any other controller widget. Something like this:

When you rotate this knob (or vertical dragtouch), the file selector will be open for the parameter (i.e. Neural Model) and you will be allowed to browse and select the file.

The base directory for the file selector is:

/zynthian/zynthian-my-data/files

The file selector will choose the right directory based in the supported file extensions:

  • IRs => wav
  • Neural Models => nam, aidax, json, etc.
  • Tuning => scl

You can organize your models in subdirs inside each one of this 3 dirs.

Also, if “wav” is in the list of supported file formats for the parameter, the “captures” folder will be included. Finally, the file selector will also look into external storage, so you could load your models from a USB pendrive, etc.

Currently we don’t have a webconf-based upload mechanism. We hope to implement this ASAP.

I’m sure some of you would like to know why we are not using the “bank/preset mechanism” for this? Well … this is a very good question. The short answer is:

This is not a preset, it’s a plugin parameter

And we have good reasons to not “hijack” the bank/preset mechanism for this. Plugins can have several oPath (file) parameters. Indeed, currently we have a few plugins that have 2, 3 and up to 4 file parameters. This can’t be fitted into the bank/preset mechanism without twisting things a lot. Current solution may result “strange” but it’s logic and very zynthianic: You want to modify the parameter (choose a file), so rotate the knob to request for this modification. By doing things like this, the implementation has been clean and straightforward. I’m really satisfied.

As i told before, this opens a few doors that were closed until now:

  • Using NAM and AIDA-X without needing the native GUI
  • Using all those nice reverb and cabinet IR-loaders without needing the native GUI
  • Using samplers like samplv1 without needing the native GUI
  • etc.

Enjoy!

17 Likes

This is…

FANTASSSSTIC!!!

:partying_face:

Thanks @jofemodo, It looks fantastic!

I have two questions:

  • Is there a way to use NAM without switching to Vangelis?
    Should I just unpack and copy the NAM LV2 package from /plugins/aarch64/ somewhere in /usr/lib/lv2 or zynthian/zynthian-plugins/lv2, and then create the folders you describe above? (This is probably more a general question on how and where should external LV2 plugins be copied in zynthian).
  • Where I could find more infos on waht are ttl files and how they work? Are these files related to the LV2’s atom:Path you mention above?

I am very eager to test this ASAP on my zynthian-based multifx pedal and give you feedback!
Thanks again for this new and very much appreciated addition!

This is wonderful! It will be great to be able to use these without VNC. Thanks for developing this!

1 Like

Yes, you can install it by hand

This is a very good question. You can try with the TTL specification:

https://www.w3.org/TR/turtle/

and the LV2 specification:

https://lv2plug.in/ns/

Both are written in Ancient Klingon (FYI, modern Klingon variants, like the one used in the famous StarTrek TV show, are much easier), so you will need “some patient” and 2 or 3 full brain expansions to adapt your neural networks to the old klingon “way of thinking”.
I expanded my own brain using a cheap “surgical kit” from aliexpress and now i can understand a little bit of these specs, specially on very bright days, but the adverse effects are terrible!! Like visualizing coloured TTL triplets in real time, overlapped to what i see with my eyes, while people talks to me. It’s specially annoying when my little daughters try to explain to me their school day, for instance…

Good luck! :grin:

3 Likes

Yes, I can confirm this. It’s just the more far northern dialect of Klingon, where all the time, they are skipping subjects and verbs to say something important.
:rofl: :vulcan_salute:

1 Like