is there a a way to map the buttons to a PC keyboard keys.?
Mybe you can connect a usb keybord
I think it wouldn't be too hard to implement (I was thinking about doing it but don't have time to)
But as for now, there are no way for samplerbox to know what you do with your keyboard.
i got two momentary switches
def Buttons():
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
global preset, lastbuttontime
i'm guessing it goes
http://www.raspberrypi-spy.co.uk/wp-content/uploads/2014/07/Raspberry-Pi-GPIO-Layout-Worksheet.pdf
one to pin 11 and one to pin 12 and the other side to ground 6,9 or 14
shows 18 used by pcm_clock , is that ok?
I did some patch to write the first preset to a file and then read that out regularly.
I also moved the first preset set to the top.
As I'm no Python guru, there can be lot of improvements to my patch. feel free :)
Keep in mind that the path to the preset file must be mounted read/write.
/tmp unfortunately isn't...
You can easily change the preset by e.g.
echo "4" > /root/SamplerBox/samplerbox.preset.txt
to change to preset 4.
This might be useful for script, e.g. reading out a usb joystick from /dev/js0 (if it exists an Raspibian - I don't know) or something you like
DISCLAIMER:
Use it at your own risk. no guarantee from my side! It's just for experimental use.
So here's my patch, have fun with :)
--- samplerbox.orig.py 2020-11-08 22:02:15.276985705 +0100
+++ samplerbox.py 1970-01-01 01:06:31.300000000 +0100
@@ -19,8 +19,10 @@
USE_SERIALPORT_MIDI = True # Set to True to enable MIDI IN via SerialPort (e.g. RaspberryPi's GPIO UART pins)
USE_I2C_7SEGMENTDISPLAY = True # Set to True to use a 7-segment display via I2C
USE_BUTTONS = True # Set to True to use momentary buttons (connected to RaspberryPi's GPIO pins) to change preset
+USE_PRESETFILE = True # Use Preset file
+PRESETFILE = "/root/SamplerBox/samplerbox.preset.txt"
MAX_POLYPHONY = 80 # This can be set higher, but 80 is a safe value
+preset = 0
#########################################
IMPORT
@@ -396,6 +398,37 @@
ButtonsThread.daemon = True
ButtonsThread.start()
+##########################################
+## PRESET CONFIG FILE THREAD
+##
+##########################################
+
+if USE_PRESETFILE:
- open(PRESETFILE,"w").writelines(str(preset))
- lastbuttontime = 0
- def Presetfile():
- global preset, lastbuttontime
- while True:
- preset_read = int(open(PRESETFILE).readline())
- if preset_read != preset:
- preset = preset_read
- if preset < 0:
- preset = 127
- if preset > 127:
- preset = 0
- lastbuttontime = time.time()
- LoadSamples()
- time.sleep(2.000)
- ButtonsThread = threading.Thread(target=Presetfile)
- ButtonsThread.daemon = True
- ButtonsThread.start()
-
#########################################
7-SEGMENT DISPLAY
@@ -462,7 +495,7 @@
#
#########################################
-preset = 0
+#preset = 0
LoadSamples()
okay... the nice forum software interpreted it itself.
Well... do it by hand:
Below LOCAL CONFIG additional:
USE_PRESETFILE = True # Use Preset file
PRESETFILE = "/root/SamplerBox/samplerbox.preset.txt"
MAX_POLYPHONY = 80 # This can be set higher, but 80 is a safe value
preset = 0
Below: # BUTTONS THREAD (RASPBERRY PI GPIO)
##########################################
PRESET CONFIG FILE THREAD
##########################################
if USE_PRESETFILE:
open(PRESETFILE,"w").writelines(str(preset))
lastbuttontime = 0
def Presetfile():
global preset, lastbuttontime
while True:
preset_read = int(open(PRESETFILE).readline())
if preset_read != preset:
preset = preset_read
if preset < 0:
preset = 127
if preset > 127:
preset = 0
lastbuttontime = time.time()
LoadSamples()
time.sleep(2.000)
ButtonsThread = threading.Thread(target=Presetfile)
ButtonsThread.daemon = True
ButtonsThread.start()
And last but not least below # LOAD FIRST SOUNDBANK
comment out preset:
preset = 0
as we defined on top.
Sorry for inconvenience...