From 5a6d187a03c3b9d6e1a1f06262936ce9676eee87 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 29 Mar 2016 00:58:12 +0200 Subject: [PATCH 1/3] Handle Panic Key Receive Panic Key (messagetype=11, note=123) and disable all playingnotes --- samplerbox.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samplerbox.py b/samplerbox.py index 2130d4d..ed6d2d7 100644 --- a/samplerbox.py +++ b/samplerbox.py @@ -232,6 +232,14 @@ def MidiCallback(message, time_stamp): elif (messagetype == 11) and (note == 64) and (velocity >= 64): # sustain pedal on sustain = True + elif (messagetype == 11) and (note == 123): # all notes off + for i in playingnotes: + for n in playingnotes[i]: + if sustain: + sustainplayingnotes.append(n) + else: + n.fadeout(50) + playingnotes[i] = [] ######################################### # LOAD SAMPLES From c702dd38365398d2f353908e54a81d3ce4137678 Mon Sep 17 00:00:00 2001 From: me Date: Wed, 30 Mar 2016 20:37:44 +0200 Subject: [PATCH 2/3] Don't fill empty notes for non melodic instrument (ie: drums) For programs like drums, create a file "config.txt" in the program folder and add the following line: melodicProgram=false --- samplerbox.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/samplerbox.py b/samplerbox.py index ed6d2d7..c1389e7 100644 --- a/samplerbox.py +++ b/samplerbox.py @@ -328,6 +328,16 @@ def ActuallyLoad(): if os.path.isfile(file): samples[midinote, 127] = Sound(file, midinote, 127) + + melodicProgram = True + configfname = os.path.join(dirname, "config.txt") + if os.path.isfile(configfname): + with open(configfname, 'r') as configfile: + for i, pattern in enumerate(configfile): + if r'melodicProgram=false' in pattern: + melodicProgram = False + + initial_keys = set(samples.keys()) for midinote in xrange(128): lastvelocity = None @@ -339,7 +349,7 @@ def ActuallyLoad(): for v in xrange(velocity): samples[midinote, v] = samples[midinote, velocity] lastvelocity = samples[midinote, velocity] - if not lastvelocity: + if not lastvelocity and melodicProgram: for velocity in xrange(128): try: samples[midinote, velocity] = samples[midinote-1, velocity] From 181fa9beb99aa55bf19133c57c3119002653a352 Mon Sep 17 00:00:00 2001 From: me Date: Wed, 30 Mar 2016 20:41:27 +0200 Subject: [PATCH 3/3] ... For programs like drums, create a file "config.txt" in the program folder and add the following line: melodic=false --- samplerbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samplerbox.py b/samplerbox.py index c1389e7..44ef600 100644 --- a/samplerbox.py +++ b/samplerbox.py @@ -334,7 +334,7 @@ def ActuallyLoad(): if os.path.isfile(configfname): with open(configfname, 'r') as configfile: for i, pattern in enumerate(configfile): - if r'melodicProgram=false' in pattern: + if r'melodic=false' in pattern: melodicProgram = False