Browse Source

use channel numbers 1-16 in the gui, keep 0-15 in the engine

master
Nils 5 years ago
parent
commit
5cbaf862ed
  1. 3
      engine/items.py
  2. 2
      engine/track.py
  3. 7
      qtgui/designer/trackWidget.py
  4. 7
      qtgui/designer/trackWidget.ui
  5. 8
      qtgui/submenus.py
  6. 20
      qtgui/trackEditor.py

3
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):

2
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

7
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)

7
qtgui/designer/trackWidget.ui

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1374</width>
<width>1448</width>
<height>530</height>
</rect>
</property>
@ -205,8 +205,11 @@
<property name="prefix">
<string>Channel </string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>15</number>
<number>16</number>
</property>
</widget>
</item>

8
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)

20
qtgui/trackEditor.py

@ -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"])
@ -292,7 +293,8 @@ class TrackWidget(QtWidgets.QGroupBox):
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
#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"""

Loading…
Cancel
Save