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.4.dev23+gdf87c3f6d 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! ![]()
You’re welcome! I’m training my English ![]()