From 20dbeb2f38684c65ff0a4b99012c161295708e88 Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 11:01:49 +0200 Subject: NeoRAT --- domestic/utility/get_io_channels.py | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 domestic/utility/get_io_channels.py (limited to 'domestic/utility/get_io_channels.py') diff --git a/domestic/utility/get_io_channels.py b/domestic/utility/get_io_channels.py new file mode 100644 index 0000000..c5fa5e2 --- /dev/null +++ b/domestic/utility/get_io_channels.py @@ -0,0 +1,43 @@ +import pyaudio + +from domestic.global_state import * + + +def get_io_channels(): + try: + p = pyaudio.PyAudio() + CHUNK = 81920 + FORMAT = pyaudio.paInt16 + RATE = 44100 + except: + pass + else: + try: + stream = p.open(format=FORMAT, channels=2, rate=RATE, input=True, output=False, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + state['settings']['io-channels'][0] = '2' + except: + try: + stream = p.open(format=FORMAT, channels=1, rate=RATE, input=True, output=False, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + state['settings']['io-channels'][0] = '1' + except: + pass + + try: + stream = p.open(format=FORMAT, channels=2, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + state['settings']['io-channels'][1] = '2' + except: + try: + stream = p.open(format=FORMAT, channels=1, rate=RATE, input=False, output=True, frames_per_buffer=CHUNK) + stream.stop_stream() + stream.close() + state['settings']['io-channels'][1] = '1' + except: + pass + + p.terminate() \ No newline at end of file -- cgit v1.2.3