Skip to content

Commit

Permalink
Event modifiers, range mode, Editor window updated, variuos fixes.
Browse files Browse the repository at this point in the history
Incoming event can now be transformed directly from the Editor window.
NoLaE now can convert any NOTE or CTRL event coming from the Launch Control,
ctrl IDs can be changed, ctrl values can become notes (the ctrl value can be
a note or a velocity), knobs and faders can send notes too.
Every controller has a range mode: buttons can have different press/release
values, knobs/faders can have a different range, indipendently from the
incoming value. As for the latter, there are 4 range modes: Equal, Single min
(minimum value is only at the beginning of the scale), Single max (maximum
value is only at the end of the scale), Single ends (minimum and maximum values
are only at the beginning and end of the scale); for example, using a range
from 0 to 8, value 0 can be reached only on the first step of the controller,
the other values are equally divided within the scale.
Editor window has been updated accordingly, the Note modifier has a small piano
keyboard widget to easily select the preferred fixed note.
There was a bug that ignored some mappings in the first template and in the
top left knob, now it is fixed along with other minor bugs.
Menus have been fixed too, it is also possible to CTRL+s to save the current
config file now.
  • Loading branch information
MaurizioB committed Jul 8, 2016
1 parent 16a3188 commit d3e9055
Show file tree
Hide file tree
Showing 8 changed files with 714 additions and 121 deletions.
96 changes: 93 additions & 3 deletions classes.py
Expand Up @@ -61,14 +61,14 @@ def __init__(self, template, widget, ext=True, mode=Value, dest=Pass, patch=md.P
self.led = widget.siblingLed
else:
self.led = None
elif led is False:
elif isinstance(led, bool) and led == False:
self.led = None
else:
self.led = led
widget.siblingLed = led

# self.led_basevalue = led_basevalue
if self.led:
if self.led is not None:
self.led_setup(led_basevalue)
else:
self.led_state = self.led_basevalue = 0
Expand Down Expand Up @@ -116,7 +116,7 @@ def led_ignore_action(self, event):
pass

def led_assign(self, action):
if not self.led:
if self.led is None:
self.led_action = self.led_ignore_action
return
if action == Pass:
Expand Down Expand Up @@ -279,3 +279,93 @@ def __init__(self, parent, text):
self.move(center-self.width()/2, parent.y()-10)
self.setStyleSheet('background-color: rgba(210,210,210,210); border: 1px solid gray;')
self.raise_()

class PianoKey(QtGui.QWidget):
def __init__(self, parent, id):
QtGui.QWidget.__init__(self, parent)
self.id = id
self.name = md.util.note_name(id)
self.black = True if self.name[1]=='#' else False
self.octave, self.note = divmod(id, 12)
self.hover_color = QtCore.Qt.red
if self.black:
self.color = QtCore.Qt.black
self.setMinimumSize(7, 24)
self.setMaximumSize(7, 24)
if (self.note & 1) == 1:
self.move(self.octave*7*10+self.note/2*10+7, 0)
else:
self.move(self.octave*7*10+(self.note+1)/2*10+7, 0)
else:
if self.id < 21 or self.id > 108:
self.color = QtCore.Qt.gray
elif self.id < 36 or self.id > 96:
self.color = QtGui.QColor(220, 220, 220)
elif self.id == 60:
self.color = QtGui.QColor(230, 230, 230)
else:
self.color = QtCore.Qt.white
self.setMinimumSize(10, 48)
self.setMaximumSize(10, 48)
if (self.note & 1) == 0:
self.move(self.octave*7*10+self.note/2*10, 0)
else:
self.move(self.octave*7*10+(self.note+1)/2*10, 0)
self.lower()
self._color = self.color
self.current_color = self.color

def showEvent(self, event):
self.update()

def paintEvent(self, event):
qp = QtGui.QPainter()
qp.begin(self)
self.draw_key(qp)
qp.end()

def draw_key(self, qp):
qp.setPen(QtGui.QPen(QtCore.Qt.black, 0.5, QtCore.Qt.SolidLine))
qp.setBrush(self.current_color)
qp.drawRect(0, 0, self.width(), self.height())

def mouseReleaseEvent(self, event):
self.parent().done(self.id+1)

def enterEvent(self, event):
self.current_color = self.hover_color
self.update()

def leaveEvent(self, event):
self.current_color = self.color
self.update()

class Piano(QtGui.QDialog):
def __init__(self, parent):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle('Note selector')
self.keys = []
self.highlight = None
for i in range(128):
key = PianoKey(self, i)
self.keys.append(key)
self.setMinimumHeight(key.height())
self.setMinimumWidth(key.width()*75)

def exec_(self, highlight=None):
if self.highlight:
key = self.keys[self.highlight]
key.current_color = key.color = key._color
key.repaint()
key.update()
if highlight:
self.highlight = highlight
key = self.keys[self.highlight]
key.current_color = key.color = QtGui.QColor(255, 150, 150)
key.repaint()
key.update()
else:
self.highlight = None
return QtGui.QDialog.exec_(self)


9 changes: 5 additions & 4 deletions const.py
Expand Up @@ -31,10 +31,11 @@ class Const(object):

#TODO Split is missing, update function with regex
md_replace = ('Ctrl', 'Port', 'Channel', 'Velocity',
'Note', 'Pitchbend', 'Aftertouch', 'Program', 'SysEx', 'Generator',
'extra.Harmonize', 'LimitPolyphony', 'MakeMonophonic', 'LatchNotes', 'Panic'
'Discard', 'Pass', 'Sanitize', 'Print',
'EVENT'
'Note', 'Pitchbend', 'Aftertouch', 'Program', 'Generator',
'event.MidiEvent', 'event.SysExEvent',
'extra.Harmonize', 'LimitPolyphony', 'MakeMonophonic', 'LatchNotes', 'Panic',
'Discard', 'Pass', 'Sanitize', 'Print', 'Process', 'Call',
'EVENT_DATA1', 'EVENT_DATA2',
)

patch_colors = (('darkred', 'red'), ('gray', 'black'))
Expand Down

0 comments on commit d3e9055

Please sign in to comment.