-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhinawa-griffin-firewave-cli
executable file
·83 lines (73 loc) · 2.9 KB
/
hinawa-griffin-firewave-cli
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2018 Takashi Sakamoto
from hinawa_utils.misc.cli_kit import CliKit
from hinawa_utils.oxfw.oxfw_unit import OxfwUnit
from hinawa_utils.ta1394.audio import AvcAudio
def handle_current_status(unit, args):
print('Current status:')
print(' Packet Streaming:')
print(' running: {0}'.format(unit.get_property('is-locked')))
fmts = unit.get_current_stream_formats()
print(' sampling-rate: {0}'.format(fmts['playback']['sampling-rate']))
print('Volumes:')
for ch in range(1, 7):
data = AvcAudio.get_feature_volume_state(unit.fcp, 0, 'current', 2, ch)
db = AvcAudio.parse_data_to_db(data)
print(' {0}: {1}'.format(ch, db))
if AvcAudio.get_feature_mute_state(unit.fcp, 0, 'current', 1, 0):
mute = 'on'
else:
mute = 'off'
print(' mute: {0}'.format(mute))
print('ASIC information:')
print(' type: {0}'.format(unit.hw_info['asic-type']))
print(' ID: {0}'.format(unit.hw_info['asic-id']))
print(' firmware version: {0}'.format(unit.hw_info['firmware-version']))
return True
def handle_output_volume(unit, args):
ops = ('set', 'get')
if len(args) > 1 and args[0] in ops:
op = args[0]
ch = int(args[1])
if op == ops[0] and len(args) == 3:
db = float(args[2])
data = AvcAudio.build_data_from_db(db)
AvcAudio.set_feature_volume_state(unit.fcp, 0, 'current', 1, ch,
data)
else:
data = AvcAudio.get_feature_volume_state(unit.fcp, 0, 'current',
1, ch)
print(AvcAudio.parse_data_to_db(data))
return True
print('Arguments for output-volume command:')
print(' output-volume OPERATION CH [dB]')
print(' OP: [{0}]'.format('|'.join(ops)))
print(' CH: [0..6] (0 = all)')
print(' dB: [-128.0..128.0] if OP=set')
return False
def handle_ouptut_mute(unit, args):
ops = ('set', 'get')
if len(args) > 0 and args[0] in ops:
op = args[0]
if op == ops[0] and len(args) == 2:
mute = int(args[1])
AvcAudio.set_feature_mute_state(unit.fcp, 0, 'current', 1, 0, mute)
else:
print(AvcAudio.get_feature_mute_state(
unit.fcp, 0, 'current', 1, 0))
return True
print('Arguments for output-mute command:')
print(' output-mute OPERATION [MUTE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' MUTE: 0, 1')
return False
cmds = {
'current-status': handle_current_status,
'output-volume': handle_output_volume,
'output-mute': handle_ouptut_mute,
}
fullpath = CliKit.seek_snd_unit_path()
if fullpath:
with OxfwUnit(fullpath) as unit:
CliKit.dispatch_command(unit, cmds)