mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
trying cc to change cameras color
This commit is contained in:
12
actions.py
12
actions.py
@@ -176,6 +176,18 @@ class Actions(object):
|
||||
else:
|
||||
self.capture.start_recording()
|
||||
|
||||
def set_the_camera_colour_u_with_cc(self, amount):
|
||||
u_value = self.convert_midi_cc_value(amount, 0, 255)
|
||||
self.capture.set_colour(u_value, None)
|
||||
|
||||
def set_the_camera_colour_v_with_cc(self, amount):
|
||||
v_value = self.convert_midi_cc_value(amount, 0, 255)
|
||||
self.capture.set_colour(None, v_value)
|
||||
|
||||
@staticmethod
|
||||
def convert_midi_cc_value(cc_value, min_param, max_param):
|
||||
output_range = max_param - min_param
|
||||
return int(( cc_value / 127 ) * output_range + min_param)
|
||||
|
||||
def switch_display_to_hdmi(self):
|
||||
settings = self.data.get_settings_data()
|
||||
|
||||
@@ -1 +1 @@
|
||||
[[{"end": -1, "start": -1, "location": "/media/pi/5EB5-664C/recur test videos/colour_pixal_04.mp4", "rate": 1.5, "name": "colour_pixal_04.mp4", "length": 40.533}, {"end": -1, "start": -1, "location": "/home/pi/Videos/recordings/rec-2018-04-19-0.mp4", "rate": 1, "name": "rec-2018-04-19-0.mp4", "length": 2.24}, {"end": -1, "start": -1, "location": "/home/pi/Videos/recordings/rec-2018-04-19-1.mp4", "rate": 1, "name": "rec-2018-04-19-1.mp4", "length": 6.32}, {"end": -1, "start": -1, "location": "/home/pi/Videos/recordings/rec-2018-04-19-2.mp4", "rate": 1, "name": "rec-2018-04-19-2.mp4", "length": 4.84}, {"end": -1, "start": 2.752, "location": "/home/pi/Videos/recordings/rec-2018-04-19-3.mp4", "rate": 1, "name": "rec-2018-04-19-3.mp4", "length": 8.92}, {"end": -1, "rate": 1, "length": 9.8, "name": "rec-2018-04-19-4.mp4", "location": "/home/pi/Videos/recordings/rec-2018-04-19-4.mp4", "start": -1}, {"end": -1, "start": -1, "location": "", "rate": 1, "name": "", "length": -1}, {"end": -1, "start": -1, "location": "", "rate": 1, "name": "", "length": -1}, {"end": -1, "start": -1, "location": "", "rate": 1, "name": "", "length": -1}, {"end": -1, "start": -1, "location": "", "rate": 1, "name": "", "length": -1}]]
|
||||
[[{"length": 52.757, "rate": 1, "name": "colour_pixal_03.mp4", "end": -1, "start": 23.878, "location": "/home/pi/Videos/internal_storage/colour_pixal_03.mp4"}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}], [{"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}, {"length": -1, "rate": 1, "name": "", "end": -1, "start": -1, "location": ""}]]
|
||||
@@ -1,63 +1,69 @@
|
||||
{
|
||||
"note_on 71": {
|
||||
"control_change 1": {
|
||||
"DEFAULT": ["set_the_camera_colour_u_with_cc"]
|
||||
},
|
||||
"control_change 2": {
|
||||
"DEFAULT": ["set_the_camera_colour_v_with_cc"]
|
||||
},
|
||||
"note_on 72": {
|
||||
"NAV_BROWSER": ["move_browser_selection_up"],
|
||||
"PLAYER": ["seek_back_on_player"],
|
||||
"NAV_SETTINGS": ["move_settings_selection_up"]
|
||||
},
|
||||
"note_on 72": {
|
||||
"note_on 73": {
|
||||
"NAV_BROWSER": ["move_browser_selection_down"],
|
||||
"PLAYER": ["seek_forward_on_player"],
|
||||
"NAV_SETTINGS": ["move_settings_selection_down"]
|
||||
},
|
||||
"note_on 73": {
|
||||
"note_on 74": {
|
||||
"NAV_BROWSER": ["enter_on_browser_selection"],
|
||||
"PLAYER": ["toggle_pause_on_player"],
|
||||
"NAV_SETTINGS": ["enter_on_settings_selection"]
|
||||
},
|
||||
"note_on 74": {
|
||||
"note_on 75": {
|
||||
"DEFAULT": ["trigger_next_player"]
|
||||
},
|
||||
"note_on 75": {
|
||||
"note_on 76": {
|
||||
"DEFAULT": ["set_playing_sample_start_to_current_duration", "clear_playing_sample_start_time"]
|
||||
},
|
||||
"note_on 76": {
|
||||
"note_on 77": {
|
||||
"DEFAULT": ["set_playing_sample_end_to_current_duration", "clear_playing_sample_end_time"]
|
||||
},
|
||||
"note_on 77": {},
|
||||
"note_on 78": {
|
||||
"note_on 78": {},
|
||||
"note_on 79": {
|
||||
"DEFAULT": ["cycle_display_mode"]
|
||||
},
|
||||
"note_on 79": {
|
||||
"note_on 80": {
|
||||
"DEFAULT": ["toggle_function"]
|
||||
},
|
||||
"note_on 80": {
|
||||
"note_on 81": {
|
||||
"DEFAULT": ["load_slot_0_into_next_player","previous_bank"]
|
||||
},
|
||||
"note_on 81": {
|
||||
"note_on 82": {
|
||||
"DEFAULT": ["load_slot_1_into_next_player","next_bank"]
|
||||
},
|
||||
"note_on 82": {
|
||||
"note_on 83": {
|
||||
"DEFAULT": ["load_slot_2_into_next_player","clear_all_slots"]
|
||||
},
|
||||
"note_on 83": {
|
||||
"note_on 84": {
|
||||
"DEFAULT": ["load_slot_3_into_next_player","decrease_speed"]
|
||||
},
|
||||
"note_on 84": {
|
||||
"note_on 85": {
|
||||
"DEFAULT": ["load_slot_4_into_next_player","increase_speed"]
|
||||
},
|
||||
"note_on 85": {
|
||||
"note_on 86": {
|
||||
"DEFAULT": ["load_slot_5_into_next_player","print_speed"]
|
||||
},
|
||||
"note_on 86": {
|
||||
"note_on 87": {
|
||||
"DEFAULT": ["load_slot_6_into_next_player"]
|
||||
},
|
||||
"note_on 87": {
|
||||
"note_on 88": {
|
||||
"DEFAULT": ["load_slot_7_into_next_player"]
|
||||
},
|
||||
"note_on 88": {
|
||||
"note_on 89": {
|
||||
"DEFAULT": ["load_slot_8_into_next_player"]
|
||||
},
|
||||
"note_on 89": {
|
||||
"note_on 90": {
|
||||
"DEFAULT": ["load_slot_9_into_next_player","quit_the_program"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"options": ["dev_mode", "auto"], "name": "SCREEN_SIZE"}, {"options": ["run_action"], "name": "quit_the_program"}, {"options": ["run_action"], "name": "switch_display_to_hdmi"}, {"options": ["run_action"], "name": "switch_display_to_lcd"}, {"options": ["run_action"], "name": "set_composite_to_pal"}, {"options": ["run_action"], "name": "set_composite_to_ntsc"}]
|
||||
[{"name": "SCREEN_SIZE", "options": ["dev_mode", "auto"]}, {"name": "quit_the_program", "options": ["run_action"]}, {"name": "switch_display_to_hdmi", "options": ["run_action"]}, {"name": "switch_display_to_lcd", "options": ["run_action"]}, {"name": "set_composite_to_pal", "options": ["run_action"]}, {"name": "set_composite_to_ntsc", "options": ["run_action"]}]
|
||||
@@ -162,7 +162,7 @@ class Display(object):
|
||||
capture_info = '{}'.format(capture_status)
|
||||
|
||||
return self.VIDEO_DISPLAY_BANNER_TEXT.format(time_been, banner, time_left), \
|
||||
'{:17} {:10} {:17}'.format(now_info[17], capture_info[10], next_info[18])
|
||||
'{:17} {:10} {:17}'.format(now_info[:17], capture_info[:10], next_info[:18])
|
||||
|
||||
def _generate_capture_status(self):
|
||||
is_previewing = self.capture.is_previewing
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
|
||||
# Some settings may impact device functionality. See link above for details
|
||||
|
||||
## gives more memory to the gpu for playing 1080 videos (might need to adjust this when using older pis with less memory)
|
||||
gpu_mem=448
|
||||
## enables the raspi camera
|
||||
start_x=1
|
||||
|
||||
# uncomment if you get no picture on HDMI for a default "safe" mode
|
||||
#hdmi_safe=1
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# For more options and information see
|
||||
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
|
||||
# Some settings may impact device functionality. See link above for details
|
||||
|
||||
## gives more memory to the gpu for playing 1080 videos (might need to adjust this when using older pis with less memory)
|
||||
gpu_mem=448
|
||||
## enables the raspi camera
|
||||
start_x=1
|
||||
|
||||
# uncomment if you get no picture on HDMI for a default "safe" mode
|
||||
#hdmi_safe=1
|
||||
|
||||
@@ -14,20 +14,7 @@ class MidiInput(object):
|
||||
#self.midi_mappings = data.get_midi_mapping_data()
|
||||
self.open_port()
|
||||
|
||||
def poll_midi_input(self):
|
||||
for message in self.midi_device.iter_pending():
|
||||
|
||||
if not message.dict()['type'] == 'clock':
|
||||
print(message)
|
||||
try:
|
||||
pass#print('{} {} {}'.format(message.dict()['type'],message.dict()['note'],message.dict()['velocity']))
|
||||
except:
|
||||
pass
|
||||
self.on_midi_message(message)
|
||||
self.root.after(self.midi_delay, self.poll_midi_input)
|
||||
|
||||
def open_port(self):
|
||||
print('gonna try open this port!')
|
||||
midi_ports = mido.get_input_names()
|
||||
midi_device_on_port_20 = [s for s in midi_ports if '20:0' in s]
|
||||
if midi_device_on_port_20:
|
||||
@@ -35,23 +22,36 @@ class MidiInput(object):
|
||||
self.message_handler.set_message('INFO', 'listening to midi device {}'.format(self.midi_device.name))
|
||||
self.poll_midi_input()
|
||||
|
||||
def poll_midi_input(self):
|
||||
i = 0
|
||||
for message in self.midi_device.iter_pending():
|
||||
print(message)
|
||||
i = i + 1
|
||||
if not message.dict()['type'] == 'clock':
|
||||
self.on_midi_message(message)
|
||||
|
||||
self.root.after(self.midi_delay, self.poll_midi_input)
|
||||
|
||||
|
||||
def on_midi_message(self, message):
|
||||
message_dict = message.dict()
|
||||
if message_dict['type'] == 'note_on' and message_dict['velocity'] == 0:
|
||||
print('!!!!!')
|
||||
message_dict['type'] = 'note_off'
|
||||
mapped_message_name = message_dict['type']
|
||||
mapped_message_name = message_dict['type']
|
||||
mapped_message_value = None
|
||||
if 'note' in message_dict:
|
||||
mapped_message_name = '{} {}'.format(mapped_message_name,message_dict['note'])
|
||||
|
||||
#print(mapped_message_name)
|
||||
if 'control' in message_dict:
|
||||
mapped_message_name = '{} {}'.format(mapped_message_name,message_dict['control'])
|
||||
mapped_message_value = message_dict['value']
|
||||
|
||||
if mapped_message_name in self.midi_mappings.keys():
|
||||
self.run_action_for_mapped_message(mapped_message_name)
|
||||
self.run_action_for_mapped_message(mapped_message_name, mapped_message_value)
|
||||
else:
|
||||
pass#print('{} is not in midi map'.format(mapped_message_name))
|
||||
print('{} is not in midi map'.format(mapped_message_name))
|
||||
|
||||
def run_action_for_mapped_message(self, message_name):
|
||||
def run_action_for_mapped_message(self, message_name, mapped_message_value):
|
||||
this_mapping = self.midi_mappings[message_name]
|
||||
if self.display.control_mode in this_mapping:
|
||||
mode = self.display.control_mode
|
||||
@@ -59,14 +59,27 @@ class MidiInput(object):
|
||||
mode = 'DEFAULT'
|
||||
|
||||
if self.message_handler.function_on and len(this_mapping[mode]) > 1:
|
||||
print('the action being called is {}'.format(this_mapping[mode][1]))
|
||||
getattr(self.actions, this_mapping[mode][1])()
|
||||
method_name = this_mapping[mode][1]
|
||||
else:
|
||||
print('the action being called is {}'.format(this_mapping[mode][0]))
|
||||
getattr(self.actions, this_mapping[mode][0])()
|
||||
|
||||
method_name = this_mapping[mode][0]
|
||||
|
||||
print('the action being called is {}'.format(method_name))
|
||||
self.call_method_name(method_name, mapped_message_value)
|
||||
self.display.refresh_display()
|
||||
|
||||
def call_method_name(self, method_name, argument=None):
|
||||
if argument is not None:
|
||||
# try:
|
||||
getattr(self.actions, method_name)(argument)
|
||||
#except TypeError as e:
|
||||
# print(e)
|
||||
# self.message_handler.set_message('INFO', 'bad midi cc mapping')
|
||||
else:
|
||||
getattr(self.actions, method_name)()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -115,4 +115,22 @@ class Capture(object):
|
||||
else:
|
||||
return False
|
||||
|
||||
def set_colour(self, u_value, v_value):
|
||||
(u, v) = (128, 128)
|
||||
if self.device.color_effects is not None:
|
||||
(u, v) = self.device.color_effects
|
||||
|
||||
if u_value is not None:
|
||||
u = u_value
|
||||
if v_value is not None:
|
||||
v = v_value
|
||||
self.device.color_effects = (u, v)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class video_player:
|
||||
|
||||
def try_load(self):
|
||||
load_attempts = 0
|
||||
while(load_attempts < 4):
|
||||
while(load_attempts < 2):
|
||||
load_attempts = load_attempts + 1
|
||||
if self.load():
|
||||
print('load success')
|
||||
@@ -40,7 +40,7 @@ class video_player:
|
||||
try:
|
||||
self.get_context_for_player()
|
||||
first_screen_arg, second_screen_arg = self.set_screen_size()
|
||||
self.arguments = ['--no-osd', '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg] # , ]
|
||||
self.arguments = ['--no-osd', '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg]
|
||||
self.status = 'LOADING'
|
||||
print('the location is {}'.format(self.location))
|
||||
self.omx_player = OMXPlayer(self.location, args=self.arguments, dbus_name=self.name)
|
||||
|
||||
Reference in New Issue
Block a user