-
Notifications
You must be signed in to change notification settings - Fork 6
/
hinawa-tascam-fireone-cli
executable file
·133 lines (118 loc) · 4.64 KB
/
hinawa-tascam-fireone-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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/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.tascam_fireone import TascamFireone
# Helper functions
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(' Control surface:')
print(' display-mode: {0}'.format(unit.get_display_mode()))
print(' control-mode: {0}'.format(unit.get_control_mode()))
print(' input-mode: {0}'.format(unit.get_input_mode()))
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']))
print('TASCAM firmware information:')
print(' version: {0}'.format(unit.get_firmware_version()))
return True
def handle_display_mode(unit, args):
ops = ('set', 'get')
modes = unit.get_display_mode_labels()
if len(args) > 0 and args[0] in ops:
op = args[0]
if op == ops[0] and len(args) == 2 and args[1] in modes:
mode = args[1]
unit.set_display_mode(mode)
else:
print(unit.get_display_mode())
return True
print('Arguments for display-mode command:')
print(' display-mode OPERATION [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' MODE: {0}'.format(', '.join(modes)))
return False
def handle_control_mode(unit, args):
ops = ('set', 'get')
modes = unit.get_control_mode_labels()
if len(args) > 0 and args[0] in ops:
op = args[0]
if op == ops[0] and len(args) == 2 and args[1] in modes:
mode = args[1]
unit.set_control_mode(mode)
else:
print(unit.get_control_mode())
return True
print('Arguments for control-mode command:')
print(' control-mode OPERATION [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' MODE: {0}'.format(', '.join(modes)))
return False
def handle_input_mode(unit, args):
ops = ('set', 'get')
modes = unit.get_input_mode_labels()
if len(args) > 0 and args[0] in ops:
op = args[0]
if op == ops[0] and len(args) == 2 and args[1] in modes:
mode = args[1]
unit.set_input_mode(mode)
else:
print(unit.get_input_mode())
return True
print('Arguments for input-mode command:')
print(' input-mode OPERATION [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' MODE: {0}'.format(', '.join(modes)))
return False
def handle_sampling_rate(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:
if unit.get_property('is-locked'):
print('Packet is-locked started.')
return False
rate = int(args[1])
for fmt in unit.supported_stream_formats['playback']:
if fmt['sampling-rate'] == rate:
playback = fmt
break
else:
print('Invalid argument for sampling rate')
return False
for fmt in unit.supported_stream_formats['capture']:
if fmt['sampling-rate'] == rate:
capture = fmt
break
else:
print('Invalid argument for sampling rate')
return False
unit.set_stream_formats(playback, capture)
else:
fmts = unit.get_current_stream_formats()
print(fmts['playback']['sampling-rate'])
return True
print('Arguments for sampling-rate command:')
print(' input-mode OPERATION [RATE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
fmts = unit.supported_stream_formats['playback']
rates = [str(fmt['sampling-rate']) for fmt in fmts]
print(' MODE: {0}'.format(', '.join(rates)))
return True
cmds = {
'current-status': handle_current_status,
'display-mode': handle_display_mode,
'control-mode': handle_control_mode,
'input-mode': handle_input_mode,
'sampling-rate': handle_sampling_rate,
}
fullpath = CliKit.seek_snd_unit_path()
if fullpath:
with TascamFireone(fullpath) as unit:
CliKit.dispatch_command(unit, cmds)