From d0c4124092388851026681159a76301452917f62 Mon Sep 17 00:00:00 2001 From: talksik Date: Thu, 27 Apr 2023 11:44:04 -0700 Subject: [PATCH] cleanup of code --- mic_hat_examples/recording_examples/get_device_index.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mic_hat_examples/recording_examples/get_device_index.py b/mic_hat_examples/recording_examples/get_device_index.py index d74eed4..71eb9e9 100644 --- a/mic_hat_examples/recording_examples/get_device_index.py +++ b/mic_hat_examples/recording_examples/get_device_index.py @@ -5,7 +5,8 @@ info = p.get_host_api_info_by_index(0) numdevices = info.get('deviceCount') for i in range(0, numdevices): - 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')) + currDeviceInfo = p.get_device_info_by_host_api_device_index(0, i) + if (currDeviceInfo.get('maxInputChannels')) > 0: + print("Input Device id ", i, " - ", currDeviceInfo.get('name')) else: - print("Output Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')) + print("Output Device id ", i, " - ", currDeviceInfo.get('name'))