Skip to content

Commit

Permalink
input and output selection support
Browse files Browse the repository at this point in the history
  • Loading branch information
Novecento99 committed Jul 30, 2024
1 parent a18f9c3 commit d256ae1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/soundMonitorGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont

#
# __o
# _ \<_
# (_)/(_)
Expand All @@ -21,6 +22,8 @@
# GUI aestetich improvement
# graphical trigger feedback
# bug when closing application
# max value
# automatic gain
#

class micMonitorWindow(QMainWindow):
Expand All @@ -35,6 +38,7 @@ def __init__(self):
self.inputDevices = [device for device in sd.query_devices() if (device["max_input_channels"] > 0)]
self.outputDevices = [device for device in sd.query_devices() if (device["max_output_channels"] > 0)]
self.triggerCheck = QCheckBox("enable trigger")
self.triggerCheck.setChecked(True)
self.multiplier = QLineEdit("100")
self.volumeBar = QProgressBar()
self.feedbackLabel = QLabel()
Expand All @@ -48,8 +52,9 @@ def __init__(self):


self.outputSelector = QComboBox()
self.outputSelector.addItems(([device["name"] for device in self.outputDevices]))
self.outputSelector.addItems([(str(device["index"]).format("%02d",7)+" "+device["name"]) for device in self.outputDevices])
self.outputSelector.setCurrentText(sd.query_devices()[4]["name"])
self.outputSelector.currentIndexChanged.connect(self.restartOutput)
self.debugButton = QPushButton("debug")
self.options = QCheckBox("show options")

Expand Down Expand Up @@ -94,16 +99,25 @@ def __init__(self):
self.stream = sd.InputStream(callback=self.ListenToMic)
self.restartInput()


def restartInput(self):
if self.stream.active:
self.stream.close()
try:
sd.default.device = int(self.inputSelector.currentText()[0:2])
sd.default.device = [int(self.inputSelector.currentText()[0:2]),sd.default.device[1]]
self.stream = sd.InputStream(callback=self.ListenToMic)
self.stream.start()
self.feedbackLabel.setText("Started")
except KeyError as e:
self.feedbackLabel.setText("Not valid")
except Exception as e:
self.feedbackLabel.setText(e)
print(e)

def restartOutput(self):
try:
sd.default.device = [sd.default.device[0],int(self.outputSelector.currentText()[0:2])]
self.PlayTone()
except Exception as e:
self.feedbackLabel.setText(e)
print(e)

def Debug(self):
Expand Down

0 comments on commit d256ae1

Please sign in to comment.