Bufix OP-Z Not found error

Added Audio Device Detection (necessary in windows)
Improved Error feedback and MIDI port handling
This commit is contained in:
Thomas Herrmann 2022-03-31 17:13:30 +02:00
parent e282eb960c
commit 54c8826467
2 changed files with 29 additions and 9 deletions

BIN
dist/underbridge.exe vendored

Binary file not shown.

View File

@ -12,6 +12,7 @@ import os
device_list = [] device_list = []
op_device = [] op_device = []
audio_device = []
loop_time = 0 loop_time = 0
inport = 0 inport = 0
outport = 0 outport = 0
@ -36,15 +37,25 @@ def getMIDIDevice():
print (op_device) print (op_device)
displaymsg.set("OP-Z found") displaymsg.set("OP-Z found")
except: except:
displaymsg.set("Can´t find OP-Z : MIDI Error") displaymsg.set("Can´t find OP-Z : MIDI Error.")
def getAudioDevice(): def getAudioDevice():
global audio_device
p = pyaudio.PyAudio() p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0) try:
numdevices = info.get('deviceCount') info = p.get_host_api_info_by_index(0)
for i in range(0, numdevices): numdevices = info.get('deviceCount')
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0: for i in range(0, numdevices):
print("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')) if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name'))
for i in range(0, numdevices):
#audio_device = p.get_device_info_by_host_api_device_index(0, i).get('name')
if "OP-Z" in p.get_device_info_by_host_api_device_index(0, i).get('name') and (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
audio_device = i
print ("Detected OP-Z audio at Index:",audio_device, p.get_device_info_by_host_api_device_index(0, audio_device).get('name'))
except:
displaymsg.set("OP-Z Audio Device not found.")
def getBPM(): def getBPM():
global op_device global op_device
@ -123,7 +134,9 @@ def nextSong():
pass pass
def closeMidi(): def closeMidi():
pass global outport
outport.close()
displaymsg.set("MIDI closed")
def setPath(): def setPath():
global path global path
@ -159,6 +172,8 @@ def start_Rec():
global j global j
global pro global pro
global pattern_nr global pattern_nr
global audio_device
CHUNK = 128 CHUNK = 128
FORMAT = pyaudio.paInt16 FORMAT = pyaudio.paInt16
CHANNELS = 2 CHANNELS = 2
@ -171,7 +186,9 @@ def start_Rec():
channels=CHANNELS, channels=CHANNELS,
rate=RATE, rate=RATE,
input=True, input=True,
input_device_index= audio_device,
frames_per_buffer=CHUNK frames_per_buffer=CHUNK
) )
#print("* recording") #print("* recording")
@ -203,6 +220,7 @@ def start_Rec():
displaymsg.set("End of Recording") displaymsg.set("End of Recording")
def sequenceMaster(): def sequenceMaster():
global cancel global cancel
global pattern_nr global pattern_nr
cancel = 0 cancel = 0
@ -245,13 +263,15 @@ def sequenceMaster():
pattern_nr = 0 pattern_nr = 0
sequenceMaster() sequenceMaster()
except: except:
displaymsg.set("OP-Z Audio Device Problem :(") displaymsg.set("OP-Z Sequence error try restarting the OP-Z or press CANCEL Button")
def cancelRec(): def cancelRec():
global cancel global cancel
global outport
global j global j
j = 0 j = 0
cancel = 1 cancel = 1
closeMidi()
#GUI Main #GUI Main
buttonsize_x = 7 buttonsize_x = 7