Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing exception if index of selected microphone has changed #79

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,15 @@ def setDevice(self, device_id):
# set device to stream from by the id of the device
if not device_id in range(0,self.numdevices):
raise ValueError("No device with id {}".format(device_id))
self.device_id = self.devices[device_id]["index"]
self.device_name = self.devices[device_id]["name"]
self.device_rate = int(self.devices[device_id]["defaultSampleRate"])

device_pos = device_id
for device in self.devices:
if device["index"] == device_id:
device_pos = self.devices.index(device)

self.device_id = self.devices[device_pos]["index"]
self.device_name = self.devices[device_pos]["name"]
self.device_rate = int(self.devices[device_pos]["defaultSampleRate"])
self.frames_per_buffer = self.device_rate // config.settings["configuration"]["FPS"]

config.settings["mic_config"]["MIC_ID"] = self.device_id
Expand Down Expand Up @@ -2050,4 +2056,4 @@ def microphone_update(audio_samples):
save_config_dicts()
colour_manager.saveColours()
colour_manager.saveGradients()
py_audio.terminate()
py_audio.terminate()