How to use notify_parameter_value method in Slash

Best Python code snippet using slash

SpecialButtonSliderElement.py

Source:SpecialButtonSliderElement.py Github

copy

Full Screen

...78 self.notify_parameter_name(self.parameter_name)79 @subject_slot('value')80 def _on_property_value_changed(self):81 """ This is only used for property observing, parameters are already observed. """82 self.notify_parameter_value(self.parameter_value)83 def set_buttons(self, buttons):84 """ Sets the buttons to use in this button slider. """85 assert buttons is None or len(buttons) > 086 self._smoother.stop_smoothing()87 self._last_sent_value = -188 self._buttons = buttons or []89 if buttons and self._should_invert_buttons:90 self._buttons = list(self._buttons)[::-1]91 self._button_value.replace_subjects(self._buttons)92 self._update_mapping_type()93 return94 def get_button(self, index):95 """ Returns the button at the index in the slider or None if out of range or no96 buttons. """97 if self._buttons and index in xrange(len(self._buttons)):98 return self._buttons[index]99 else:100 return101 def height(self):102 """ Returns the height or number of buttons in the slider or 0 if no buttons. """103 if self._buttons:104 return len(self._buttons)105 return 0106 def enable_fine_tune_and_reset(self, enable):107 """ Enables/disables fine tuning. When enabled the mapping type will be set to108 inc/dec, the highest button in the slider will be set up as a reset/toggle button109 and the lowest button will be set up as a clear envelope button. """110 self._is_fine_tuning = bool(enable)111 self._update_mapping_type()112 def set_slider_color(self, color):113 """ Sets the LED color to use when the slider is set up as a continuous114 slider. """115 self._slider_color = color116 def set_bipolar_color(self, color):117 """ Sets the LED color to use when the slider is set up as a bipolar slider. """118 self._bipolar_color = color119 def set_inc_dec_colors(self, colors):120 """ Sets the tuple of LED colors (can't increment/can increment) to use when the121 slider is set up as inc/dec buttons. """122 assert isinstance(colors, tuple)123 assert len(colors) == 2124 self._inc_dec_colors = colors125 def set_off_on_colors(self, colors):126 """ Sets the tuple of LED colors (off/on) to use when the slider is set up as an127 on/off button. """128 assert isinstance(colors, tuple)129 assert len(colors) == 2130 self._off_on_colors = colors131 def set_automation_clear_colors(self, colors):132 """ Sets the tuple of LED colors (off/on) to use for the lowest button in the133 slider (clear automation) when fine tune is enabled. """134 assert isinstance(colors, tuple)135 assert len(colors) == 2136 self._automat_clear_colors = colors137 def set_smoothing_speed(self, speed):138 """ Sets the smoother object's smoothing speed. """139 self._smoother.set_smoothing_speed(speed)140 def set_property_to_map_to(self, prop):141 """ Sets the property to map to and connects to it. Also handles setting up142 observers. """143 self.release_parameter()144 self._parameter_to_map_to = prop145 self._smoother.set_parameter(prop)146 self._on_parameter_name_changed.subject = prop147 self._on_property_value_changed.subject = prop148 self._update_mapping_type()149 def connect_to(self, parameter):150 """ Overrides standard so that mapping type can be properly updated on parameter151 assignment. Also handles setting up observers. """152 self._on_parameter_changed.subject = None153 self._on_parameter_name_changed.subject = None154 SliderElement.connect_to(self, parameter)155 self._smoother.set_parameter(self._parameter_to_map_to)156 self._on_parameter_changed.subject = self._parameter_to_map_to157 self._on_parameter_name_changed.subject = self._parameter_to_map_to158 self._update_mapping_type()159 return160 def release_parameter(self):161 """ Overrides standard to update mapping type on parameter disconnect and clear162 out observers. """163 self._on_parameter_changed.subject = None164 self._on_property_value_changed.subject = None165 SliderElement.release_parameter(self)166 self._smoother.set_parameter(None)167 self._parameter_to_map_to = None168 self._update_mapping_type()169 return170 def clear_send_cache(self):171 """ Extends standard to clear last sent value. """172 super(SpecialButtonSliderElement, self).clear_send_cache()173 self._last_sent_value = -1174 def send_value(self, value, **k):175 """ Overrides standard to interpret parameter values differently and use different176 LED colors depending on the type of parameter being controlled. Also handles177 clearing LEDs if no parameter assigned. """178 assert value is not None179 assert isinstance(value, int)180 assert value in range(128)181 if self._buttons and value != self._last_sent_value:182 buttons_len = len(self._buttons)183 led_color = 'DefaultButton.Off'184 param = self._parameter_to_map_to185 if param:186 param_value = int((param.value - param.min) / (param.max - param.min) * buttons_len)187 offsets = self._strategy['offsets'](param, param_value, value, buttons_len)188 if offsets == (-1, -1):189 set_group_button_lights(self._buttons, 'DefaultButton.Off')190 else:191 for index, button in enumerate(self._buttons):192 led_color = self._strategy['send_value'](self, param, index, offsets, buttons_len)193 if button:194 button.set_light(led_color or 'DefaultButton.Off')195 else:196 set_group_button_lights(self._buttons, 'DefaultButton.Off')197 self._last_sent_value = value198 return199 @subject_slot_group('value')200 def _button_value(self, value, sender):201 """ Overrides standard to interpret values from buttons differently depending202 on the parameter being controlled. """203 self.clear_send_cache()204 self._last_sent_value = -1205 if value:206 self._smoother.stop_smoothing()207 if self._is_velocity_sensitive:208 s = get_smoothing_speed_for_velocity(value)209 self._smoother.set_smoothing_speed(s)210 button_id = list(self._buttons).index(sender)211 buttons_len = len(self._buttons)212 midi_value = int(127 * button_id / (buttons_len - 1))213 param = self._parameter_to_map_to214 if param and param.is_enabled:215 param_value = self._strategy['button_value'](self, param, button_id)216 if param_value is not None:217 self._smoother.set_parameter_value(param_value, self._mapping_type >= INC_DEC)218 self.notify_value(midi_value)219 self._last_received_value = midi_value220 return221 def _on_smoothing_complete(self):222 self._last_sent_value = -1223 def _update_mapping_type(self):224 """ Updates the type of mapping to use based on the type of parameter being225 controlled. """226 self._last_sent_value = -1227 self._mapping_type = SLIDER228 self._smoother.stop_smoothing()229 if self._parameter_to_map_to is not None:230 param = self._parameter_to_map_to231 if self._is_fine_tuning:232 self._mapping_type = INC_DEC233 self._inc_dec_factor = (param.max - param.min) / 127.0234 elif param.max == abs(param.min):235 self._mapping_type = BIPOLAR236 else:237 parent = param.canonical_parent238 if isinstance(parent, Live.Device.Device):239 parent = parent.class_name240 if parameter_is_quantized(param):241 self._mapping_type = INC_DEC242 if param.max - param.min == 1.0:243 self._mapping_type = ON_OFF244 self._inc_dec_factor = 1245 self._strategy = STRATEGIES[self._mapping_type]246 self._on_parameter_changed()247 else:248 set_group_button_lights(self._buttons, 'DefaultButton.Off')249 self.notify_parameter_value(self.parameter_value)250 self.notify_parameter_name(self.parameter_name)251 return252 @subject_slot('value')253 def _on_parameter_changed(self):254 assert self._parameter_to_map_to is not None255 param = self._parameter_to_map_to256 midi_value = parameter_value_to_midi_value(param.value, param.min, param.max)257 self.send_value(midi_value)258 self.notify_parameter_value(self.parameter_value)259 return260 def message_channel(self):261 raise NotImplementedError262 def message_identifier(self):263 raise NotImplementedError264 def message_map_mode(self):265 return Live.MidiMap.MapMode.absolute266 def identifier_bytes(self):267 raise RuntimeWarning...

Full Screen

Full Screen

SpecialEncoderElement.py

Source:SpecialEncoderElement.py Github

copy

Full Screen

...54 return ''55 @subject_slot('value')56 def _on_parameter_value_changed(self):57 """ Notifies listeners of parameter_value upon changes. """58 self.notify_parameter_value(self.parameter_value)59 @subject_slot('name')60 def _on_parameter_name_changed(self):61 """ Notifies listeners of parameter_name upon changes. """62 self.notify_parameter_name(self.parameter_name)63 def release_parameter(self):64 """ Extends standard to send 0 value to clear LED if no parameter to map to65 and notify listener. """66 self._property_to_map_to = None67 super(SpecialEncoderElement, self).release_parameter()68 if not self.is_mapped_manually() and not self._parameter_to_map_to:69 self.send_value(0, force=True)70 self._update_assignment_and_notify()71 return72 def install_connections(self, install_translation=None, install_mapping=None, install_forwarding=None):73 """ Extends standard to notify listener. """74 super(SpecialEncoderElement, self).install_connections(install_translation, install_mapping, install_forwarding)75 self._update_assignment_and_notify()76 def set_property_to_map_to(self, prop):77 """ Sets the property to map to and notifies listeners. """78 notify = prop != self._property_to_map_to79 self._property_to_map_to = prop80 if notify:81 self._update_assignment_and_notify()82 def _update_assignment_and_notify(self):83 """ Updates/verifies this encoder's assignment, notifies listeners and sets up84 value and name listeners. """85 param = self.mapped_parameter()86 if self._property_to_map_to:87 param = self._property_to_map_to88 if self.is_mapped_manually() or not live_object_is_valid(param):89 param = None90 self.notify_parameter(param)91 self.notify_parameter_name(self.parameter_name)92 self.notify_parameter_value(self.parameter_value)93 self._on_parameter_value_changed.subject = param94 self._on_parameter_name_changed.subject = param95 return96 def is_enabled(self):97 """ Returns whether this control is enabled. """98 return self._is_enabled99 def is_mapped_manually(self):100 """ Returns whether the encoder has been MIDI mapped. """101 return not self._is_mapped and not self._is_being_forwarded102 def receive_value(self, value):103 """ Extends standard to store last received value. """104 super(SpecialEncoderElement, self).receive_value(value)105 self._last_received_value = value106 def get_adjustment_factor(self, value, threshold=10):...

Full Screen

Full Screen

slash_run_result.py

Source:slash_run_result.py Github

copy

Full Screen

...46 self.active_fixtures[f_id] = value47 def notify_fixture_end(self, f_id):48 _logger.debug('ended fixture {}', f_id)49 self.active_fixtures.pop(f_id)50 def notify_parameter_value(self, p_id, value):51 slash.context.result.data.setdefault('param_values', {})[p_id] = value52 def get_fixture_memento(self):53 return copy.deepcopy(self.active_fixtures)54class Event(object):55 def __init__(self, args):56 super(Event, self).__init__()57 self.args = args58 self.timestamp = next(_timestamps)59 def is_before(self, other_event):60 return self.timestamp < other_event.timestamp61 def __repr__(self):62 return '<Event #{}: {}>'.format(self.timestamp, self.args)63class Events(object):64 def __init__(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful