-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhinawa-edirol-fa-cli
executable file
·70 lines (61 loc) · 2.48 KB
/
hinawa-edirol-fa-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
#!/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.bebob.edirol_fa import EdirolFaUnit
def handle_mixer_input_gain(unit, args):
chs = ('1', '2')
ops = ('set', 'get')
targets = unit.get_mixer_input_labels()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and args[1] in chs:
ch = int(args[1])
if len(args) >= 3 and args[2] in ops:
op = args[2]
if op == 'set' and len(args) >= 4:
db = float(args[3])
unit.set_mixer_input_gain(target, ch, db)
return True
elif op == 'get':
print(unit.get_mixer_input_gain(target, ch))
return True
print('Arguments for mixer-input-gain command:')
print(' mixer-input-gain TARGET CH OP [dB]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' dB: [-128.00..128.00] if OP=set')
return False
def handle_mixer_input_balance(unit, args):
chs = ('1', '2')
ops = ('set', 'get')
targets = unit.get_mixer_input_labels()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and args[1] in chs:
ch = int(args[1])
if len(args) >= 3 and args[2] in ops:
op = args[2]
if len(args) >= 4 and op == 'set':
balance = float(args[3])
unit.set_mixer_input_balance(target, ch, balance)
return True
elif op == 'get':
print(unit.get_mixer_input_balance(target, ch))
return True
print('Arguments for mixer-input-balance command')
print(' mixer-input-balance TARGET CH OP [BALANCE]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' BALANCE:[-128.0..128.0] (left-right) if OP=set')
return False
cmds = {
'mixer-input-gain': handle_mixer_input_gain,
'mixer-input-balance': handle_mixer_input_balance,
}
fullpath = CliKit.seek_snd_unit_path()
if fullpath:
with EdirolFaUnit(fullpath) as unit:
CliKit.dispatch_command(unit, cmds)