added tap tempo input for fixed length mode

This commit is contained in:
langolierz
2018-05-03 05:17:36 +00:00
parent c15ec1247c
commit cfad0dc7f8
10 changed files with 97 additions and 44 deletions

View File

@@ -1,4 +1,5 @@
import subprocess
import data_centre.length_setter as length_setter
class Actions(object):
def __init__(self, tk, message_handler, data, video_driver, capture, display):
@@ -28,10 +29,11 @@ class Actions(object):
def enter_on_settings_selection(self):
is_setting, setting = self.display.settings_menu.enter_on_setting_selection()
if is_setting:
if setting['value'] is None:
getattr(self, setting['action'])()
else:
getattr(self, setting['action'])(setting['value'])
if setting['action']:
if setting['value'] is None:
getattr(self, setting['action'])()
else:
getattr(self, setting['action'])(setting['value'])
def clear_all_slots(self):
self.data.clear_all_slots()
@@ -305,8 +307,21 @@ class Actions(object):
self.toggle_x_autorepeat()
self.tk.destroy()
def set_fixed_length(self, value):
self.data.control_mode = 'LENGTH_SET'
self.message_handler.set_message('INFO', 'tap: ■ ; < > : back')
self.fixed_length_setter = length_setter.FixedLengthSetter(self.data)
def return_to_default_control_mode(self):
if self.data.control_mode == 'LENGTH_SET':
pass
self.data.control_mode = 'NAV_SETTINGS'
def record_fixed_length(self):
if self.fixed_length_setter:
self.fixed_length_setter.record_input()
self.display.settings_menu.generate_settings_list()

View File

@@ -140,6 +140,8 @@ class Data(object):
use_rand_start = self.settings['sampler']['RAND_START_MODE']['value'] == 'on'
use_fixed_length = self.settings['sampler']['FIXED_LENGTH_MODE']['value'] == 'on'
fixed_length_value = self.settings['sampler']['FIXED_LENGTH']['value']
fixed_length_multiply = self.settings['sampler']['FIXED_LENGTH_MULTIPLY']['value']
total_fixed_length = fixed_length_value * fixed_length_multiply
if start == -1:
start = 0
if end == -1:
@@ -148,12 +150,12 @@ class Data(object):
new_start = start
if use_fixed_length and use_rand_start:
max_increase = int(max(end - start - max(fixed_length_value, 4),0))
max_increase = int(max(end - start - max(total_fixed_length, 4),0))
random_increase = randint(0,max_increase)
new_start = start + random_increase
new_end = min(new_start + fixed_length_value, end)
new_end = min(new_start + total_fixed_length, end)
elif use_fixed_length and not use_rand_start:
new_end = min(new_start + fixed_length_value, end)
new_end = min(new_start + total_fixed_length, end)
elif not use_fixed_length and use_rand_start:
max_increase = int(max(end - start - 4,0))
random_increase = randint(0,max_increase)

View File

@@ -40,35 +40,35 @@
"rate": 1,
"start": -1
},
{
"end": 591.0,
"length": 804.245,
"location": "/media/pi/5EB5-664C/recur test videos/long_spinning.mp4",
"name": "long_spinning.mp4",
"rate": 1,
"start": 568.78
},
{
"end": -1,
"length": 7.4,
"location": "/home/pi/Videos/recordings/rec-2018-05-03-0.mp4",
"name": "rec-2018-05-03-0.mp4",
"length": -1,
"location": "",
"name": "",
"rate": 1,
"start": -1
},
{
"end": -1,
"length": 2.32,
"location": "/home/pi/Videos/recordings/rec-2018-05-03-1.mp4",
"name": "rec-2018-05-03-1.mp4",
"length": -1,
"location": "",
"name": "",
"rate": 1,
"start": -1
},
{
"end": -1,
"length": 3.36,
"location": "/home/pi/Videos/recordings/rec-2018-05-03-2.mp4",
"name": "rec-2018-05-03-2.mp4",
"length": -1,
"location": "",
"name": "",
"rate": 1,
"start": -1
},
{
"end": -1,
"length": -1,
"location": "",
"name": "",
"rate": 1,
"start": -1
},

View File

@@ -2,17 +2,20 @@
"a": {
"NAV_BROWSER": ["move_browser_selection_up"],
"PLAYER": ["seek_back_on_player"],
"NAV_SETTINGS": ["move_settings_selection_up"]
"NAV_SETTINGS": ["move_settings_selection_up"],
"LENGTH_SET": ["return_to_default_control_mode"]
},
"b": {
"NAV_BROWSER": ["move_browser_selection_down"],
"PLAYER": ["seek_forward_on_player"],
"NAV_SETTINGS": ["move_settings_selection_down"]
"NAV_SETTINGS": ["move_settings_selection_down"],
"LENGTH_SET": ["return_to_default_control_mode"]
},
"c": {
"NAV_BROWSER": ["enter_on_browser_selection"],
"PLAYER": ["toggle_action_on_player","toggle_show_on_player"],
"NAV_SETTINGS": ["enter_on_settings_selection"]
"NAV_SETTINGS": ["enter_on_settings_selection"],
"LENGTH_SET": ["record_fixed_length"]
},
"d": {
"DEFAULT": ["switch_to_next_player", "toggle_player_mode"]

View File

@@ -1 +1 @@
"0-1"
"0-2"

View File

@@ -113,7 +113,7 @@
"FIXED_LENGTH": {
"action": "set_fixed_length",
"options": [],
"value": 5
"value": 1.18
},
"FIXED_LENGTH_MODE": {
"action": "update_video_settings",
@@ -121,7 +121,18 @@
"on",
"off"
],
"value": "off"
"value": "on"
},
"FIXED_LENGTH_MULTIPLY": {
"action": null,
"options": [
1,
2,
4,
8,
16
],
"value": 4
},
"FUNC_GATED": {
"action": null,
@@ -138,7 +149,7 @@
"random",
"consecutive"
],
"value": "now"
"value": "random"
},
"ON_ACTION": {
"action": "update_video_settings",

View File

@@ -0,0 +1,22 @@
import datetime
class FixedLengthSetter(object):
DELTA_NUMBER = 2
def __init__(self, data):
self.data = data
self.last_time = None
self.list_of_deltas = []
def record_input(self):
if self.last_time == None:
self.last_time = datetime.datetime.now()
else:
now_time = datetime.datetime.now()
self.list_of_deltas.append(now_time - self.last_time)
self.last_time = now_time
if len(self.list_of_deltas) > self.DELTA_NUMBER:
average_delta = sum(self.list_of_deltas[-self.DELTA_NUMBER+1:], datetime.timedelta(0))/float(self.DELTA_NUMBER)
average_seconds = round(average_delta.total_seconds(), 2)
self.data.update_setting_value('sampler', 'FIXED_LENGTH', average_seconds)

View File

@@ -0,0 +1,4 @@
class FixedLengthSet(object):

View File

@@ -81,21 +81,19 @@ class Display(object):
bank_data = self.data.bank_data[self.data.bank_number]
self.display_text.insert(END, '------------------ <SAMPLER> ------------------ \n')
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29)
self.display_text.insert(END, '{:^6} {:<16} {:<4} {:<4} {:<4} \n'.format(
self.display_text.insert(END, '{:>6} {:<20} {:>6} {:<5} {:<5} \n'.format(
'{}-slot'.format(self.data.bank_number), 'name', 'length', 'start', 'end'))
for index, slot in enumerate(bank_data):
name_without_extension = slot['name'].rsplit('.',1)[0]
self.display_text.insert(END, '{:^4} {:<18} {:<4} {:<4} {:<4} \n'.format(
index, name_without_extension[0:22], self.format_time_value(slot['length']),
self.display_text.insert(END, '{:^6} {:<20} {:^6} {:>5} {:<5} \n'.format(
index, name_without_extension[0:20], self.format_time_value(slot['length']),
self.format_time_value(slot['start']), self.format_time_value(slot['end'])))
if self.data.is_this_path_broken(slot['location']):
self.display_text.tag_add("BROKEN_PATH", self.ROW_OFFSET + index,
self.ROW_OFFSET + self.SELECTOR_WIDTH + index)
current_bank , current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
if current_bank is self.data.bank_number:
self.selected_list_index = current_slot
else:
self.selected_list_index = 0
self._highlight_this_row(current_slot)
def _load_browser(self):
browser_list = self.browser_menu.menu_list
@@ -110,7 +108,7 @@ class Display(object):
break
if index >= self.browser_menu.top_menu_index:
path = browser_list[index]
self.display_text.insert(END, '{:40} {:5} \n'.format(path['name'][0:35], path['slot']))
self.display_text.insert(END, '{:40} {:5} \n'.format(path['name'][0:38], path['slot']))
number_of_lines_displayed = number_of_lines_displayed + 1
for index in range(self.MENU_HEIGHT - number_of_browser_items):
@@ -130,7 +128,7 @@ class Display(object):
break
if index >= self.settings_menu.top_menu_index:
setting = settings_list[index]
self.display_text.insert(END, '{:<23} {:<22} \n'.format(setting['name'], setting['value']))
self.display_text.insert(END, '{:<23} {:<22} \n'.format(setting['name'][0:22], setting['value']))
line_count = line_count + 1
for index in range(self.MENU_HEIGHT - number_of_settings_items):
@@ -140,7 +138,7 @@ class Display(object):
def _load_message(self):
if self.message_handler.current_message[1]:
self.display_text.insert(END, '{:5} {:38}'.format(
self.display_text.insert(END, '{:5} {:42} \n'.format(
self.message_handler.current_message[0], self.message_handler.current_message[1][0:38]))
self.display_text.tag_add('{}_MESSAGE'.format(
self.message_handler.current_message[0]), 16.0,16.0 + self.SELECTOR_WIDTH)
@@ -149,10 +147,10 @@ class Display(object):
message_length = 4000
self.tk.after(message_length, self.message_handler.clear_message)
elif self.data.function_on:
self.display_text.insert(END, '{:^45}'.format('< FUNCTION KEY ON >'))
self.display_text.insert(END, '{:^47} \n'.format('< FUNCTION KEY ON >'))
self.display_text.tag_add('FUNCTION', 16.0,16.0 + self.SELECTOR_WIDTH)
else:
self.display_text.insert(END, '{:8} {:<10}'.format('CONTROL:', self.data.control_mode))
self.display_text.insert(END, '{:8} {:<10} \n'.format('CONTROL:', self.data.control_mode))
self.display_text.tag_add('TITLE', 16.0,16.0 + self.SELECTOR_WIDTH)
def _highlight_this_row(self, row):

View File

@@ -1,6 +1,4 @@
import string
import datetime
import traceback
import sys
class NumpadInput(object):