summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console.py88
-rwxr-xr-xtascam-fw-console55
2 files changed, 99 insertions, 44 deletions
diff --git a/console.py b/console.py
index 7d6650c..a8757c0 100644
--- a/console.py
+++ b/console.py
@@ -20,13 +20,11 @@
:license: GPL-2.0, see COPYING for details
"""
-import argparse
import string
import time
import threading
from pathlib import Path
-import osc
import strips
import fw_1884_buttons
@@ -34,6 +32,7 @@ import gi
gi.require_version('Hinawa', '2.0')
from gi.repository import Hinawa # noqa: E402
+from hinawa_utils.tscm.config_rom_parser import TscmConfigRomParser # noqa: E402 E501
from hinawa_utils.tscm.tscm_console_unit import TscmConsoleUnit # noqa: E402
@@ -86,13 +85,28 @@ class RunningStatusThread():
class Console():
- def __init__(self, card):
+ def __init__(self, card_id=None, guid=None):
+
+ fullpath = None
+ if guid:
+ fullpath = self._seek_snd_unit_from_guid(card_id)
+ elif card_id:
+ fullpath = '/dev/snd/hwC{0}D0'.format(card_id)
+ else:
+ try:
+ units = list_units()
+ if units:
+ model, fullpath, guid = units[0]
+ except Exception:
+ raise Exception('No Tascam FW Console unit found')
- fullpath = seek_snd_unit_path(card)
if fullpath:
self.unit = TscmConsoleUnit(fullpath)
+ model = self.unit.model_name
+ guid = self.unit.get_property('guid')
+ print('Found Tascam {0} unit with GUID: {1:016x}'.format(model, guid)) # noqa E501
else:
- exit()
+ raise Exception('No Tascam FW Console unit found')
self.state = {}
self.current_bank = 1
@@ -106,6 +120,20 @@ class Console():
self.status_thread = RunningStatusThread(self) # noqa F841
+ def _seek_snd_unit_from_guid(self, guid):
+ for fullpath in Path('/dev/snd').glob('hw*'):
+ fullpath = str(fullpath)
+ try:
+ unit = Hinawa.SndUnit()
+ unit.open(fullpath)
+ if unit.get_property('guid') == guid:
+ return fullpath
+ except Exception as e:
+ pass
+ finally:
+ del unit
+ return None
+
def init_buttons(self):
self.button_map = fw_1884_buttons.init_buttons(self)
for index, items in self.button_map.items():
@@ -292,49 +320,21 @@ def _check_hexadecimal(literal):
return True
-def _seek_snd_unit_from_guid(guid):
+def list_units():
+ units = []
for fullpath in Path('/dev/snd').glob('hw*'):
fullpath = str(fullpath)
+ unit = None
try:
unit = Hinawa.SndUnit()
unit.open(fullpath)
- if unit.get_property('guid') == guid:
- return fullpath
+ parser = TscmConfigRomParser()
+ info = parser.parse_rom(unit.get_config_rom())
+ model = info['model-name']
+ guid = unit.get_property('guid')
+ if model in ('FW-1082', 'FW-1884'):
+ units.append((model, fullpath, guid))
except Exception as e:
pass
- finally:
- del unit
- return None
-
-
-def seek_snd_unit_path(card_id):
- # Assume as sound card number if it's digit literal.
- if card_id.isdigit():
- return '/dev/snd/hwC{0}D0'.format(card_id)
- # Assume as GUID on IEEE 1394 bus if it's hexadecimal literal.
- elif _check_hexadecimal(card_id):
- return _seek_snd_unit_from_guid(int(card_id, base=16))
- return None
-
-
-if __name__ == "__main__":
-
- parser = argparse.ArgumentParser()
- parser.add_argument("--card", default="1",
- help="number of the ALSA sound card")
- parser.add_argument("--listen-ip", default="127.0.0.1",
- help="The ip to listen on")
- parser.add_argument("--listen-port", type=int, default=5005,
- help="The port to listen on")
- parser.add_argument("--ip", default="127.0.0.1",
- help="The ip of the OSC server")
- parser.add_argument("--port", type=int, default=3819,
- help="The port the OSC server is listening on")
- args = parser.parse_args()
-
- console = Console(args.card)
- osc.init_client(args.ip, args.port)
- osc.init_server(args.listen_ip, args.listen_port, console)
-
- print("Serving on {}".format(osc.server.server_address))
- osc.server.serve_forever()
+
+ return units
diff --git a/tascam-fw-console b/tascam-fw-console
new file mode 100755
index 0000000..21fdbd0
--- /dev/null
+++ b/tascam-fw-console
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+"""
+ Open Sound Control send/recieve daemon for Tascam Firewire control surface
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ :copyright: Copyright (c) 2012-2014 Scott Bahling
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2 as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program (see the file COPYING); if not, write to the
+ Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ :license: GPL-2.0, see COPYING for details
+
+Usage:
+ tascam-fw-osc [options]
+
+Options:
+ -h --help Show this screen.
+ -l --list List connected Tascam FW console units
+ -c CARD_NUM --card=CARD_NUM Number of the ALSA sound card
+ -d GUID --device=GUID GUID of the FW unit
+ -I IP --listen-ip=IP IP to listen on [default: 127.0.0.1]
+ -P PORT --listen-port=PORT Port to listen on [default: 5005]
+ -i IP --ip=IP IP to communicate to [default: 127.0.0.1]
+ -p PORT --port=PORT Port to communicate to [default: 3919]
+"""
+
+from docopt import docopt
+from console import Console, list_units
+import osc
+
+if __name__ == "__main__":
+
+ args = docopt(__doc__, version='0.1')
+
+ if args['--list']:
+ for model, fullpath, guid in list_units():
+ print('{0} path: {1} GUID: 0x{2:016x}'.format(model,
+ fullpath, guid))
+ exit()
+
+ console = Console(card_id=args['--card'], guid=args['--device'])
+ osc.init_client(args['--ip'], int(args['--port']))
+ osc.init_server(args['--listen-ip'], int(args['--listen-port']), console)
+
+ print("Serving on {}".format(osc.server.server_address))
+ osc.server.serve_forever()