Browse Source

update template

master
Nils 3 years ago
parent
commit
31b2830ed3
  1. 7
      template/engine/ly2cbox.py
  2. 8
      template/engine/sampler_sf2.py
  3. 6
      template/qtgui/midiinquickwidget.py

7
template/engine/ly2cbox.py

@ -26,6 +26,7 @@ This is mostly meant for development and testing.
#Standard Library Modules #Standard Library Modules
import re import re
from typing import Dict
#Third Party Modules #Third Party Modules
from calfbox import cbox from calfbox import cbox
@ -35,10 +36,10 @@ from . import pitch
from .duration import DB, DL, D1, D2, D4, D8, D16, D32, D64, D128 from .duration import DB, DL, D1, D2, D4, D8, D16, D32, D64, D128
lyToMidi = {} #filled for all pitches on startup, below lyToMidi:Dict[str,int] = {} #filled for all pitches on startup, below
for ly, _pitch in pitch.ly2pitch.items(): for lyPitchString, _pitch in pitch.ly2pitch.items():
octOffset = (pitch.octave(_pitch) +1) * 12 #twelve tones per midi octave octOffset = (pitch.octave(_pitch) +1) * 12 #twelve tones per midi octave
lyToMidi[ly] = octOffset + pitch.halfToneDistanceFromC(_pitch) lyToMidi[lyPitchString] = octOffset + pitch.halfToneDistanceFromC(_pitch)
lyToTicks = { lyToTicks = {

8
template/engine/sampler_sf2.py

@ -25,6 +25,8 @@ import logging; logger = logging.getLogger(__name__); logger.info("import")
#Python Standard Lib #Python Standard Lib
import os.path import os.path
from os import PathLike
from typing import List, Dict, Union
#Third Party #Third Party
from calfbox import cbox from calfbox import cbox
@ -48,9 +50,9 @@ class Sampler_sf2(Data):
def __init__(self, parentSession, filePath, activePatches, ignoreProgramChanges, mixer:bool, defaultSoundfont=None): def __init__(self, parentSession, filePath, activePatches, ignoreProgramChanges, mixer:bool, defaultSoundfont=None):
super().__init__(parentSession) super().__init__(parentSession)
self._unlinkOnSave = [] self._unlinkOnSave:List[Union[str, PathLike]] = [] #old sf2 files no longer in use.
self.filePath = filePath self.filePath = filePath
self.patchlist = {} #bank:{program:name} self.patchlist:Dict[int,Dict[int, str]] = {} #bank:{program:name}
self.buffer_ignoreProgramChanges = ignoreProgramChanges self.buffer_ignoreProgramChanges = ignoreProgramChanges
self.midiInput = MidiInput(session=parentSession, portName="all") self.midiInput = MidiInput(session=parentSession, portName="all")
@ -166,7 +168,7 @@ class Sampler_sf2(Data):
def _convertPatches(self, dictionary:dict): def _convertPatches(self, dictionary:dict):
"""Returns a dict of dicts: """Returns a dict of dicts:
bank:{program:name}""" bank:{program:name}"""
result = {} result:Dict[int,Dict[int, str]] = {} #same as self.patchlist
for value, name in dictionary.items(): for value, name in dictionary.items():
program = value & 127 program = value & 127
bank = value >> 7 bank = value >> 7

6
template/qtgui/midiinquickwidget.py

@ -74,19 +74,19 @@ class QuickMidiInputComboController(QtWidgets.QWidget):
#api.callbacks.auditionerVolumeChanged.append(self.callback__auditionerVolumeChanged) #api.callbacks.auditionerVolumeChanged.append(self.callback__auditionerVolumeChanged)
def callback_startLoadingAuditionerInstrument(self, idkey): def callback_startLoadingAuditionerInstrument(self, idkey):
self.parentWidget.qtApp.setOverrideCursor(QtCore.Qt.WaitCursor) #reset in self.callback_auditionerInstrumentChanged self.parentWidget.qtApp.setOverrideCursor(QtCore.Qt.WaitCursor) # type: ignore #mypy doesn't know PyQts parent Widget #reset in self.callback_auditionerInstrumentChanged
self.label.setText(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "…loading…")) self.label.setText(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "…loading…"))
self.parentWidget.qtApp.processEvents() #actually show the label and cursor self.parentWidget.qtApp.processEvents() #actually show the label and cursor
def callback_auditionerInstrumentChanged(self, exportMetadata:dict): def callback_auditionerInstrumentChanged(self, exportMetadata:dict):
self.parentWidget.qtApp.restoreOverrideCursor() #We assume the cursor was set to a loading animation app = self.parentWidget.qtApp.restoreOverrideCursor() # type: ignore #mypy doesn't know PyQts parent Widget #We assume the cursor was set to a loading animation
key = exportMetadata["id-key"] key = exportMetadata["id-key"]
t = f"➜ [{key[0]}-{key[1]}] {exportMetadata['name']}" t = f"➜ [{key[0]}-{key[1]}] {exportMetadata['name']}"
self.label.setText(t) self.label.setText(t)
def callback__auditionerVolumeChanged(self, value:float): def callback__auditionerVolumeChanged(self, value:float):
self.volumeDial.setValue(value) self.volumeDial.setValue(value)
self.parentWidget.statusBar().showMessage(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "Volume: {}").format(value)) self.parentWidget.statusBar().showMessage(QtCore.QCoreApplication.translate("QuickMidiInputComboController", "Volume: {}").format(value)) # type: ignore #mypy doesn't know PyQts parent Widget
def _sendVolumeChangeToEngine(self, newValue): def _sendVolumeChangeToEngine(self, newValue):
self.volumeDial.blockSignals(True) self.volumeDial.blockSignals(True)

Loading…
Cancel
Save