tidying detour + usb rcording + a few other small bits

This commit is contained in:
langolierz
2019-07-02 20:41:51 +00:00
parent 37f2833090
commit 80d4eaa20a
31 changed files with 82 additions and 29 deletions

View File

@@ -28,7 +28,7 @@ vec4 rotate(sampler2D tex, vec2 pos){
pos.x = r * cos(a + 2.0 * 3.141592 * u_x0) + 0.5;
pos.y = r * sin(a + 2.0 * 3.141592 * u_x0) + 0.5;
pos.x = 1.0 - pos.x;
if((pos.x < 0.0)||(pos.y < 0.0)||(pos.x > 1.0)||(pos.y > 1.0)){
texColourRotate = vec4(0.0);
}

View File

@@ -286,7 +286,9 @@ class Actions(object):
self.video_driver.osc_client.send_message("/detour/end", True)
else:
self.data.detour_active = True
self.video_driver.osc_client.send_message("/detour/start", True)
shader_input = self.data.settings['detour']['SHADER_POSITION']['value'] == 'input'
self.video_driver.osc_client.send_message("/detour/start", shader_input)
self.load_this_detour_shader()
def toggle_detour_play(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
@@ -310,6 +312,23 @@ class Actions(object):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
self.video_driver.osc_client.send_message("/detour/clear_this_detour", True)
def increase_mix_shader(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
l = self.data.detour_mix_shaders
self.data.detour_mix_shaders = l[1:] + l[:1]
self.data.detour_settings['mix_shader'] = l[0]
self.load_this_detour_shader()
def decrease_mix_shader(self):
if self.data.settings['detour']['TRY_DEMO']['value'] == 'enabled':
l = self.data.detour_mix_shaders
self.data.detour_mix_shaders = l[-1:] + l[:-1]
self.data.detour_settings['mix_shader'] = l[0]
self.load_this_detour_shader()
def load_this_detour_shader(self):
self.video_driver.osc_client.send_message("/detour/load_mix", "/home/pi/Shaders/2-input/" + self.data.detour_settings['mix_shader'])
def switch_to_detour_0(self):
self.switch_to_this_detour(0)
@@ -345,13 +364,10 @@ class Actions(object):
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['detour_speed'] = round(speed, 2)
self.data.detour_settings['detour_position'] = round(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)
@@ -618,6 +634,7 @@ class Actions(object):
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("/detour/detour_info", self.receive_detour_info)
this_dispatcher.map("/capture/recording_finished", self.capture.receive_recording_finished)
this_dispatcher.map("/shutdown", self.exit_osc_server)
#this_dispatcher.map("/player/a/status", self.set_status)
@@ -691,7 +708,8 @@ class Actions(object):
def shutdown_pi(self):
subprocess.call(['sudo', 'shutdown', '-h', 'now'])
def clear_message(self):
self.message_handler.clear_all_messages()

View File

@@ -43,7 +43,8 @@ class Data(object):
self.update_screen = True
self.player_mode = 'now'
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), ])
self.detour_mix_shaders = self.get_list_of_two_input_shaders()
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_shader', self.detour_mix_shaders[0]), ('detour_position', 0), ('detour_start', 0), ('detour_end', 0), ('is_delay', False)])
### persisted data (use default if doesnt exits):
self.bank_data = [self.create_empty_bank()]
@@ -318,4 +319,14 @@ class Data(object):
else:
return input
@staticmethod
def get_list_of_two_input_shaders():
if os.path.exists('/home/pi/Shaders/2-input'):
(_, _, filenames) = next(os.walk('/home/pi/Shaders/2-input'))
return filenames
#elif os.path.exists('/home/pi/r_e_c_u_r/Shaders/2-input'):
#(_, _, filenames) = next(os.walk('/home/pi/r_e_c_u_r/Shaders/2-input'))
#return filenames
else:
return []

View File

@@ -185,9 +185,9 @@ class Display(object):
## showing current detour info:
self.display_text.insert(END, '{:^23} {:^22} \n'.format('SETTING', 'VALUE'))
self.display_text.insert(END, '{:>23} {:<22} \n'.format("DETOUR_ACTIVE", self.data.detour_active))
for index, (key, value) in enumerate(self.data.detour_settings.items()):
if index < 9:
if index < 8:
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))
@@ -302,7 +302,8 @@ round(param_row + column_offset + (param_num+1)*param_length, 2))
banner_list = ['|', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'-', '-', '-', '-', '-', '-', '-', '-', '-',
'|']
max = len(banner_list) - 1
if size == 0:

View File

@@ -27,3 +27,6 @@ class MessageHandler(object):
if self.number_of_messages is 0:
self.current_message = [None, None, None]
def clear_all_messages(self):
self.current_message = [None, None, None]
self.number_of_messages = 0

View File

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

View File

@@ -1,7 +1,7 @@
{
"a": {
"NAV_BROWSER": ["move_browser_selection_up"],
"PLAYER": ["seek_back_on_player", "decrease_seek_time"],
"DEFAULT": ["seek_back_on_player", "decrease_seek_time"],
"NAV_SETTINGS": ["move_settings_selection_up"],
"NAV_SHADERS": ["move_shaders_selection_up"],
"LENGTH_SET": ["return_to_default_control_mode"],
@@ -9,7 +9,7 @@
},
"b": {
"NAV_BROWSER": ["move_browser_selection_down"],
"PLAYER": ["seek_forward_on_player", "increase_seek_time"],
"DEFAULT": ["seek_forward_on_player", "increase_seek_time"],
"NAV_SETTINGS": ["move_settings_selection_down"],
"NAV_SHADERS": ["move_shaders_selection_down"],
"LENGTH_SET": ["return_to_default_control_mode"],
@@ -17,7 +17,7 @@
},
"c": {
"NAV_BROWSER": ["enter_on_browser_selection"],
"PLAYER": ["toggle_action_on_player","toggle_show_on_player"],
"DEFAULT": ["toggle_action_on_player","toggle_show_on_player"],
"NAV_SETTINGS": ["enter_on_settings_selection"],
"NAV_SHADERS": ["enter_on_shaders_selection"],
"LENGTH_SET": ["record_fixed_length"],
@@ -30,11 +30,13 @@
},
"e": {
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"],
"SHADER_PARAM": ["decrease_param_focus"]
"SHADER_PARAM": ["decrease_param_focus"],
"NAV_DETOUR": ["decrease_mix_shader"]
},
"f": {
"DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"],
"SHADER_PARAM": ["increase_param_focus"]
"SHADER_PARAM": ["increase_param_focus"],
"NAV_DETOUR": ["increase_mix_shader"]
},
"g": {
"DEFAULT": ["toggle_capture_preview", "toggle_capture_recording"]},

View File

@@ -75,7 +75,7 @@
"yes",
"no"
],
"value": "no"
"value": "yes"
}
},
"incur": {
@@ -135,6 +135,11 @@
"options": [],
"value": null
},
"CLEAR_MESSAGE_BAR": {
"action": "clear_message",
"options": [],
"value": null
},
"DEV_MODE_RESET": {
"action": "switch_dev_mode",
"options": [
@@ -201,6 +206,14 @@
"disabled"
],
"value": "disabled"
},
"SHADER_POSITION": {
"action": null,
"options": [
"input",
"output"
],
"value": "output"
}
},
"recur": {

View File

@@ -250,5 +250,6 @@ class Capture(object):
print('closing the old camera...')
self.device.close()
def receive_recording_finished(self, path, value):
pass

View File

@@ -16,7 +16,9 @@ class OfCapture(object):
self.is_recording = False
self.is_previewing = False
self.video_dir = '/home/pi/Videos/'
self.recording_start_time = 0
self.update_capture_settings()
self.of_recording_finished = True
#self.create_capture_device()
def create_capture_device(self):
@@ -103,6 +105,8 @@ class OfCapture(object):
if not os.path.exists(self.video_dir):
os.makedirs(self.video_dir)
self.is_recording = True
self.of_recording_finished = False
self.recording_start_time = time.time()
#self.device.start_recording(self.video_dir + '/raw.h264')
self.osc_client.send_message("/capture/record/start", True)
self.monitor_disk_space()
@@ -136,13 +140,11 @@ class OfCapture(object):
self.root.after(0, self.wait_for_recording_to_save, mp4box_process, recording_name)
self.update_capture_settings()
elif os.path.exists(self.video_dir + 'raw.mp4'):
elif os.path.exists(self.video_dir + 'raw.mp4') and self.of_recording_finished:
recording_path , recording_name = self.generate_recording_path()
os.rename(self.video_dir + 'raw.mp4', recording_path )
self.is_recording = False
print('usb name is ', recording_name)
self.root.after(10000, self.data.create_new_slot_mapping_in_first_open, recording_name)
self.data.create_new_slot_mapping_in_first_open(recording_name)
self.update_capture_settings()
else:
self.root.after(1000, self.wait_for_raw_file)
@@ -183,8 +185,12 @@ class OfCapture(object):
name = 'rec-{}-{}.mp4'.format(date, i)
return '{}/{}'.format(rec_dir,name), name
def receive_recording_finished(self, unused_addr, position):
print('recieved recording finshed message !!!!')
self.of_recording_finished = True
def get_recording_time(self):
return -1
return time.time() - self.recording_start_time
#if not self.device or not self.device.recording or self.device.frame.timestamp == None:
# return -1
#else:

View File

@@ -29,7 +29,7 @@ class VideoDriver(object):
self.root.after(self.delay, self.begin_playing_parallel)
else:
self.root.after(self.delay, self.begin_playing)
self.print_status()
#self.print_status()
@@ -152,14 +152,12 @@ class VideoDriver(object):
self.current_player.reload(self.get_next_layer_value(), is_current=True)
def receive_position(self, unused_addr, player_name, args):
#print("the position of player {} is set to {}".format(player_name,args))
for player in [self.next_player, self.current_player, self.last_player]:
if player_name[0] in player.name :
player.position = args * player.total_length
break
def receive_status(self, unused_addr, player_name, args):
print("the status of player {} is set to {}".format(player_name,args))
for player in [self.next_player, self.current_player, self.last_player]:
if player_name[0] in player.name:
player.status = args