PluginsManager - nice Python library

Hi developers,

did you know the following?

http://pedalpi-pluginsmanager.readthedocs.io/

Really nice work for implementing own LV2-plugin-stacks in Python.

Regards, Holger

2 Likes

Congratularions, @SrMouraSilva!! Nice work! :trophy:
I will give it a try ASAP …

Regards!

1 Like

Thanks for sharing my project! Thank you for this space and I will bring some information about the project (I hope this is allowed in this forum):

Currently support is with mod-host, however it is possible in a short time to develop an observer to use another host, such as Carla, for example. Just extends UpdatesObserver (and implement the connection to the host).

If someone finds a bug, please report on issues. And if anyone is curious about development, check out the milestones.

I am available to answer questions. Even I think it’s cool so I can improve the documentation
I do not have an official channel for this. Can anyone suggest me one?


This project is part of another larger one: the Pedal Pi. It aims to enable users to assemble their equipment for audio processing. Something like MOD Duo (simpler, of course), but allowing a friendly hardware expansion. Exemplifying:

If a user wants to use mod-ui but wants to add footswitches to control the state of the plugins, he should make changes to the mod-ui itself or implement a system On the outside to consume the WebService that was not documented - as MODEP did.

On my system, I’m preparing you to accept this expansion through a documented API. This will allow developers to implement “components” and lay users choose which components to use and benefit from.

An example of a component is the Raspberry-P0, which allows the pedalboard to be exchanged for two footswitches. Note that I tried to write the Readme of the project so that it is simple for people to set it up.

Another component example is the WebService, which offers the project API as REST and WebSocket web services. It is documented.

Other components can be found in the Components list.

3 Likes

Hi,

do you have thought about a converter script which uses a pedalboard created by mod-ui and converts it into Python code using pedalpi-pluginsmanager?

What do you think? Are there any traps which may make such a script impossible?

Regards, Holger

Hello @C0d3man,

Is possible convert Mod-ui pedalboards to PluginsManager. However, there are some implications:


How to convert mod-ui pedalboards to PluginsManager

Part 1 - Loading configurations in PluginsManager using specified json configurations

First of all, PluginsManager has native support for persistence (Autosaver observer). This feature is most commonly used in PedalPi-Application, but you can already use this feature only with PluginsManager.

The documentation informs how to: PedalPi - PluginsManager - Observers — PedalPi - PluginsManager 1 documentation

The banks data is persisted in json files. An example is Bank 1.json.

When Autosaver is used for loaded the previous data, is necessary specify the banks PATH:

system_effect = SystemEffect('system', ('capture_1', 'capture_2'), ('playback_1', 'playback_2'))

PATH = 'my/path/data/'
autosaver = Autosaver(PATH)
banks_manager = autosaver.load(system_effect)

If you add files like Bank 1.json in the PATH, Autosaver will be loads the configurations!
Note: A bank for a file.

Part 2 - Obtain pedalboards data from mod-ui

I tried to find a js function to get some .json from a pedalboard by mod-ui, but I did not succeed.

Mod-ui receives ws messages when a pedalboard has changed. The protocol are similar (or equals) to the mod-host communication protocol.

I think the mod-ui share option send the pedalboard data in json format to pedalboards.moddevices.com.
I tried to simulate the steps, enabling the necessary directly by javascript, but I could not.
The pedalboards.moddevices.com API provides some pedalboard information, but unfortunately, it does not inform the connections (pedalboard json example).

The way to do this is to take the pedalboards in ttl format and convert them to something easy to work with.

Part 3 - Script to convert

I have not implemented a conversion from mod-ui pedalboards to pluginsmanager pedalboard. For this I would consider converting maybe the file to json or working directly with rdf.

A simple example how to extract information:

pip install rdflib-jsonld
from rdflib import Graph, plugin
from rdflib.serializer import Serializer

testrdf = open('my-pedalboard.tld').read()
print(testrdf)

g = Graph().parse(data=testrdf, format='n3')
print(g.serialize(format='json-ld', indent=4))

Considerations

Feel the urge to question and suggest. This month I’m going to present the monograph and the discussion is great for me to prepare for the examining bank.

2 Likes

Hi @SrMouraSilva

Hm… that’s bad… but perhaps not so tricky to implement? Hm - I will take a look at this, but my python skills are limited.

I have done this (for testing purposes) a year ago… have to search for my script. The script was parsing a pedalboard file and wrotes instructions for mod-host. This is not very complicated.

I think converting into json will be the best solution for using directly with PluginsManager. I will try to make some tests and perhaps write a converter script.

Thanks for your (nicely formated) long descriptions!

Regards, Holger

I know, but only now I have a midi interface (my pisound arrived)!
However, the Master’s degree course has begun, the time is short for implement this. But I can help!

Adding a new functionality (observer)

I tried to implement the pedalpi-* libraries to be easy to add new features.

A cool midi implementation requires two things: 1. receive commands for other devices and 2. send commands for other devices:

Mido library

In a old project, I used mido for receive and send midi data. do not remember correctly how you use it, so maybe there’s a bug here.

# Installing: https://mido.readthedocs.io/en/latest/installing.html
pip install mido
# maybe requires python-rtmidi, I don't remember
# pip install python-rtmidi

Connecting with a midi devices

Informations are from: Introduction (Basic Concepts) — Mido 1.3.2.dev7+g7bc7432 documentation

# In IDLE
>>> import mido
>>> # get 
>>> mido.get_input_names()
['Midi Through Port-0', 'SH-201', 'Integra-7']
>>> # for connect, use "mido.open_input('SH-201')"

Receive commands for other devices

Assuming I want to control plugins manager by “SH-201”

def midi_messages_analyzer(message):
    print('Message received!')
    print(message)

inport = mido.open_input('SH-201')
inport.callback = midi_messages_analyzer

Now, by the inport.callback = midi_messages_analyzer line, MIDI messages received from SH-201 are “printed”.

We will implement change the current pedalboard:

Changing current pedalboard

def midi_messages_analyzer(message):
    print('Message received!')
    if message.type == 'control_change':
        print('Pedalboard number: ', message.value)
        # Change code here!
        

Pseudo complete script

# Script from https://discourse.zynthian.org/t/pluginsmanager-nice-python-library/726/5?u=srmourasilva
from pluginsmanager.observer.autosaver.autosaver import Autosaver
from pluginsmanager.observer.mod_host.mod_host import ModHost
from pluginsmanager.model.system.system_effect import SystemEffect

system_effect = SystemEffect('system', ('capture_1', 'capture_2'), ('playback_1', 'playback_2'))

autosaver = Autosaver('my/path/data/')
banks_manager = autosaver.load(system_effect)

# Connect with mod-host
#  http://pedalpi-pluginsmanager.readthedocs.io/en/latest/mod_host.html
mod_host = ModHost('localhost')
mod_host.connect()
banks_manager.register(mod_host)

# Set current pedalboard
bank = banks_manager.banks[0]
mod_host.pedalboard = bank.pedalboards[0]

# The own code
def midi_messages_analyzer(message):
    print('Message received!')

    if message.type == 'control_change':
        pedalboard_number = message.value
        if pedalboard_number < len(bank.pedalboards):
            mod_host.pedalboard = bank.pedalboards[pedalboard_number]
        else:
            print("Pedalboard number", pedalboard_number, "from bank", bank.name, " doesn't exist")

inport = mido.open_input('SH-201')
inport.callback = midi_messages_analyzer

# Safe close
from signal import pause
try:
    pause()
except KeyboardInterrupt:
    mod_host.close()

Send commands for other devices

Is possible notify changes for other devices too using observer. I wrote a document how to create a observer for, when occurs changes in a bank, a pedalboard, an effect, a connection or a parameter, call a special functions: PedalPi - PluginsManager - Observers — PedalPi - PluginsManager 1 documentation

Note: Autosaver and ModHost are observers!

Note: In PluginsManager abstraction level doesn’t exists the “current pedalboard” concept. Current pedalboard are implement in PedalPi-Application.

midi_learn

A cool feature is auto midi-learn.
You can try implement it too! :smiley:




You’re welcome! I’m training my English :grinning:

1 Like

@C0d3man, good morning

I discovered how to get the relevant information from a pedalboard in python. Mod has a function to obtain the data of a pedalboard.

I’ve created a gist containing the information I consider necessary to create a conversion script. I detailed more information in a gist comment

1 Like

@C0d3man

Check the script in my issue commentary.

In the current version, the Lv2EffectBuilder only works with a small plugins list.
But it’s possible works with all lv2 plugins data:

# uncomment
#builder.reload(builder.lv2_plugins_data())

For more information how offers more support, check Lv2EffectBuilder.lv2_plugins_data docummentation.