示例#1
0
    def __call__(self, event, data=None):
        message, deltatime = event

        # Get buttons on the grid
        if message[0] == 144 and message[2] == 127:
            note_num = message[1]

            col = note_num % 16
            row = note_num / 16

            if col == 8:
                # Mute the sequencer in this row
                for sm in sequencermodel.get_current_seq_page():
                    if sm.in_range(row):
                        sm.mute_toggle()
            else:
                for sm in sequencermodel.get_current_seq_page():
                    if sm.in_range(row):
                        sm.toggle(8*row + col)
                        
        # Get transport buttons
        elif message[0] == 176 and message[2] == 127:
            cc_num = message[1]

            if cc_num == 104:
                # Up arrow button pressed
                sequencermodel.increase_velocity()

            elif cc_num == 105:
                # Down arrow button pressed
                sequencermodel.decrease_velocity()

            elif cc_num == 107:
                # Right arrow button pressed
                sequencermodel.toggle_playing()

            elif cc_num == 109:
                # User 1 button pressed
                sequencermodel.select_seq_page(0)

            elif cc_num == 110:
                # User 2 button pressed
                sequencermodel.select_seq_page(1)

            elif cc_num == 111:
                # Mixer button pressed
                sequencermodel.toggle_randomize()
示例#2
0
    midi_input_controller = MidiInputController() 

    midi_in.set_callback(midi_input_controller)

    sequencermodel.init_view()

    # Set the period in seconds for one sixteenth note
    period_sec = 60.0/constants.INTERNAL_BPM / 4

    step = 0

    if not constants.USE_EXT_CLOCK:
        while True:
            if sequencermodel.sequencer_playing:
                # Step through each button at the specified bpm
                for sm in sequencermodel.get_current_seq_page():
                    sm.start_note(step)

                time.sleep(constants.NOTE_LEN_SEC)

                for sm in sequencermodel.get_current_seq_page():
                    sm.stop_note()

                step = (step + 1) % constants.MAX_NUM_STEPS

                time.sleep(period_sec - constants.NOTE_LEN_SEC)
            else:
                step = 0
                time.sleep(0.1)

    elif constants.USE_EXT_CLOCK: