Browse Source

Use new template midi in widget and provide engine required methods

master
Nils 1 year ago
parent
commit
f7f07bef2e
  1. 30
      engine/api.py
  2. 2
      engine/config.py
  3. 7
      qtgui/mainwindow.py

30
engine/api.py

@ -38,13 +38,13 @@ from template.engine.api import callbacks
_templateStartEngine = startEngine
def startEngine(nsmClient):
_templateStartEngine(nsmClient)
#Populate Channel Activity and Channel Instrument Changes midi callbacks
_registerMidiCallbacks()
playTestSignal.patterns = {channel : ly2cbox.pattern("c'16 g c", channel) for channel in range(1, 17)}
#Send initial Data etc.
playTestSignal.patterns = {channel : ly2cbox.pattern("c'16 g c", channel) for channel in range(1, 17)}
#Send initial Data etc.
callbacks._soundfontChanged()
callbacks._ignoreProgramChangesChanged()
@ -53,33 +53,33 @@ def _registerMidiCallbacks():
our data."""
from template.engine.input_midi import MidiProcessor
def _NoteOn(timestamp, channel, m_note, m_velocity):
def _NoteOn(timestamp, channel, m_note, m_velocity):
callbacks._channelActivity(channel+1)
def _controlChange(timestamp, channel, cc_type, m_value):
"""Includes Bank Change, which is a CC.
Jack-Keyboar and other programs send this even if only a program changed. This will
Jack-Keyboard and other programs send this even if only a program changed. This will
trigger our GUI to update the whole channel as well, but technically we don't react to
an individual program change here.
"""
if cc_type == MidiProcessor.CC_BANKCHANGE_COARSE or cc_type == MidiProcessor.CC_BANKCHANGE_FINE:
"""
if cc_type == MidiProcessor.CC_BANKCHANGE_COARSE or cc_type == MidiProcessor.CC_BANKCHANGE_FINE:
callbacks._channelChanged(channel+1)
def _programChange(timestamp, channel, value):
"""The callbacks receiver will fetch the new program values on its own"""
callbacks._channelChanged(channel+1)
session.data.midiInput.midiProcessor.register_NoteOn(_NoteOn)
session.data.midiInput.midiProcessor.register_CC(_controlChange)
session.data.midiInput.midiProcessor.register_ProgramChange(_programChange)
session.data.midiInput.midiProcessor.register_ProgramChange(_programChange)
#Sampler
def playTestSignal(channel:int):
def playTestSignal(channel:int):
"""Channel 1-16
Play a short test chime to verify that sound is working and to see how the instrument sounds"""
#patterns are defined in startEngine because we obviously need to wait for cbox to be ready.
Play a short test chime to verify that sound is working and to see how the instrument sounds"""
#patterns are defined in startEngine because we obviously need to wait for cbox to be ready.
if channel <1 or channel > 16:
raise ValueError(f"Midi Channel must be between 1 and 16 inclusive. Yours is {channel}")
callbacks._channelActivity(channel)

2
engine/config.py

@ -21,7 +21,7 @@ METADATA={
#release announcements, entries in software directories etc.
"tagline" : 'SF2 soundfont sample player for JACK based on Fluidsynth.',
"version" : "1.6.3",
"version" : "1.7.0",
"year" : "2021",
"author" : "Laborejo Software Suite",
"url" : "https://www.laborejo.org/fluajho",

7
qtgui/mainwindow.py

@ -31,6 +31,7 @@ from PyQt5 import QtWidgets, QtCore, QtGui
from template.qtgui.mainwindow import MainWindow as TemplateMainWindow
from template.qtgui.menu import Menu
from template.qtgui.about import About
from template.qtgui.midiinquickwidget import QuickMidiInputComboController
#Client modules
import engine.api as api
@ -78,12 +79,16 @@ class MainWindow(TemplateMainWindow):
self.ui.checkBox_ignoreProgramChanges.hide() #will be shown after loading an sf2
self.ui.checkBox_ignoreProgramChanges.stateChanged.connect(api.setIgnoreProgramAndBankChanges) #one parameter: int state. 0 is unchecked, 1 is partially, 2 is checked
self.ui.checkBox_playTestAfterSelectingProgram.hide() #will be shown after loading an sf2. NThe state is queried by the comboBoxProgram directly
self.ui.checkBox_playTestAfterSelectingProgram.hide() #will be shown after loading an sf2. The state is queried by the comboBoxProgram directly
if "playTestAfterSelectingProgram" in api.session.guiSharedDataToSave:
self.ui.checkBox_playTestAfterSelectingProgram.setChecked(api.session.guiSharedDataToSave["playTestAfterSelectingProgram"])
self.ui.checkBox_playTestAfterSelectingProgram.stateChanged.connect(self.saveCheckBox_playTestAfterSelectingProgram) #one parameter: int state. 0 is unchecked, 1 is partially, 2 is checked
midiInputWidget = QuickMidiInputComboController(self)
layout = self.ui.verticalLayout
layout.insertWidget(3,midiInputWidget)
#Set up the Rack Tree Widget that holds all Channels
####################################################

Loading…
Cancel
Save