Sampled Instrument Player with static and monolithic design. All instruments are built-in.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.4 KiB

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
Copyright 2022, Nils Hilbricht, Germany ( )
This file is part of the Laborejo Software Suite ( ),
This application is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <>.
import logging; logger = logging.getLogger(__name__);"import")
from PyQt5 import QtCore
class EventLoop(object):
def __init__(self):
"""The loop for all things GUI and controlling the GUI (e.g. by a control midi in port)
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.
But not realtime. This is not the realtime loop. Converting midi into instrument sounds
or playing back sequenced midi data is not handled by this loop at all.
Creating a non-qt class for the loop is an abstraction layer that enables the engine to
work without modification for non-gui situations. In this case it will use its own loop,
like python async etc.
A qt event loop needs the qt-app started. Otherwise it will not run.
We init the event loop outside of main but call start from the mainWindow.
self.fastLoop = QtCore.QTimer()
self.slowLoop = QtCore.QTimer()
self.verySlowLoop = QtCore.QTimer()
def fastConnect(self, function):
def slowConnect(self, function):
def verySlowConnect(self, function):
def fastDisconnect(self, function):
"""The function must be the exact instance that was registered"""
def slowDisconnect(self, function):
"""The function must be the exact instance that was registered"""
def verySlowDisconnect(self, function):
"""The function must be the exact instance that was registered"""
def start(self):
"""The event loop MUST be started after the Qt Application instance creation""""Starting fast qt event loop")
self.fastLoop.start(20)"Starting slow qt event loop")
self.slowLoop.start(100)"Starting very slow qt event loop")
def stop(self):"Stopping fast qt event loop")
self.fastLoop.stop()"Stopping slow qt event loop")
self.slowLoop.stop()"Stopping very slow qt event loop")