Browse Source

middle mouse button on gui instrument channels now play a short test sound with the selected instrument. Still crashes if you do too many in a row

Former-commit-id: 0ec66ae2e68fa25f9a55214beb9bae8ab00a3b74
master
Nils 4 years ago
parent
commit
c223206ba4
  1. 14
      engine/api.py
  2. 10
      qtgui/mainwindow.py

14
engine/api.py

@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import template.engine.api #we need direct access to the module to inject data in the provided structures. but we also need the functions directly. next line:
from template.engine.api import *
import template.engine.ly2cbox as ly2cbox
#New callbacks
class ClientCallbacks(Callbacks): #inherits from the templates api callbacks
@ -39,6 +41,8 @@ def startEngine(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.
callbacks._soundfontChanged()
callbacks._ignoreProgramChangesChanged()
@ -62,3 +66,13 @@ def _registerMidiCallbacks():
session.data.midiInput.midiProcessor.callbacks3[(MidiProcessor.SIMPLE_EVENT, MidiProcessor.M_CONTROL_CHANGE)] = _controlChange
#session.data.midiInput.midiProcessor.callbacks2[(MidiProcessor.SIMPLE_EVENT, MidiProcessor.PROGRAMCHANGE)] = _programChange
#Sampler
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.
if channel <1 or channel > 16:
raise ValueError(f"Midi Channel must be between 1 and 16 inclusive. Yours is {channel}")
callbacks._channelActivity(channel)
session.data.midiInput.scene.play_pattern(playTestSignal.patterns[channel], 150.0, id=channel) #If there is already an adhoc pattern with a given non-zero id, stop it and release all the pending notes. Retry until all the notes are released.

10
qtgui/mainwindow.py

@ -273,4 +273,12 @@ class ChannelStrip(QtWidgets.QGroupBox):
self.ui.comboBox_bank.blockSignals(False)
self.ui.comboBox_program.blockSignals(False)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.MiddleButton:
api.playTestSignal(self.channelNumber)
event.accept()
else:
event.ignore()
super().mousePressEvent(event)

Loading…
Cancel
Save