Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ USE_BUTTONS = True
USE_GUI = False
SAMPLES_DIR = None
AUDIO_DEVICE_ID = -1
USE_LAUNCHPAD = True
AUDIO_DEVICE_NAME = autodetect
BOXRELEASE = 30
PRESET_BASE = 0
Expand Down
1 change: 1 addition & 0 deletions modules/globalvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
USE_HD44780_16x2_LCD = cp.get_option_by_name('USE_HD44780_16x2_LCD')
USE_HD44780_20x4_LCD = cp.get_option_by_name('USE_HD44780_20x4_LCD')
USE_FREEVERB = cp.get_option_by_name('USE_FREEVERB')
USE_LAUNCHPAD = cp.get_option_by_name('USE_LAUNCHPAD')
USE_TONECONTROL = cp.get_option_by_name('USE_TONECONTROL')
USE_I2C_7SEGMENTDISPLAY = cp.get_option_by_name('USE_I2C_7SEGMENTDISPLAY')
USE_GUI = cp.get_option_by_name('USE_GUI')
Expand Down
47 changes: 45 additions & 2 deletions samplerbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@
##########################

midi_in = rtmidi2.MidiInMulti()
excluded_ports = ['Midi Through', 'LoopBe Internal']

if gv.USE_LAUNCHPAD:
excluded_ports.extend(['Launchpad', 'RtMidiOut', 'RTMIDI'])

curr_ports = []
prev_ports = []
first_loop = True
Expand All @@ -205,8 +209,10 @@ def midi_devices_loop():
midi_in.close_ports()
prev_ports = []
for port in curr_ports:
if port not in prev_ports and 'Midi Through' not in port and (
len(prev_ports) != len(curr_ports) and 'LoopBe Internal' not in port):
if len([excluded_port_name for excluded_port_name in excluded_ports if excluded_port_name in port]) > 0 :
print "Ignored MIDI port: ", port
continue
if port not in prev_ports and (len(prev_ports) != len(curr_ports)):
midi_in.open_ports(port)
midi_in.callback = gv.midicallback.callback
if first_loop:
Expand All @@ -218,6 +224,43 @@ def midi_devices_loop():
first_loop = False
time.sleep(0.2)

if gv.USE_LAUNCHPAD:

import grid_instrument

def LaunchpadNoteCallback(messageType, midiNote, velocity):
if messageType is "note_on":
# MidiCallback([0b10010001, midiNote, velocity], None)
gv.ac.noteon(midiNote, 1, velocity)
elif messageType is "note_off":
# MidiCallback([0b10000001, midiNote, velocity], None)
gv.ac.noteoff(midiNote, 1)

def LaunchpadButtonCallback(x, y, pressed):
if gv.SYSTEM_MODE is 1:
if x is 1 and y is 9 and pressed:
gv.nav.state.left()
elif x is 2 and y is 9 and pressed:
gv.nav.state.right()
if gv.SYSTEM_MODE is 2:
if x is 1 and y is 9 and pressed:
gv.nav.down()
elif x is 2 and y is 9 and pressed:
gv.nav.up()

instrument = grid_instrument.GridInstrument();
# set the callback for midi events
instrument.note_callback = LaunchpadNoteCallback
# set the callback for function buttons
instrument.func_button_callback = LaunchpadButtonCallback

instrument.kid_mode = False
instrument.debugging = False
instrument.intro_message = "SamplerBox"

LaunchpadThread = threading.Thread(target=instrument.start)
LaunchpadThread.daemon = True
LaunchpadThread.start()

if gv.USE_GUI and not gv.IS_DEBIAN:

Expand Down