Browse Source

increase timer. CPU will go up until fixed, but at least it works

master
Nils 4 years ago
parent
commit
879b9b5cc3
  1. 2
      template/engine/api.py
  2. 23
      template/qtgui/mainwindow.py

2
template/engine/api.py

@ -295,9 +295,9 @@ def startEngine(nsmClient):
assert callbacks
session.nsmClient = nsmClient
session.eventLoop.directConnect(callbacks._checkPlaybackStatusAndSendSignal)
session.eventLoop.fastConnect(callbacks._setPlaybackTicks)
session.eventLoop.fastConnect(cbox.get_new_events) #global cbox.get_new_events does not eat dynamic midi port events.
session.eventLoop.slowConnect(callbacks._checkPlaybackStatusAndSendSignal)
session.eventLoop.slowConnect(callbacks._checkBBTAndSendSignal)
#session.eventLoop.slowConnect(lambda: print(cbox.Transport.status().tempo))
#asession.eventLoop.slowConnect(lambda: print(cbox.Transport.status()))

23
template/qtgui/mainwindow.py

@ -53,7 +53,10 @@ class EventLoop(object):
def __init__(self):
"""The loop for all things GUI and controlling the GUI (e.g. by a control midi in port)
By default use fastConnect.
directConnect is 0ms (see below)
fastConnect 20ms
slowConnect 100ms
verySlowConnect 200ms
0 ms means "if there is time". 10ms-20ms is smooth. 100ms is still ok.
Influences everything. Control Midi In Latency, playback cursor scrolling smoothnes etc.
@ -69,10 +72,14 @@ class EventLoop(object):
We init the event loop outside of main but call start from the mainWindow.
"""
self.directLoop = QtCore.QTimer()
self.fastLoop = QtCore.QTimer()
self.slowLoop = QtCore.QTimer()
self.verySlowLoop = QtCore.QTimer()
def directConnect(self, function):
self.directLoop.timeout.connect(function)
def fastConnect(self, function):
self.fastLoop.timeout.connect(function)
@ -97,6 +104,8 @@ class EventLoop(object):
def start(self):
"""The event loop MUST be started after the Qt Application instance creation"""
logger.info("Starting direct qt event loop")
self.directLoop.start(0)
logger.info("Starting fast qt event loop")
self.fastLoop.start(20)
logger.info("Starting slow qt event loop")
@ -105,6 +114,8 @@ class EventLoop(object):
self.verySlowLoop.start(200)
def stop(self):
logger.info("Stopping direct qt event loop")
self.directLoop.stop()
logger.info("Stopping fast qt event loop")
self.fastLoop.stop()
logger.info("Stopping slow qt event loop")
@ -143,9 +154,9 @@ class MainWindow(QtWidgets.QMainWindow):
super().__init__()
self.qtApp = qtApp
self.qtApp.setWindowIcon(QtGui.QIcon(":icon.png")) #non-template part of the program
QtGui.QIcon.setThemeName("hicolor") #audio applications can be found here. We have no need for other icons.
QtGui.QIcon.setThemeName("hicolor") #audio applications can be found here. We have no need for other icons.
logger.info("Init MainWindow")
#Callbacks. Must be registered before startEngine.
api.callbacks.message.append(self.callback_message)
@ -172,9 +183,9 @@ class MainWindow(QtWidgets.QMainWindow):
self.setWindowTitle(self.nsmClient.ourClientNameUnderNSM)
self.qtApp.setApplicationName(self.nsmClient.ourClientNameUnderNSM)
self.qtApp.setApplicationDisplayName(self.nsmClient.ourClientNameUnderNSM)
self.qtApp.setOrganizationName("Laborejo Software Suite")
self.qtApp.setOrganizationDomain("laborejo.org")
self.qtApp.setApplicationVersion(METADATA["version"])
self.qtApp.setOrganizationName("Laborejo Software Suite")
self.qtApp.setOrganizationDomain("laborejo.org")
self.qtApp.setApplicationVersion(METADATA["version"])
self.setAcceptDrops(True)
self.debugScriptRunner = DebugScriptRunner(apilocals=locals()) #needs to have trueInit called after the session and nsm was set up. Which happens in startEngine.

Loading…
Cancel
Save