Exemple #1
0
    def _setup_session_control(self):
        self.session = CustomSessionComponent(self.box_width, self.box_height, self) # subclass from _Framework
        is_momentary = True # what exactly does this do in the _Framework?
        if up_button_note_number >= 0 and down_button_note_number >= 0: # opt in enable UP/DOWN nav
            up_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, up_button_note_number) 
            up_button.name = 'Bank_Select_Up_Button' # sure, why not
            down_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, down_button_note_number)
            down_button.name = 'Bank_Select_Down_Button' #sure, why not
            self.session.set_scene_bank_buttons(down_button, up_button)
        if right_button_note_number >= 0 and left_button_note_number >= 0: # opt in enable LEFT/RIGHT nav
            right_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, right_button_note_number)
            right_button.name = 'Bank_Select_Right_Button' #sure, why not
            left_button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, left_button_note_number)
            left_button.name = 'Bank_Select_Left_Button' #sure, why not
            self.session.set_track_bank_buttons(right_button, left_button)
        self.session.name = 'Session_Control' #sure, why not
        matrix = ButtonMatrixElement() # @todo subclass this via established new patterns
        matrix.name = 'Button_Matrix' #sure, why not
        # I loop a little different. The goal is readbility, flexibility, and the web app...incase you did not notice yet
        if len(scene_launch_notes) > 0 and len(scene_launch_notes) == self.box_height: # logic check have launch notes and scene = box height
            for index in range(self.box_height): 
                self.session.scene(index).set_launch_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, scene_launch_notes[index])) 
        else :
            self.log_message("..::|| Scene launch not in use or error on case of use. Modern.DJ ||::..")
        if len(stop_track_buttons) >0 and len(stop_track_buttons) == self.box_width: #logic check have track stop assignments and 
            track_stop_buttons = [ ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, stop_track_buttons[index]) for index in range(len(stop_track_buttons))]
            for index in range(len(track_stop_buttons)):
                track_stop_buttons[index].name = 'Track_' + str(index) + '_Stop_Button' # sure, why not
            self.session.set_stop_track_clip_buttons(tuple(track_stop_buttons))
        else :
            self.log_message("..::|| Stop notes not in use or error found Modern.DJ ||::..")
        # Check for stop all clips option
        if stop_all_clips >=0 : 
            self.session.set_stop_all_clips_button(ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, stop_all_clips))
        # creating the matrix of buttons from the launch_button_list (tuple)
        launch_button_list_len = len(launch_button_list) # var used multiple times. This is a performance modification
        if (self.box_height*self.box_width) ==  launch_button_list_len : # check box size against number of button vars sent
            launch_ctr = launch_button_list_len -1 # decrement for zero offset in list/tuple
            launch_button_list.reverse() #reverse list from human readable for decrement use (performance tweak)
            ## check for use of RGB
            if use_velocity_for_RGB != 1: # if not enabled use these defaults
                self.log_message("..::|| RGB not in effect assigning defaults ||::..")
                self.clip_loaded_stopped = 1
                self.clip_currently_playing = 127
                self.clip_triggered_to_play = 64
            else: # yes RGB in effect...assign per the parameters script
                self.clip_loaded_stopped = clip_loaded_stopped
                self.clip_currently_playing = clip_currently_playing
                self.clip_triggered_to_play = clip_triggered_to_play

            for scene_index in range(self.box_height): # loop on the notes matrix
                scene = self.session.scene(scene_index) # part of the martix built, think rows
                scene.name = 'Scene_' + str(scene_index) # sure, why not
                button_row = [] # create recepticle
                # loop across the tracks
                for track_index in range(self.box_width): 
                    button = ButtonElement(is_momentary, MIDI_NOTE_TYPE, midi_channel, launch_button_list[launch_ctr]) # button instance for _Framework
                    launch_ctr = launch_ctr -1# decrement is faster than increment
                    button.name = str(track_index) + '_Clip_' + str(scene_index) + '_Button' # sure, why not
                    button_row.append(button) # add to our growing list
                    clip_slot = scene.clip_slot(track_index) # clips slot and buttons are not the same thing, this aligns these ideas in the red box
                    clip_slot.name = str(track_index) + '_Clip_Slot_' + str(scene_index) # sure, why not
                    # assign the button and and status in th refrech update
                    clip_slot.set_stopped_value(self.clip_loaded_stopped ) # this number is sent back to the machine allowing diff colors for stopped
                    clip_slot.set_started_value(self.clip_currently_playing) # this number is sent back to the machine allowing diff colors for started/is-playing
                    clip_slot.set_triggered_to_play_value(self.clip_triggered_to_play) # this number is sent back to the machine allowing diff colors for cued, will play next                   
                    clip_slot.set_launch_button(button) # part of the slit+button = go time paradigm
                matrix.add_row(tuple(button_row)) # close out the matrix build. @todo - possible subclass here?
        else : # log message
            self.log_message("..::|| Number of notes defined does not match box height and width Modern.DJ ||::..")
        ''' live 9 only
        self.set_highlighting_session_component(self.session) # new for live9 -- this is for the box. via aumhaa/bitnomad
        '''
        return None
Exemple #2
0
    def _setup_session_control(self):
        Live.Base.log("LOG: AAAMatrix _setup_session_control")
        is_momentary = True

        # Set Highlight Grid Size
        session = CustomSessionComponent(num_tracks, num_scenes)

        # Set Session Name
        session.name = 'AAAMatrix Session'

        # Set Highlight Grid Size
        session.set_offsets(offset_tracks, offset_scenes)

        # SESSION NAVIGATION BUTTONS
        right_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                     right_button_CC)
        left_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                    left_button_CC)
        right_button.name = 'Bank_Select_Right_Button'
        left_button.name = 'Bank_Select_Left_Button'
        session.set_track_bank_buttons(right_button, left_button)
        up_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                  up_button_CC)
        down_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                    down_button_CC)
        up_button.name = 'Bank_Select_Up_Button'
        down_button.name = 'Bank_Select_Down_Button'
        session.set_scene_bank_buttons(down_button, up_button)

        #SCENE NAVIGATION BUTTONS
        prev_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                    left_select_CC)
        next_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                    right_select_CC)
        next_button.name = 'Next_Select_Button'
        prev_button.name = 'Prev_Select__Button'
        session.set_select_buttons(next_button, prev_button)

        #STOP ALL CLIP BUTTON
        stop_all_button = ButtonElement(is_momentary, MIDI_CC_TYPE, CHANNEL,
                                        stop_all_clips_CC)
        stop_all_button.name = 'Stop_All_Button'
        session.set_stop_all_clips_button(stop_all_button)

        #SCENE LAUCH BUTTONS
        scene_launch_buttons = [
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL,
                          scene_launch_column_CCs[index])
            for index in xrange(num_scenes)
        ]
        scene_launch_buttons = ButtonMatrixElement(name='Scene_Launch_Buttons',
                                                   rows=[scene_launch_buttons])
        session.set_scene_launch_buttons(scene_launch_buttons)

        #CLIP STOP BUTTONS
        scene_stop_buttons = [
            ButtonElement(True, MIDI_CC_TYPE, CHANNEL,
                          clip_stop_row_CCs[index])
            for index in xrange(num_tracks)
        ]
        scene_stop_buttons = ButtonMatrixElement(name='Scene_Stop_Buttons',
                                                 rows=[scene_stop_buttons])
        session.set_stop_track_clip_buttons(scene_stop_buttons)

        #CLIP LAUCH BUTTONS
        matrix = ButtonMatrixElement(name='Button_Matrix')
        for scene_index in xrange(num_scenes):
            row = [
                ButtonElement(True, MIDI_CC_TYPE, CHANNEL,
                              clip_CCs[scene_index][track_index])
                for track_index in xrange(num_tracks)
            ]
            matrix.add_row(row)
        session.set_clip_launch_buttons(matrix)

        self.set_highlighting_session_component(session)