mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-05 16:00:06 +01:00
adding speed control
This commit is contained in:
@@ -146,16 +146,18 @@ class Actions(object):
|
|||||||
print('current bank is {} , the number of banks is {} '.format(self.data.bank_number, len(self.data.bank_data)))
|
print('current bank is {} , the number of banks is {} '.format(self.data.bank_number, len(self.data.bank_data)))
|
||||||
|
|
||||||
def increase_speed(self):
|
def increase_speed(self):
|
||||||
|
print("increasing speed !")
|
||||||
new_rate = self.video_driver.current_player.change_rate(0.5)
|
new_rate = self.video_driver.current_player.change_rate(0.5)
|
||||||
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
self.data.update_slot_rate_to_this(current_slot, new_rate)
|
self.data.update_slot_rate_to_this(current_slot, new_rate)
|
||||||
self._load_this_slot_into_next_player(current_slot)
|
#self._load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def decrease_speed(self):
|
def decrease_speed(self):
|
||||||
|
print("increasing speed !")
|
||||||
new_rate = self.video_driver.current_player.change_rate(-0.5)
|
new_rate = self.video_driver.current_player.change_rate(-0.5)
|
||||||
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
self.data.update_slot_rate_to_this(current_slot, new_rate)
|
self.data.update_slot_rate_to_this(current_slot, new_rate)
|
||||||
self._load_this_slot_into_next_player(current_slot)
|
#self._load_this_slot_into_next_player(current_slot)
|
||||||
|
|
||||||
def set_playing_sample_start_to_current_duration(self):
|
def set_playing_sample_start_to_current_duration(self):
|
||||||
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
current_bank, current_slot = self.data.split_bankslot_number(self.video_driver.current_player.bankslot_number)
|
||||||
@@ -281,10 +283,8 @@ class Actions(object):
|
|||||||
#### check if in dev mode:(ie not using the lcd screen)
|
#### check if in dev mode:(ie not using the lcd screen)
|
||||||
with open('/boot/config.txt', 'r') as config:
|
with open('/boot/config.txt', 'r') as config:
|
||||||
if '##no_waveshare_overlay' in config.read():
|
if '##no_waveshare_overlay' in config.read():
|
||||||
print('it is in !')
|
|
||||||
self.data.update_setting_value('other','DEV_MODE_RESET', 'on')
|
self.data.update_setting_value('other','DEV_MODE_RESET', 'on')
|
||||||
else:
|
else:
|
||||||
print('it is not in !')
|
|
||||||
self.data.update_setting_value('other','DEV_MODE_RESET', 'off')
|
self.data.update_setting_value('other','DEV_MODE_RESET', 'off')
|
||||||
|
|
||||||
def check_if_should_start_openframeworks(self):
|
def check_if_should_start_openframeworks(self):
|
||||||
@@ -368,6 +368,7 @@ class Actions(object):
|
|||||||
with open('/boot/config.txt', 'r') as config:
|
with open('/boot/config.txt', 'r') as config:
|
||||||
with open('/usr/share/X11/xorg.conf.d/99-fbturbo.conf') as framebuffer_conf:
|
with open('/usr/share/X11/xorg.conf.d/99-fbturbo.conf') as framebuffer_conf:
|
||||||
if '##no_waveshare_overlay' in config.read() and 'dev/fb0' in framebuffer_conf.read():
|
if '##no_waveshare_overlay' in config.read() and 'dev/fb0' in framebuffer_conf.read():
|
||||||
|
print('running the switch script')
|
||||||
self.run_script('switch_display_to_lcd')
|
self.run_script('switch_display_to_lcd')
|
||||||
else:
|
else:
|
||||||
self.message_handler.set_message('INFO', 'failed to switch display')
|
self.message_handler.set_message('INFO', 'failed to switch display')
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ class Display(object):
|
|||||||
bank_data = self.data.bank_data[self.data.bank_number]
|
bank_data = self.data.bank_data[self.data.bank_number]
|
||||||
self.display_text.insert(END, '------------------ <SAMPLER> ------------------ \n')
|
self.display_text.insert(END, '------------------ <SAMPLER> ------------------ \n')
|
||||||
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29)
|
self.display_text.tag_add("DISPLAY_MODE", 4.19, 4.29)
|
||||||
self.display_text.insert(END, '{:>6} {:<20} {:>6} {:<5} {:<5} \n'.format(
|
self.display_text.insert(END, '{:>6} {:<17} {:>5} {:<5} {:<5} {:<4}\n'.format(
|
||||||
'{}-slot'.format(self.data.bank_number), 'name', 'length', 'start', 'end'))
|
'{}-slot'.format(self.data.bank_number), 'name', 'length', 'start', 'end', 'spd'))
|
||||||
for index, slot in enumerate(bank_data):
|
for index, slot in enumerate(bank_data):
|
||||||
name_without_extension = slot['name'].rsplit('.',1)[0]
|
name_without_extension = slot['name'].rsplit('.',1)[0]
|
||||||
self.display_text.insert(END, '{:^6} {:<20} {:^6} {:>5} {:<5} \n'.format(
|
self.display_text.insert(END, '{:^6} {:<17} {:^5} {:>5} {:<5} {:>4}\n'.format(
|
||||||
index, name_without_extension[0:20], self.format_time_value(slot['length']),
|
index, name_without_extension[0:17], self.format_time_value(slot['length']),
|
||||||
self.format_time_value(slot['start']), self.format_time_value(slot['end'])))
|
self.format_time_value(slot['start']), self.format_time_value(slot['end']),self.format_speed_value(slot['rate'])))
|
||||||
if self.data.is_this_path_broken(slot['location']):
|
if self.data.is_this_path_broken(slot['location']):
|
||||||
self.display_text.tag_add("BROKEN_PATH", self.ROW_OFFSET + index,
|
self.display_text.tag_add("BROKEN_PATH", self.ROW_OFFSET + index,
|
||||||
self.ROW_OFFSET + self.SELECTOR_WIDTH + index)
|
self.ROW_OFFSET + self.SELECTOR_WIDTH + index)
|
||||||
@@ -299,3 +299,10 @@ class Display(object):
|
|||||||
return '99:99'
|
return '99:99'
|
||||||
else:
|
else:
|
||||||
return time.strftime("%M:%S", time.gmtime(time_in_seconds))
|
return time.strftime("%M:%S", time.gmtime(time_in_seconds))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def format_speed_value(value):
|
||||||
|
if value == 1:
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|||||||
@@ -59,10 +59,10 @@
|
|||||||
"DEFAULT": ["load_slot_6_into_next_player","toggle_shaders"]
|
"DEFAULT": ["load_slot_6_into_next_player","toggle_shaders"]
|
||||||
},
|
},
|
||||||
"q": {
|
"q": {
|
||||||
"DEFAULT": ["load_slot_7_into_next_player"]
|
"DEFAULT": ["load_slot_7_into_next_player", "increase_speed"]
|
||||||
},
|
},
|
||||||
"r": {
|
"r": {
|
||||||
"DEFAULT": ["load_slot_8_into_next_player"]
|
"DEFAULT": ["load_slot_8_into_next_player", "decrease_speed"]
|
||||||
},
|
},
|
||||||
"s": {
|
"s": {
|
||||||
"DEFAULT": ["load_slot_9_into_next_player","quit_the_program"]
|
"DEFAULT": ["load_slot_9_into_next_player","quit_the_program"]
|
||||||
|
|||||||
@@ -38,12 +38,7 @@ class AltVideoPlayer:
|
|||||||
|
|
||||||
|
|
||||||
def load(self, layer):
|
def load(self, layer):
|
||||||
#try:
|
|
||||||
self.get_context_for_player()
|
self.get_context_for_player()
|
||||||
#is_dev_mode, first_screen_arg, second_screen_arg = self.set_screen_size_for_dev_mode()
|
|
||||||
#arguments = ['--no-osd', '--layer', str(layer), '--adev', 'local', '--alpha', '0', first_screen_arg, second_screen_arg]
|
|
||||||
#if not is_dev_mode:
|
|
||||||
# arguments.append('--blank=0x{}'.format(self.data.get_background_colour()))
|
|
||||||
print('the location is {}'.format(self.location))
|
print('the location is {}'.format(self.location))
|
||||||
if self.location == '':
|
if self.location == '':
|
||||||
self.status = 'EMPTY'
|
self.status = 'EMPTY'
|
||||||
@@ -53,7 +48,7 @@ class AltVideoPlayer:
|
|||||||
self.end = self.total_length
|
self.end = self.total_length
|
||||||
if(self.start is -1):
|
if(self.start is -1):
|
||||||
self.start = 0
|
self.start = 0
|
||||||
self.client.send_message("/player/{}/load".format(self.name[0]), [self.location, self.start / self.total_length, self.end / self.total_length])
|
self.client.send_message("/player/{}/load".format(self.name[0]), [self.location, self.start / self.total_length, self.end / self.total_length, self.rate])
|
||||||
self.crop_length = self.end - self.start
|
self.crop_length = self.end - self.start
|
||||||
if 'show' in self.data.settings['sampler']['ON_LOAD']['value']:
|
if 'show' in self.data.settings['sampler']['ON_LOAD']['value']:
|
||||||
self.set_alpha_value(255)
|
self.set_alpha_value(255)
|
||||||
@@ -93,6 +88,7 @@ class AltVideoPlayer:
|
|||||||
|
|
||||||
def get_context_for_player(self):
|
def get_context_for_player(self):
|
||||||
next_context = self.data.get_next_context()
|
next_context = self.data.get_next_context()
|
||||||
|
print('the context is {}'.format(next_context))
|
||||||
self.location = next_context['location']
|
self.location = next_context['location']
|
||||||
self.total_length = next_context['length']
|
self.total_length = next_context['length']
|
||||||
self.start = next_context['start']
|
self.start = next_context['start']
|
||||||
@@ -129,16 +125,18 @@ class AltVideoPlayer:
|
|||||||
self.message_handler.set_message('INFO', 'can not seek outside range')
|
self.message_handler.set_message('INFO', 'can not seek outside range')
|
||||||
|
|
||||||
def change_rate(self, amount):
|
def change_rate(self, amount):
|
||||||
pass
|
if self.rate is None:
|
||||||
#new_rate = self.rate + amount
|
self.rate = 1
|
||||||
#if (new_rate > self.omx_player.minimum_rate() and new_rate < self.omx_player.maximum_rate()):
|
|
||||||
# updated_speed = self.omx_player.set_rate(new_rate)
|
new_rate = self.rate + amount
|
||||||
# self.rate = new_rate
|
print('new rate is being set to {}'.format(new_rate))
|
||||||
#print('max rate {} , min rate {} '.format(self.omx_player.maximum_rate() ,self.omx_player.minimum_rate()))
|
if new_rate >= 0 and new_rate <= 3:
|
||||||
#return new_rate
|
self.client.send_message("/player/{}/speed".format(self.name[0]), new_rate)
|
||||||
#else:
|
self.rate = new_rate
|
||||||
# self.message_handler.set_message('INFO', 'can not set speed outside of range')
|
return new_rate
|
||||||
#return self.rate
|
else:
|
||||||
|
self.message_handler.set_message('INFO', 'can not set speed outside of range')
|
||||||
|
return self.rate
|
||||||
|
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
return self.position
|
return self.position
|
||||||
@@ -148,7 +146,7 @@ class AltVideoPlayer:
|
|||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
try:
|
try:
|
||||||
self.client.send_message("/player/{}/quit".format(self.name[0]),True)
|
#self.client.send_message("/player/{}/quit".format(self.name[0]),True)
|
||||||
self.player_running = False
|
self.player_running = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user