summaryrefslogtreecommitdiff
path: root/buttons.py
diff options
context:
space:
mode:
authorsbahling <sbahling@mudgum.net>2018-10-26 14:23:08 +0200
committersbahling <sbahling@mudgum.net>2018-10-26 14:23:08 +0200
commit1d1b23e5154e093a3e3e3e40b05946ab06c9738c (patch)
treea57773bf632c21cecc6427619ec23fd8c88d8b5d /buttons.py
parent38c4e8310ef6bde30d3628ee93103c631caed47b (diff)
downloadtascam-fw-osc-1d1b23e5154e093a3e3e3e40b05946ab06c9738c.tar.gz
tascam-fw-osc-1d1b23e5154e093a3e3e3e40b05946ab06c9738c.tar.xz
tascam-fw-osc-1d1b23e5154e093a3e3e3e40b05946ab06c9738c.zip
Create initial package setup with setuptools
Diffstat (limited to 'buttons.py')
-rw-r--r--buttons.py252
1 files changed, 0 insertions, 252 deletions
diff --git a/buttons.py b/buttons.py
deleted file mode 100644
index f914435..0000000
--- a/buttons.py
+++ /dev/null
@@ -1,252 +0,0 @@
-#!/usr/bin/env python3
-"""
- Open Sound Control send/recieve daemon for Tascam Firewire control surface
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- :copyright: Copyright (c) 2018 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
-"""
-
-import re
-import pyautogui
-import osc
-
-
-keymap = {'CTRL': 'ctrl',
- 'ALT': 'alt',
- 'SHIFT': 'shift',
- }
-
-
-osc_addrs = {'STOP': '/transport_stop',
- 'PLAY': '/transport_play',
- 'F.FWD': '/ffwd',
- 'REW': '/rewind',
- 'REC': '/rec_enable_toggle',
- }
-
-re_strip_num = re.compile('.*([1-9])')
-
-current_bank = 1
-more_banks_up = False
-more_banks_down = False
-
-
-class Button():
- def __init__(self, console, name):
- self.name = name
- self.state = 0
- self.console = console
-
- def press(self):
- self.state = 1
- print('%s pressed' % self.name)
-
- def release(self):
- self.state = 0
- print('%s released' % self.name)
-
- @property
- def pressed(self):
- if self.state:
- return True
- return False
-
-
-class EncoderButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self):
-
- encoder_mode = self.console.state.get('encoder_mode', None)
- print(encoder_mode)
- if encoder_mode == self.name:
- return
-
- self.state = 1
- if encoder_mode:
- self.console.unit.leds.turn_off(encoder_mode)
- self.console.state[encoder_mode] = 0
- self.console.unit.leds.turn_on(self.name)
- self.console.state['encoder_mode'] = self.name
- super().press()
-
-
-class StripSelButton(Button):
- def __init__(self, console, name, strip):
- super().__init__(console, name)
- self.strip = strip
- self.strip.select_button = self
-
- def press(self):
-
- strip = self.strip
- print('handle_strip_sel', strip)
- recenable = self.console.buttons.get('REC ENABLE', None)
- if recenable.pressed:
- if strip.rec:
- osc.client.send_message('/strip/recenable', (strip.num, 0))
- else:
- osc.client.send_message('/strip/recenable', (strip.num, 1))
- super().press()
-
-
-class StripMuteButton(Button):
- def __init__(self, console, name, strip):
- super().__init__(console, name)
- self.strip = strip
- self.strip.mute_button = self
-
- def press(self):
-
- strip = self.strip
- if strip.mute:
- strip.mute = False
- osc.client.send_message('/strip/mute', (strip.num, 0))
- else:
- strip.mute = True
- osc.client.send_message('/strip/mute', (strip.num, 1))
- super().press()
-
-
-class StripSoloButton(Button):
- def __init__(self, console, name, strip):
- super().__init__(console, name)
- self.strip = strip
- self.strip.solo_button = self
-
- def press(self):
-
- strip = self.strip
- if strip.solo:
- strip.solo = False
- osc.client.send_message('/strip/solo', (strip.num, 0))
- else:
- strip.solo = True
- osc.client.send_message('/strip/solo', (strip.num, 1))
- super().press()
-
-
-class ArrowButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self):
- key = keymap.get(self.name.lower(), self.name.lower())
- pyautogui.press(key)
-
-
-class ModButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def mod_button_press(self):
- key = keymap.get(self.name, None)
- if key is None:
- return
-
- pyautogui.keyDown(key)
- super().press()
-
- def release(self):
- key = keymap.get(self.name, None)
- if key is None:
- return
-
- pyautogui.keyUp(key)
- super().release()
-
-
-class ComputerButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self):
- osc.client.send_message('/set_surface', (8, 7, 19, 1, 8, 11))
- super().press()
-
-
-class ClrSoloButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self):
- osc.client.send_message('/cancel_all_solos', 1)
- super().press()
-
-
-class LoopButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self, *args):
- if self.console.state.get('loop', 0):
- print('******* loop off')
- osc.client.send_message('/loop_toggle', 0)
- else:
- print('******* loop on')
- osc.client.send_message('/loop_toggle', 1)
- super().press()
-
-
-class TransportButton(Button):
- def __init__(self, console, name):
- super().__init__(console, name)
-
- def press(self):
- addr = osc_addrs.get(self.name, None)
- if addr:
- osc.client.send_message(addr, 1)
- super().press()
-
-
-class BankSwitchButton(Button):
- def __init__(self, console, name, direction):
- super().__init__(console, name)
- self.direction = direction
-
- def press(self):
-
- direction = self.direction
- print(direction, more_banks_up, more_banks_down)
- if direction > 0 and more_banks_up:
- print('calling /bank_up 1')
- osc.client.send_message('/bank_up', 1)
- elif direction < 0 and more_banks_down:
- print('calling /bank_down 1')
- osc.client.send_message('/bank_down', 1)
- super().press()
-
-
-class NudgeButton(Button):
- def __init__(self, console, name, direction):
- super().__init__(console, name)
- self.direction = direction
-
- def nudge_press(self):
- direction = self.direction
- print(direction)
- if direction > 0:
- osc.client.send_message('/access_action',
- 'Common/nudge-next-forward')
- else:
- osc.client.send_message('/access_action',
- 'Common/nudge-next-backward')
- super().press()
-
-
-NULLBUTTON = Button(None, None)