1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()
|