Repository navigation
Expand file tree
/
Copy pathLoopThread.py
More file actions
40 lines (30 loc) · 1.39 KB
/
Copy pathLoopThread.py
File metadata and controls
40 lines (30 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# helpful resource: https://www.geeksforgeeks.org/python/start-and-stop-a-thread-in-python/
import threading
import time
from FluidSynth import FluidSynth
from SharedVariables import SharedVariables
class LoopTask:
def __init__(self):
self._running = True
def terminate(self):
self._running = False
def run(self):
while self._running:
self.loopThread()
def loopThread(self):
for currentIndex in range(4):
for ext in reversed(SharedVariables.extensions):
if ext.chordIndex == currentIndex:
if ext.isChecked and SharedVariables.loopSelectedCheckbox.isChecked():
noteThread = threading.Thread(target=FluidSynth.playsound, args=(FluidSynth, ext.midiValue))
noteThread.start()
print("playing note ", ext.midiValue)
if ext.isProposed and SharedVariables.loopSuggestedCheckbox.isChecked():
noteThread = threading.Thread(target=FluidSynth.playsound, args=(FluidSynth, ext.midiValue))
noteThread.start()
print("playing note ", ext.midiValue)
currentIndex += 1
time.sleep(0.5)
# self.loopThread()
# (ext.isChecked and SharedVariables.loopSelectedCheckbox.isChecked) or
# self.startLoop()