detour almost working now

This commit is contained in:
langolierz
2019-07-01 19:34:14 +00:00
parent 03d9411edf
commit f41a6b570f
6 changed files with 142 additions and 15 deletions

View File

@@ -136,10 +136,11 @@ class Actions(object):
def cycle_display_mode(self): def cycle_display_mode(self):
display_modes = [["BROWSER",'NAV_BROWSER'],["SETTINGS",'NAV_SETTINGS'],[ "SAMPLER",'PLAYER']]
if self.data.settings['conjur']['VIDEO_BACKEND']['value'] == 'openframeworks': if self.data.settings['conjur']['VIDEO_BACKEND']['value'] == 'openframeworks':
display_modes = [["SETTINGS",'NAV_SETTINGS'],[ "SAMPLER",'PLAYER'],["BROWSER",'NAV_BROWSER'],["SHADERS",'NAV_SHADERS']] display_modes.append(["SHADERS",'NAV_SHADERS'])
else: if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
display_modes = [["BROWSER",'NAV_BROWSER'],["SETTINGS",'NAV_SETTINGS'],[ "SAMPLER",'PLAYER']] display_modes.append(["DETOUR",'NAV_DETOUR'])
current_mode_index = [index for index, i in enumerate(display_modes) if self.data.display_mode in i][0] current_mode_index = [index for index, i in enumerate(display_modes) if self.data.display_mode in i][0]
next_mode_index = (current_mode_index + 1) % len(display_modes) next_mode_index = (current_mode_index + 1) % len(display_modes)
@@ -287,6 +288,76 @@ class Actions(object):
self.data.detour_active = True self.data.detour_active = True
self.video_driver.osc_client.send_message("/detour/start", True) self.video_driver.osc_client.send_message("/detour/start", True)
def toggle_detour_play(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
is_playing = not self.data.detour_settings['is_playing']
self.data.detour_settings['is_playing'] = is_playing
self.video_driver.osc_client.send_message("/detour/is_playing", is_playing)
def toggle_detour_record(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
is_recording = not self.data.detour_settings['is_recording']
self.data.detour_settings['is_recording'] = is_recording
self.video_driver.osc_client.send_message("/detour/is_recording", is_recording)
def toggle_detour_record_loop(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
record_loop = not self.data.detour_settings['record_loop']
self.data.detour_settings['record_loop'] = record_loop
self.video_driver.osc_client.send_message("/detour/record_loop", record_loop)
def clear_this_detour(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
self.video_driver.osc_client.send_message("/detour/clear_this_detour", True)
def switch_to_detour_0(self):
self.switch_to_this_detour(0)
def switch_to_detour_1(self):
self.switch_to_this_detour(1)
def switch_to_detour_2(self):
self.switch_to_this_detour(2)
def switch_to_detour_3(self):
self.switch_to_this_detour(3)
def switch_to_this_detour(self, number):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
self.data.detour_settings['current_detour'] = number
self.video_driver.osc_client.send_message("/detour/switch_to_detour_number", number)
def set_detour_speed_position_continuous(self, amount):
self.video_driver.osc_client.send_message("/detour/set_speed_position", amount)
def set_detour_start_continuous(self, amount):
self.video_driver.osc_client.send_message("/detour/set_start", amount)
def set_detour_end_continuous(self, amount):
self.video_driver.osc_client.send_message("/detour/set_end", amount)
def set_detour_mix_continuous(self, amount):
self.video_driver.osc_client.send_message("/detour/set_mix", amount)
def receive_detour_info(self, unused_addr, position, start, end, size, speed, mix, memory_full):
self.data.detour_settings['detour_position'] = position
self.data.detour_settings['detour_start'] = start
self.data.detour_settings['detour_end'] = end
self.data.detour_settings['detour_size'] = size
self.data.detour_settings['detour_speed'] = speed
self.data.detour_settings['position_position'] = mix
self.data.detour_settings['memory_full'] = memory_full
print(position, start, end, size, speed, mix, memory_full)
def set_the_detour_mix_0(self):
self.set_detour_mix_continuous(0)
def set_the_detour_mix_1(self):
self.set_detour_mix_continuous(1)
def set_the_camera_colour_u_continuous(self, amount): def set_the_camera_colour_u_continuous(self, amount):
self.capture.set_colour(amount*255, None) self.capture.set_colour(amount*255, None)
@@ -546,6 +617,7 @@ class Actions(object):
this_dispatcher.map("/player/a/status", self.video_driver.receive_status, "a.a") this_dispatcher.map("/player/a/status", self.video_driver.receive_status, "a.a")
this_dispatcher.map("/player/b/status", self.video_driver.receive_status, "b.b") this_dispatcher.map("/player/b/status", self.video_driver.receive_status, "b.b")
this_dispatcher.map("/player/c/status", self.video_driver.receive_status, "c.c") this_dispatcher.map("/player/c/status", self.video_driver.receive_status, "c.c")
this_dispatcher.map("/detour/detour_info", self.receive_detour_info)
this_dispatcher.map("/shutdown", self.exit_osc_server) this_dispatcher.map("/shutdown", self.exit_osc_server)
#this_dispatcher.map("/player/a/status", self.set_status) #this_dispatcher.map("/player/a/status", self.set_status)

View File

@@ -1,6 +1,7 @@
import json import json
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import os import os
import collections
from random import randint from random import randint
import inspect import inspect
from itertools import cycle from itertools import cycle
@@ -42,6 +43,7 @@ class Data(object):
self.update_screen = True self.update_screen = True
self.player_mode = 'now' self.player_mode = 'now'
self.detour_active = False self.detour_active = False
self.detour_settings = collections.OrderedDict([('current_detour',0), ('is_playing', False), ('is_recording', False), ('record_loop', False), ('detour_size', False), ('detour_speed', 0), ('memory_full', False), ('mix_position', False), ('is_delay', False), ('detour_position', 0), ('detour_start', 0), ('detour_end', 0), ])
### persisted data (use default if doesnt exits): ### persisted data (use default if doesnt exits):
self.bank_data = [self.create_empty_bank()] self.bank_data = [self.create_empty_bank()]

View File

@@ -81,6 +81,8 @@ class Display(object):
self._load_sampler() self._load_sampler()
elif self.data.display_mode == 'SHADERS': elif self.data.display_mode == 'SHADERS':
self._load_shaders() self._load_shaders()
elif self.data.display_mode == 'DETOUR':
self._load_detour()
self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0) self.display_text.tag_add("COLUMN_NAME", 5.0, 6.0)
@@ -176,6 +178,21 @@ class Display(object):
self._highlight_this_param(self.shaders.focused_param) self._highlight_this_param(self.shaders.focused_param)
def _load_detour(self):
line_count = 0
self.display_text.insert(END, '------------------ <DETOUR> ------------------- \n')
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.28)
## showing current detour info:
self.display_text.insert(END, '{:^23} {:^22} \n'.format('SETTING', 'VALUE'))
for index, (key, value) in enumerate(self.data.detour_settings.items()):
if index < 9:
self.display_text.insert(END, '{:>23} {:<22} \n'.format(key, value))
detour_banner = self.create_detour_display_banner(self.data.detour_settings['detour_size'], self.data.detour_settings['detour_position'], self.data.detour_settings['detour_start'], self.data.detour_settings['detour_end'])
self.display_text.insert(END, '{} \n'.format(detour_banner))
self.display_text.tag_add("NOW_PLAYER_INFO", 15.0, 15.0 + self.SELECTOR_WIDTH)
def _load_message(self): def _load_message(self):
if self.message_handler.current_message[1]: if self.message_handler.current_message[1]:
self.display_text.insert(END, '{:5} {:42} \n'.format( self.display_text.insert(END, '{:5} {:42} \n'.format(
@@ -280,6 +297,32 @@ round(param_row + column_offset + (param_num+1)*param_length, 2))
return ''.join(banner_list) return ''.join(banner_list)
@staticmethod
def create_detour_display_banner(size, position, start, end):
banner_list = ['|', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-',
'|']
max = len(banner_list) - 1
if size == 0:
size = max
#print('start value is {}, end value is {}, position is {}'.format(start, end, position))
if start > 0:
start = int(math.floor(float(start) /
float(size) * (max - 1)) + 1)
banner_list[start] = '['
if end > 0:
end = int(math.floor(float(end) /
float(size) * (max - 1)) + 1)
banner_list[end] = ']'
position = int(math.floor(float(position) /
float(size) * (max - 1)) + 1)
banner_list[position] = '*'
return ''.join(banner_list)
def _set_colour_from_alpha(self, now_alpha, preview_alpha, next_alpha): def _set_colour_from_alpha(self, now_alpha, preview_alpha, next_alpha):
upper_bound = 150 upper_bound = 150
if self.capture is not None: if self.capture is not None:

View File

@@ -1 +1 @@
"1-1" "1-4"

View File

@@ -21,14 +21,16 @@
"NAV_SETTINGS": ["enter_on_settings_selection"], "NAV_SETTINGS": ["enter_on_settings_selection"],
"NAV_SHADERS": ["enter_on_shaders_selection"], "NAV_SHADERS": ["enter_on_shaders_selection"],
"LENGTH_SET": ["record_fixed_length"], "LENGTH_SET": ["record_fixed_length"],
"SHADER_PARAM": ["return_to_default_control_mode"] "SHADER_PARAM": ["return_to_default_control_mode"],
"NAV_DETOUR": ["toggle_detour_play"]
}, },
"d": { "d": {
"DEFAULT": ["switch_to_next_player", "toggle_player_mode"] "DEFAULT": ["switch_to_next_player", "toggle_player_mode"],
"NAV_DETOUR": ["toggle_detour_record", "toggle_detour_record_loop"]
}, },
"e": { "e": {
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"], "DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"],
"SHADER_PARAM": ["decrease_param_focus"] "SHADER_PARAM": ["decrease_param_focus"]
}, },
"f": { "f": {
"DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"], "DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"],
@@ -43,16 +45,20 @@
"DEFAULT": ["toggle_function"] "DEFAULT": ["toggle_function"]
}, },
"j": { "j": {
"DEFAULT": ["load_slot_0_into_next_player","previous_bank"] "DEFAULT": ["load_slot_0_into_next_player","previous_bank"],
"NAV_DETOUR": ["switch_to_detour_0", "set_the_detour_mix_0"]
}, },
"k": { "k": {
"DEFAULT": ["load_slot_1_into_next_player","next_bank"] "DEFAULT": ["load_slot_1_into_next_player","next_bank"],
"NAV_DETOUR": ["switch_to_detour_1", "set_the_detour_mix_1"]
}, },
"l": { "l": {
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"] "DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"],
"NAV_DETOUR": ["switch_to_detour_2", "clear_this_detour"]
}, },
"m": { "m": {
"DEFAULT": ["load_slot_3_into_next_player"] "DEFAULT": ["load_slot_3_into_next_player"],
"NAV_DETOUR": ["switch_to_detour_3"]
}, },
"n": { "n": {
"DEFAULT": ["load_slot_4_into_next_player"] "DEFAULT": ["load_slot_4_into_next_player"]

View File

@@ -3,16 +3,20 @@
"DEFAULT": ["set_the_current_video_alpha_continuous"] "DEFAULT": ["set_the_current_video_alpha_continuous"]
}, },
"control_change 1": { "control_change 1": {
"DEFAULT": ["set_the_next_video_alpha_continuous"] "DEFAULT": ["set_the_next_video_alpha_continuous"],
"NAV_DETOUR": ["set_detour_mix_continuous"]
}, },
"control_change 2": { "control_change 2": {
"DEFAULT": ["set_the_camera_alpha_continuous"] "DEFAULT": ["set_the_camera_alpha_continuous"],
"NAV_DETOUR": ["set_detour_speed_position_continuous"]
}, },
"control_change 3": { "control_change 3": {
"DEFAULT": ["set_the_camera_colour_u_continuous"] "DEFAULT": ["set_the_camera_colour_u_continuous"],
"NAV_DETOUR": ["set_detour_start_continuous"]
}, },
"control_change 4": { "control_change 4": {
"DEFAULT": ["set_the_camera_colour_v_continuous"] "DEFAULT": ["set_the_camera_colour_v_continuous"],
"NAV_DETOUR": ["set_detour_end_continuous"]
}, },
"control_change 5": { "control_change 5": {
"DEFAULT": ["set_the_shader_param_0_continuous"] "DEFAULT": ["set_the_shader_param_0_continuous"]