Skip to content

Instantly share code, notes, and snippets.

@rtulke
Forked from PeteMidi/qunexus_neutron.py
Created December 22, 2020 13:13
Show Gist options
  • Save rtulke/cc0a8cee2029cd8ad0780fe79f443aa2 to your computer and use it in GitHub Desktop.
Save rtulke/cc0a8cee2029cd8ad0780fe79f443aa2 to your computer and use it in GitHub Desktop.
MIDI processing (mido) of QuNexus poly pressure for control of Behringer Neutron wave-morphing
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 7 20:13:16 2019
@author: Pete Midi
"""
# basic code for "Neutron goes HydraSynth: poly pressure wave-morphing special" (https://www.youtube.com/channel/PeteMidi)
import mido
outputs = mido.get_output_names()
inputs = mido.get_input_names()
msg_ctrl = mido.Message('control_change', control=2, value=0, channel=1) # mido channel 0..15 -> midi channel 1..16 !!
# qunexus & neutron are both connected via USB MIDI
# works for port names under linux (names on windows / mac os may be different ...)
port_out_neutron = mido.open_output([s for s in outputs if s.startswith('Neutron')][0])
port_out_qunexus = mido.open_output([s for s in outputs if s.startswith('QuNexus')][2])
port_in_qunexus = mido.open_input([s for s in inputs if s.startswith('QuNexus')][0])
split_note = 60 # C3
stop_note = 36 # C1
while True:
for msg in port_in_qunexus.iter_pending():
if msg.type == 'note_on' or msg.type == 'note_off':
note = msg.note
velo = msg.velocity
port_out_neutron.send(msg)
if msg.type == 'polytouch':
note = msg.note
press = msg.value
msg_ctrl.value = 127 - press # inverse! (minimal pressure -> neutron sine wave)
if note < split_note:
msg_ctrl.control = 2 # cc cv2 out (cc can be adjusted with qunexus editor)
port_out_qunexus.send(msg_ctrl)
else:
msg_ctrl.control = 3 # cc cv3 out (cc can be adjusted with qunexus editor)
port_out_qunexus.send(msg_ctrl)
# foot controller connected to qunexus -> neutron mod. wheel (filter cutoff freq)
# if msg.type == 'control_change' and msg.control == 1:
# port_out_neutron.send(msg)
# msg.channel = 2
# port_out_neutron.send(msg)
# msg.channel = 1
if note == stop_note and velo == 0: # stop script with particular 'out of range' note
break
# close ports
port_out_neutron.send(mido.Message('control_change', control=123, value=0, channel=1)) # all notes OFF
port_out_neutron.close()
port_out_qunexus.close()
port_in_qunexus.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment