Replies: 2 comments 1 reply
-
Hi @adbrt I ended up doing something similar but in a python script. It directly binds the buttons connected to the GPIO pins to a MIDI note. A possibility could be to add different signals for double click or long press as well. Also, I created a post about continuing the development of pipedal if you are interested: #147 Steps:
midi.py:import time
from alsa_midi import SequencerClient, WRITE_PORT, NoteOnEvent, NoteOffEvent
from gpiozero import Button
from signal import pause
# Init GPIO Buttons
button1 = Button(pin=17, pull_up=False, bounce_time=None)
button2 = Button(pin=27, pull_up=False, bounce_time=None)
# return first element in array that contains VirMidi
def getVirMidiPorts():
return [p for p in client.list_ports(input=True) if "VirMIDI" in p.name]
client = SequencerClient("GPIO-Midi Client")
# print("outports:")
# print(client.list_ports(output=True))
# print("inports:")
# print(client.list_ports(input=True))
inport = client.create_port("GPIO-Midi out", caps=WRITE_PORT)
virmidi_ports = getVirMidiPorts()
if len(virmidi_ports) == 0:
print("Could not find virtual MIDI ports. Please add 'snd-virmidi' to the file '/etc/modules'. Exiting...")
exit(1)
source_port = virmidi_ports[0]
print("Selected source port: ", source_port)
inport.connect_to(source_port)
def triggerNote(note):
print(f"Sending note: {note}")
client.event_output(NoteOnEvent(note=note, velocity=64, channel=0))
client.drain_output()
client.event_output(NoteOffEvent(note=note, channel=0))
client.drain_output()
time.sleep(0.2)
note1 = 60
note2 = 62
print("Connected")
button1.when_pressed = lambda: triggerNote(note1)
button2.when_pressed = lambda: triggerNote(note2)
pause()
client.close() midi-gpio.service:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@FoolHen Do you need a resistor on the switch, or can you just hook a momentary contact switch directly? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to skip using the web server part and just configure everything through GPIO, even without MIDI controllers, so it would be nice to control various parameters directly through the command line.
I don't know if there is a nicer way of doing that, but for now I used virtual MIDI port and emulated MIDI commands:
midiemu.sh - run this @ reboot with sudo crontab -e
selectpreset.sh
Example usage:
Beta Was this translation helpful? Give feedback.
All reactions