I fixed the bytes-like error in shellCall()
is by sending commands in str (not bytes) object and specifying encoding using locale.getpreferredencoding()
. Please see following pull request for detail.
https://github.com/psychopy/psychopy/pull/1636
The next issue is about pyo. Recent versions of pyo have UnicodeDecodeError in Python 2.7.
Unicode{En,De}codeErrors in fresh install #1525
I had expected that this issue would be resolved in Python 3, but it wasn’t. In Python3, pa_get_devices_infos()
crashes with following error on my Japanese Windows10 PC.
Pyo’s version is 0.8.8.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 10: invalid start byte
The above exception was the direct cause of the following exception:
SystemError: <class 'UnicodeDecodeError'> returned a result with an error set
The above exception was the direct cause of the following exception:
SystemError: <class 'UnicodeDecodeError'> returned a result with an error set
The above exception was the direct cause of the following exception:
SystemError: <class 'UnicodeDecodeError'> returned a result with an error set
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: <built-in function pa_get_devices_infos> returned a result with an error set
On the same machine, pa_get_devices_infos()
returns following result in Python 2. Again, pyo is 0.8.8. There seems to be no problem, but name of device 0, 1, 3, 4 are corrupted (shown as u'???'
).
({
10: {'host api index': 4, 'latency': 0.009999999776482582, 'default sr': 44100, 'name': u'\u30b9\u30c6\u30ec\u30aa \u30df\u30ad\u30b5\u30fc (Realtek HD Audio Stereo input)'},
11: {'host api index': 4, 'latency': 0.009999999776482582, 'default sr': 44100, 'name': u'\u30de\u30a4\u30af (Realtek HD Audio Mic input)'},
12: {'host api index': 4, 'latency': 0.009999999776482582, 'default sr': 44100, 'name': u'\u30e9\u30a4\u30f3\u5165\u529b (Realtek HD Audio Line input)'},
6: {'host api index': 2, 'latency': 0.01160997711122036, 'default sr': 44100, 'name': u'ASIO4ALL v2'}
}, {
0: {'host api index': 0, 'latency': 0.09000000357627869, 'default sr': 44100, 'name': u'???'},
1: {'host api index': 0, 'latency': 0.09000000357627869, 'default sr': 44100, 'name': u'???'},
2: {'host api index': 0, 'latency': 0.09000000357627869, 'default sr': 44100, 'name': u'Realtek Digital Output (Realtek'},
3: {'host api index': 1, 'latency': 0.11999999731779099, 'default sr': 44100, 'name': u'???'},
4: {'host api index': 1, 'latency': 0.11999999731779099, 'default sr': 44100, 'name': u'???'},
5: {'host api index': 1, 'latency': 0.11999999731779099, 'default sr': 44100, 'name': u'Realtek Digital Output (Realtek High Definition Audio)'}, 6: {'host api index': 2, 'latency': 0.01160997711122036, 'default sr': 44100, 'name': u'ASIO4ALL v2'},
7: {'host api index': 3, 'latency': 0.003000000026077032, 'default sr': 48000, 'name': u'Realtek Digital Output (Realtek High Definition Audio)'},
8: {'host api index': 3, 'latency': 0.003000000026077032, 'default sr': 48000, 'name': u'\u30b9\u30d4\u30fc\u30ab\u30fc (Realtek High Definition Audio)'},
9: {'host api index': 4, 'latency': 0.009999999776482582, 'default sr': 44100, 'name': u'Speakers (Realtek HD Audio output)'},
13: {'host api index': 4, 'latency': 0.009999999776482582, 'default sr': 44100, 'name': u'SPDIF Out (Realtek HDA SPDIF Out)'}
})
I tried pa_get_input_devices()
, pa_get_output_devices()
on the same machine. The result was that pa_get_input_devices()
shows UnicodeDecodeError in Python2, while
pa_get_output_devices()
shows UnicodeDecodeError in Python3 ! I suspect that the name of some devices are encoded in cp932, while the other are encoded in utf-8
.
pa_list_devices()
works better. In Python 3, all devices are correctly shown
.
AUDIO devices:
0: OUT, name: Microsoft サウンド マッパー - Output, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
1: OUT, name: スピーカー (Realtek High Defini, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
2: OUT, name: Realtek Digital Output (Realtek, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
3: OUT, name: プライマリ サウンド ドライバー, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
4: OUT, name: スピーカー (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
5: OUT, name: Realtek Digital Output (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
6: IN, name: ASIO4ALL v2, host api index: 2, default sr: 44100 Hz, latency: 0.011610 s
6: OUT, name: ASIO4ALL v2, host api index: 2, default sr: 44100 Hz, latency: 0.011610 s
7: OUT, name: Realtek Digital Output (Realtek High Definition Audio), host api index: 3, default sr: 48000 Hz, latency: 0.003000 s
8: OUT, name: スピーカー (Realtek High Definition Audio), host api index: 3, default sr: 48000 Hz, latency: 0.003000 s
9: OUT, name: Speakers (Realtek HD Audio output), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
10: IN, name: ステレオ ミキサー (Realtek HD Audio Stereo input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
11: IN, name: マイク (Realtek HD Audio Mic input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
12: IN, name: ライン入力 (Realtek HD Audio Line input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
13: OUT, name: SPDIF Out (Realtek HDA SPDIF Out), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
In python 2, pa_list_devices()
runs without UnicodeDecodeError though name of some devices are corrupted (i.e., 8, 10, 11, 12).
AUDIO devices:
0: OUT, name: Microsoft サウンド マッパー - Output, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
1: OUT, name: スピーカー (Realtek High Defini, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
2: OUT, name: Realtek Digital Output (Realtek, host api index: 0, default sr: 44100 Hz, latency: 0.090000 s
3: OUT, name: プライマリ サウンド ドライバー, host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
4: OUT, name: スピーカー (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
5: OUT, name: Realtek Digital Output (Realtek High Definition Audio), host api index: 1, default sr: 44100 Hz, latency: 0.120000 s
6: IN, name: ASIO4ALL v2, host api index: 2, default sr: 44100 Hz, latency: 0.011610 s
6: OUT, name: ASIO4ALL v2, host api index: 2, default sr: 44100 Hz, latency: 0.011610 s
7: OUT, name: Realtek Digital Output (Realtek High Definition Audio), host api index: 3, default sr: 48000 Hz, latency: 0.003000 s
8: OUT, name: 繧ケ繝斐・繧ォ繝シ (Realtek High Definition Audio), host api index: 3, default sr: 48000 Hz, latency: 0.003000 s
9: OUT, name: Speakers (Realtek HD Audio output), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
10: IN, name: 繧ケ繝・Ξ繧ェ 繝溘く繧オ繝シ (Realtek HD Audio Stereo input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
11: IN, name: 繝槭う繧ッ (Realtek HD Audio Mic input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
12: IN, name: 繝ゥ繧、繝ウ蜈・蜉・(Realtek HD Audio Line input), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
13: OUT, name: SPDIF Out (Realtek HDA SPDIF Out), host api index: 4, default sr: 44100 Hz, latency: 0.010000 s
pa_list_devices()
seems to be the most promising among these functions, but the output cannot be obtained as a return value.
I read pyo’s source code and noticed that pa_get_devices_infos()
simply calls DLL function in portaudio.dll. I think that we can get information directly from DLL function by using ctypes. I’ll give it a try.