diff --git a/shader_experiments/Shaders/0-input/colour_sine.frag b/Shaders/0-input/colour_sine.frag similarity index 100% rename from shader_experiments/Shaders/0-input/colour_sine.frag rename to Shaders/0-input/colour_sine.frag diff --git a/shader_experiments/Shaders/0-input/flowing_colours.frag b/Shaders/0-input/flowing_colours.frag similarity index 100% rename from shader_experiments/Shaders/0-input/flowing_colours.frag rename to Shaders/0-input/flowing_colours.frag diff --git a/shader_experiments/Shaders/0-input/hypnotic_rings.frag b/Shaders/0-input/hypnotic_rings.frag similarity index 100% rename from shader_experiments/Shaders/0-input/hypnotic_rings.frag rename to Shaders/0-input/hypnotic_rings.frag diff --git a/shader_experiments/Shaders/0-input/squarewaves.frag b/Shaders/0-input/squarewaves.frag similarity index 100% rename from shader_experiments/Shaders/0-input/squarewaves.frag rename to Shaders/0-input/squarewaves.frag diff --git a/shader_experiments/Shaders/0-input/zoom_clouds.frag b/Shaders/0-input/zoom_clouds.frag similarity index 100% rename from shader_experiments/Shaders/0-input/zoom_clouds.frag rename to Shaders/0-input/zoom_clouds.frag diff --git a/shader_experiments/Shaders/1-input/gray_divisions.frag b/Shaders/1-input/gray_divisions.frag similarity index 100% rename from shader_experiments/Shaders/1-input/gray_divisions.frag rename to Shaders/1-input/gray_divisions.frag diff --git a/shader_experiments/Shaders/1-input/hsv_control.frag b/Shaders/1-input/hsv_control.frag similarity index 100% rename from shader_experiments/Shaders/1-input/hsv_control.frag rename to Shaders/1-input/hsv_control.frag diff --git a/shader_experiments/Shaders/1-input/invert_effect.frag b/Shaders/1-input/invert_effect.frag similarity index 100% rename from shader_experiments/Shaders/1-input/invert_effect.frag rename to Shaders/1-input/invert_effect.frag diff --git a/shader_experiments/Shaders/1-input/kaleidoscope.frag b/Shaders/1-input/kaleidoscope.frag similarity index 100% rename from shader_experiments/Shaders/1-input/kaleidoscope.frag rename to Shaders/1-input/kaleidoscope.frag diff --git a/shader_experiments/Shaders/1-input/mirror.frag b/Shaders/1-input/mirror.frag similarity index 100% rename from shader_experiments/Shaders/1-input/mirror.frag rename to Shaders/1-input/mirror.frag diff --git a/shader_experiments/Shaders/1-input/rotate.frag b/Shaders/1-input/rotate.frag similarity index 97% rename from shader_experiments/Shaders/1-input/rotate.frag rename to Shaders/1-input/rotate.frag index 3b63f1f..d1b671e 100644 --- a/shader_experiments/Shaders/1-input/rotate.frag +++ b/Shaders/1-input/rotate.frag @@ -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); } diff --git a/shader_experiments/Shaders/1-input/s-wobble.frag b/Shaders/1-input/s-wobble.frag similarity index 100% rename from shader_experiments/Shaders/1-input/s-wobble.frag rename to Shaders/1-input/s-wobble.frag diff --git a/shader_experiments/Shaders/1-input/simple_colorizer.frag b/Shaders/1-input/simple_colorizer.frag similarity index 100% rename from shader_experiments/Shaders/1-input/simple_colorizer.frag rename to Shaders/1-input/simple_colorizer.frag diff --git a/shader_experiments/Shaders/1-input/wobble.frag b/Shaders/1-input/wobble.frag similarity index 100% rename from shader_experiments/Shaders/1-input/wobble.frag rename to Shaders/1-input/wobble.frag diff --git a/shader_experiments/Shaders/1-input/zoom.frag b/Shaders/1-input/zoom.frag similarity index 100% rename from shader_experiments/Shaders/1-input/zoom.frag rename to Shaders/1-input/zoom.frag diff --git a/shader_experiments/Shaders/2-input/add_mix.frag b/Shaders/2-input/add_mix.frag similarity index 100% rename from shader_experiments/Shaders/2-input/add_mix.frag rename to Shaders/2-input/add_mix.frag diff --git a/shader_experiments/Shaders/2-input/blend_add.frag b/Shaders/2-input/blend_add.frag similarity index 100% rename from shader_experiments/Shaders/2-input/blend_add.frag rename to Shaders/2-input/blend_add.frag diff --git a/shader_experiments/Shaders/2-input/luma_key.frag b/Shaders/2-input/luma_key.frag similarity index 100% rename from shader_experiments/Shaders/2-input/luma_key.frag rename to Shaders/2-input/luma_key.frag diff --git a/shader_experiments/Shaders/2-input/mixShader.frag b/Shaders/2-input/mixShader.frag similarity index 100% rename from shader_experiments/Shaders/2-input/mixShader.frag rename to Shaders/2-input/mixShader.frag diff --git a/shader_experiments/Shaders/2-input/wipe.frag b/Shaders/2-input/wipe.frag similarity index 100% rename from shader_experiments/Shaders/2-input/wipe.frag rename to Shaders/2-input/wipe.frag diff --git a/shader_experiments/Shaders/default.vert b/Shaders/default.vert similarity index 100% rename from shader_experiments/Shaders/default.vert rename to Shaders/default.vert diff --git a/actions.py b/actions.py index f32c64f..6c87de7 100644 --- a/actions.py +++ b/actions.py @@ -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() diff --git a/data_centre/data.py b/data_centre/data.py index f70ecd8..d9e53ab 100644 --- a/data_centre/data.py +++ b/data_centre/data.py @@ -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 [] + diff --git a/display_centre/display.py b/display_centre/display.py index cf6ebc8..ee47908 100644 --- a/display_centre/display.py +++ b/display_centre/display.py @@ -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: diff --git a/display_centre/messages.py b/display_centre/messages.py index 026d33f..47fcf1b 100644 --- a/display_centre/messages.py +++ b/display_centre/messages.py @@ -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 diff --git a/json_objects/current_bankslot_number.json b/json_objects/current_bankslot_number.json index 7c1b0ff..0f0aec8 100644 --- a/json_objects/current_bankslot_number.json +++ b/json_objects/current_bankslot_number.json @@ -1 +1 @@ -"1-1" \ No newline at end of file +"1-2" \ No newline at end of file diff --git a/json_objects/keypad_action_mapping.json b/json_objects/keypad_action_mapping.json index 67a5b49..85edd15 100644 --- a/json_objects/keypad_action_mapping.json +++ b/json_objects/keypad_action_mapping.json @@ -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"]}, diff --git a/json_objects/settings_default.json b/json_objects/settings_default.json index 603543d..833ed14 100644 --- a/json_objects/settings_default.json +++ b/json_objects/settings_default.json @@ -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": { diff --git a/video_centre/capture.py b/video_centre/capture.py index f9234c9..1e6a797 100644 --- a/video_centre/capture.py +++ b/video_centre/capture.py @@ -250,5 +250,6 @@ class Capture(object): print('closing the old camera...') self.device.close() - + def receive_recording_finished(self, path, value): + pass diff --git a/video_centre/of_capture.py b/video_centre/of_capture.py index fdd8cbd..800613d 100644 --- a/video_centre/of_capture.py +++ b/video_centre/of_capture.py @@ -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: diff --git a/video_centre/video_driver.py b/video_centre/video_driver.py index 4802220..c9ba847 100644 --- a/video_centre/video_driver.py +++ b/video_centre/video_driver.py @@ -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