From 5cbaf862ed286f2a4031d515da93f6a69ee06549 Mon Sep 17 00:00:00 2001
From: Nils <>
Date: Sun, 30 Jun 2019 22:01:14 +0200
Subject: [PATCH] use channel numbers 1-16 in the gui, keep 0-15 in the engine
---
engine/items.py | 3 ++-
engine/track.py | 2 +-
qtgui/designer/trackWidget.py | 7 ++++---
qtgui/designer/trackWidget.ui | 7 +++++--
qtgui/submenus.py | 8 ++++----
qtgui/trackEditor.py | 24 +++++++++++++-----------
6 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/engine/items.py b/engine/items.py
index 5c46574..903cef7 100644
--- a/engine/items.py
+++ b/engine/items.py
@@ -2763,7 +2763,8 @@ class ChannelChange(Item):
"tickindex" : trackState.tickindex - duration, #we parse the tickindex after we stepped over the item.
"midiBytes" : [],
"text" : self.text,
- "UIstring" : f"{self.text}(ch{self.value})" if self.text else f"ch{self.value}", #this is for a UI, possibly a text UI, maybe for simple items of a GUI. Make it as short and unambigious as possible.
+ #TODO: UIs work with 1-16. The rest of the laborejo engine works with 0-15 but this is dedicated for our own UI, read-only. Export the GUI value directly, even if it is a responsibility mismatch.
+ "UIstring" : f"{self.text}(ch{self.value+1})" if self.text else f"ch{self.value+1}", #this is for a UI, possibly a text UI, maybe for simple items of a GUI. Make it as short and unambigious as possible.
}
def _lilypond(self):
diff --git a/engine/track.py b/engine/track.py
index bb73620..0aa52e8 100644
--- a/engine/track.py
+++ b/engine/track.py
@@ -377,7 +377,7 @@ class Track(object):
self.sequencerInterface = template.engine.sequencer.SequencerInterface(parentTrack=self, name=name)
self.ccGraphTracks = {} #cc number, graphTrackCC. Every CC is its own SequencerTrack that routes to this tracks jack midi out
- self.ccChannels = tuple() #numbers from 0-15 which represent the midi channels all CCs are sent to. Only replaced by a new tuple by the user directly. From json this becomes a list, so don't test for type. If empty then CC uses the initial midi channel.
+ self.ccChannels = tuple() #unsorted numbers from 0-15 which represent the midi channels all CCs are sent to. Only replaced by a new tuple by the user directly. From json this becomes a list, so don't test for type. If empty then CC uses the initial midi channel.
self.blocks = [Block(track = self)]
self.durationSettingsSignature = DurationSettingsSignature() #only one per track
diff --git a/qtgui/designer/trackWidget.py b/qtgui/designer/trackWidget.py
index 96683b8..6204644 100644
--- a/qtgui/designer/trackWidget.py
+++ b/qtgui/designer/trackWidget.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'trackWidget.ui'
#
-# Created by: PyQt5 UI code generator 5.12.1
+# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!
@@ -12,7 +12,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_trackGroupWidget(object):
def setupUi(self, trackGroupWidget):
trackGroupWidget.setObjectName("trackGroupWidget")
- trackGroupWidget.resize(1374, 530)
+ trackGroupWidget.resize(1448, 530)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
@@ -84,7 +84,8 @@ class Ui_trackGroupWidget(object):
self.horizontalLayout_4.setSpacing(3)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.midiChannelSpinBox = QtWidgets.QSpinBox(self.frame_2)
- self.midiChannelSpinBox.setMaximum(15)
+ self.midiChannelSpinBox.setMinimum(1)
+ self.midiChannelSpinBox.setMaximum(16)
self.midiChannelSpinBox.setObjectName("midiChannelSpinBox")
self.horizontalLayout_4.addWidget(self.midiChannelSpinBox)
self.ccChannelsPushButton = QtWidgets.QPushButton(self.frame_2)
diff --git a/qtgui/designer/trackWidget.ui b/qtgui/designer/trackWidget.ui
index 67b5ddb..835092f 100644
--- a/qtgui/designer/trackWidget.ui
+++ b/qtgui/designer/trackWidget.ui
@@ -6,7 +6,7 @@
0
0
- 1374
+ 1448
530
@@ -205,8 +205,11 @@
Channel
+
+ 1
+
- 15
+ 16
diff --git a/qtgui/submenus.py b/qtgui/submenus.py
index a541595..11c09a9 100644
--- a/qtgui/submenus.py
+++ b/qtgui/submenus.py
@@ -598,12 +598,12 @@ class SecondaryChannelChangeMenu(Submenu):
lastCustomValue = 0
def __init__(self, mainWindow):
- super().__init__(mainWindow, "Channel Change 0-15. [enter] to use value")
+ super().__init__(mainWindow, "Channel Change 1-16. [enter] to use value")
self.spinbox = QtWidgets.QSpinBox()
self.spinbox.setValue(type(self).lastCustomValue)
- self.spinbox.setMinimum(0)
- self.spinbox.setMaximum(15)
+ self.spinbox.setMinimum(1)
+ self.spinbox.setMaximum(16)
self.spinbox.setSingleStep(1)
self.layout.addRow("Channel", self.spinbox)
self.name = QtWidgets.QLineEdit()
@@ -612,7 +612,7 @@ class SecondaryChannelChangeMenu(Submenu):
def process(self):
v = self.spinbox.value()
type(self).lastCustomValue = v
- api.channelChange(v, self.name.text())
+ api.channelChange(v-1, self.name.text())
self.done(True)
diff --git a/qtgui/trackEditor.py b/qtgui/trackEditor.py
index 0e9cfe1..47ae2af 100644
--- a/qtgui/trackEditor.py
+++ b/qtgui/trackEditor.py
@@ -52,7 +52,7 @@ class TrackWidget(QtWidgets.QGroupBox):
self.ui.nameLineEdit.editingFinished.connect(self.nameChanged) #only user changes, not through setText() etc.
self.ui.deleteButton.clicked.connect(lambda: api.deleteTrack(self.trackExportObject["id"]))
- self.ui.midiChannelSpinBox.valueChanged.connect(self.dataChanged)
+ self.ui.midiChannelSpinBox.valueChanged.connect(self.dataChanged)
self.ui.midiProgramSpinBox.valueChanged.connect(self.dataChanged)
self.ui.midiBankMsbSpinBox.valueChanged.connect(self.dataChanged)
self.ui.midiBankLsbSpinBox.valueChanged.connect(self.dataChanged)
@@ -64,11 +64,11 @@ class TrackWidget(QtWidgets.QGroupBox):
#Create a menu with checkboxes to allow switching on and off of additional channels for the CC sub-track
#However, we will not use normal checkable Menu actions since they close the menu after triggering. even blockSignals does not prevent closing
- self.ccChannels = []
+ self.ccChannels = {}
ccChannelMenu = QtWidgets.QMenu()
- for i in range(0,16): #excluding 16
+ for i in range(1,17): #excluding 17
checkbox = QtWidgets.QCheckBox(ccChannelMenu)
- self.ccChannels.append(checkbox)
+ self.ccChannels[i] = checkbox
checkbox.stateChanged.connect(self.dataChanged)
widget = QtWidgets.QWidget()
layout = QtWidgets.QFormLayout()
@@ -161,12 +161,12 @@ class TrackWidget(QtWidgets.QGroupBox):
for widget in self.ui.__dict__.values():
widget.blockSignals(True)
- for checkbox in self.ccChannels:
+ for checkbox in self.ccChannels.values():
checkbox.blockSignals(True)
yield
for widget in self.ui.__dict__.values():
widget.blockSignals(False)
- for checkbox in self.ccChannels:
+ for checkbox in self.ccChannels.values():
checkbox.blockSignals(False)
def callClickWidgetForUpbeat(self):
@@ -186,13 +186,14 @@ class TrackWidget(QtWidgets.QGroupBox):
api.setTrackUpbeat(self.trackExportObject["id"], v)
def dataChanged(self):
+ """Our data changed. Send to Engine"""
with self.blockUiSignals():
dictionary = {}
- dictionary["initialMidiChannel"] = self.ui.midiChannelSpinBox.value()
+ dictionary["initialMidiChannel"] = self.ui.midiChannelSpinBox.value()-1
dictionary["initialMidiProgram"] = self.ui.midiProgramSpinBox.value()
dictionary["initialMidiBankMsb"] = self.ui.midiBankMsbSpinBox.value()
dictionary["initialMidiBankLsb"] = self.ui.midiBankLsbSpinBox.value()
- dictionary["ccChannels"] = tuple(i for i, checkbox in enumerate(self.ccChannels) if checkbox.checkState())
+ dictionary["ccChannels"] = tuple(chanNum-1 for chanNum, checkbox in self.ccChannels.items() if checkbox.checkState()) #can be unsorted
dictionary["midiTranspose"] = self.ui.midiTransposeSpinBox.value()
dictionary["duration.defaultOn"] = self.ui.defaultOn.text()
@@ -236,7 +237,7 @@ class TrackWidget(QtWidgets.QGroupBox):
self.trackExportObject = trackExportObject
self.ui.upbeatSpinBox.setValue(trackExportObject["upbeatInTicks"])
self.ui.nameLineEdit.setText(trackExportObject["name"])
- self.ui.midiChannelSpinBox.setValue(trackExportObject["initialMidiChannel"])
+ self.ui.midiChannelSpinBox.setValue(trackExportObject["initialMidiChannel"]+1)
self.ui.midiProgramSpinBox.setValue(trackExportObject["initialMidiProgram"])
self.ui.midiBankMsbSpinBox.setValue(trackExportObject["initialMidiBankMsb"])
self.ui.midiBankLsbSpinBox.setValue(trackExportObject["initialMidiBankLsb"])
@@ -291,8 +292,9 @@ class TrackWidget(QtWidgets.QGroupBox):
self.ui.doubleTrackCheckbox.setChecked(trackExportObject["double"])
self.ui.audibleCheckbox.setChecked(trackExportObject["audible"])
- for i in range(0,16): #without 16
- self.ccChannels[i].setChecked(i in trackExportObject["ccChannels"]) #a checkbox widget
+ for i in range(0,16): #without 16
+ #Engine from 0 to 15, GUI from 1 to 16.
+ self.ccChannels[i+1].setChecked(i in trackExportObject["ccChannels"]) #a checkbox widget.
class TrackEditor(QtWidgets.QWidget):
"""Created by ControlMainWindow. One permanent instance"""