From 5ecf09842c3d2e83cc9d276ffc90f26954b41989 Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Sun, 24 Jan 2021 18:45:40 +1000 Subject: [PATCH] init --- Midi-Expression-Pedal.py | 17 +++++++++++++++++ README.md | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 Midi-Expression-Pedal.py diff --git a/Midi-Expression-Pedal.py b/Midi-Expression-Pedal.py new file mode 100644 index 0000000..0a87a2f --- /dev/null +++ b/Midi-Expression-Pedal.py @@ -0,0 +1,17 @@ +# Expression pedal settings +exp_min = 0 # Expression pedal minimum value +exp_max = 65535 #Expression pedal maximum value + +# Midi settings +midi_channel = 1 # Target midi channel to write to +cc = 68 # Target Control Change number - this is for Behringer X32 Matrix 5 +cc_min = 0 # Minimum desired CC output +cc_max = 100 # Maximum desired CC output (only want fader to go to unity gain - hence not 127) + +# This function translates the expression pedal value to the equivalent CC value +def translate(exp_val): + return (((exp_val - exp_min) * (cc_max - cc_min)) / (exp_max - exp_min)) + cc_min + +# Test the translate function: +for i in range(65535): + print (translate(i)) \ No newline at end of file diff --git a/README.md b/README.md index efa90c1..1d5a08e 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# Py-Pico-Midi-Expression-Pedal \ No newline at end of file +# Py-Pico-Midi-Expression-Pedal + +This is a Raspberry Pi Pico MicroPython project that takes an expression pedal input via a TRS 1/4" jack connected to ADC pins on the Pico, and outputs a Midi CC message equivalent via USB. + +Midi channel, CC number, and maximum and minimum values can all be set as required. \ No newline at end of file