def topPluginEnd():
    # Only in extended mode:
    if internal.getPortExtended():
        internal.extendedMode.revert(eventconsts.INCONTROL_FADERS)
        internal.extendedMode.revert(eventconsts.INCONTROL_KNOBS)
        internal.extendedMode.revert(eventconsts.INCONTROL_PADS)
    return
def topPluginStart():
    # Only in extended mode:
    if internal.getPortExtended():
        internal.extendedMode.setVal(False, eventconsts.INCONTROL_FADERS)
        internal.extendedMode.setVal(False, eventconsts.INCONTROL_KNOBS)
        internal.extendedMode.setVal(False, eventconsts.INCONTROL_PADS)
    return
Ejemplo n.º 3
0
def processNoteModeMenuOpener(command):
    command.addProcessor("Note Menu Opener Processor")
    if (
        command.type is eventconsts.TYPE_PAD
        and command.is_lift 
        and (command.coord_X, command.coord_Y) == (8, 1)
    ):
        
        if not note_menu_active:
            switchNoteModeMenu(True)
            command.handle("Open note mode menu", True)
        else:
            # If on last page
            if noteModeMenu.num_modes - 1 == noteModeMenu.mode:
                # Exit menu
                switchNoteModeMenu(False)
                command.handle("Exit note mode menu", True)
            
            else:
                noteModeMenu.nextMode()
                command.handle("Next page of note mode menu", True)
    elif ( # Basic drum pad: forward event
        command.type is eventconsts.TYPE_BASIC_PAD
        and command.is_lift 
        and (command.coord_X, command.coord_Y) == (8, 1)
        and not note_menu_active
    ):
        switchNoteModeMenu(True)
        if not internal.getPortExtended():
            internal.sendCompleteInternalMidiMessage(command.getDataMIDI(), "Forward drum for opening note mode menu")
        else:
            internal.extendedMode.setVal(True, eventconsts.INCONTROL_PADS)
        command.handle("Open note mode menu", True)
def activeEnd():
    """Called when plugin no longer in foreground (end of focused)
    """
    # Only in extended mode: uncomment lines to revert to previous inControl modes
    if internal.getPortExtended():
        # internal.extendedMode.revert(eventconsts.INCONTROL_FADERS) # Faders
        # internal.extendedMode.revert(eventconsts.INCONTROL_KNOBS) # Knobs
        internal.extendedMode.revert(eventconsts.INCONTROL_PADS) # Pads
        pass
    return
def activeStart():
    """Called when plugin brought to foreground (focused)
    """
    # Only in extended mode: uncomment lines to set inControl mode
    if internal.getPortExtended():
        # internal.extendedMode.setVal(False, eventconsts.INCONTROL_FADERS) # Faders
        # internal.extendedMode.setVal(False, eventconsts.INCONTROL_KNOBS) # Knobs
        internal.extendedMode.setVal(False, eventconsts.INCONTROL_PADS) # Pads
        pass
    return
def topPluginEnd():
    """Called when plugin is no longer top plugin (not neccesarily focused)
    """

    # Only in extended mode: uncomment lines to revert to previous inControl modes
    if internal.getPortExtended():
        # internal.extendedMode.revert(eventconsts.INCONTROL_FADERS) # Faders
        # internal.extendedMode.revert(eventconsts.INCONTROL_KNOBS) # Knobs
        # internal.extendedMode.revert(eventconsts.INCONTROL_PADS) # Pads
        pass
    return
def topPluginStart():
    """Called when plugin is top plugin (not neccesarily focused)
    """

    # Only in extended mode: uncomment lines to set inControl mode
    if internal.getPortExtended():
        # internal.extendedMode.setVal(False, eventconsts.INCONTROL_FADERS) # Faders
        # internal.extendedMode.setVal(False, eventconsts.INCONTROL_KNOBS) # Knobs
        # internal.extendedMode.setVal(False, eventconsts.INCONTROL_PADS) # Pads
        pass
    return
def process(command):
    """Called with an event to be processed by your note processor. Events aren't filtered so you'll want to make sure your processor checks that events are notes.

    Args:
        command (ParsedEvent): An event for your function to modify/act on.
    """
    global current_set
    command.addProcessor("Note Randomiser Processor")

    # If the note processor isn't initialised, call the initialise function instead
    if not INIT_COMPLETE:
        processInit(command)
        return

    # If command is a note
    if command.type is eventconsts.TYPE_NOTE:
        if command.value:
            new_note = chord_sets[current_set][math.floor(
                abs(rng.random() * len(chord_sets[current_set]) - 0.01))]
            internal.notesDown.noteOn(
                processorhelpers.ExtensibleNote(command, [
                    processorhelpers.RawEvent(command.status, new_note,
                                              command.value)
                ]))
            command.handle("Randomise note")
        else:
            internal.notesDown.noteOff(command)
            command.handle("Randomise note off", True)

    elif command.id == eventconsts.PEDAL:
        if command.is_lift:
            command.handle("Pedal lift", True)
        else:
            toNextSet()
            if not internal.getPortExtended():
                # Forward note
                internal.sendCompleteInternalMidiMessage(command.getDataMIDI())
            command.handle("Next chord set")

    elif command.type is eventconsts.TYPE_PAD:
        if command.coord_Y == 1 and command.coord_X < 8:
            if len(chord_sets[command.coord_X]):
                current_set = command.coord_X
                command.handle("Set chord set number")
            else:
                command.handle("Chord set doesn't exist")
        elif command.coord_Y == 0 and command.coord_X < 8:
            command.handle("Drum pads catch-all", True)
def processInit(command):
    """Called if the INIT_COMPLETE flag is set to false

    Args:
        command (ParsedEvent): event to process
    """
    global current_set, chord_sets, INIT_COMPLETE, FORWARD_NOTES, bar_progresses_set
    # If command is a note
    if command.type is eventconsts.TYPE_NOTE and not command.value:
        chord_sets[current_set].append(command.note)
        command.ignore("Add note to list " + str(current_set))

    elif command.id == eventconsts.PEDAL:
        if command.is_lift:
            command.handle("Pedal lift", True)
        else:
            current_set += 1
            if current_set >= 8:
                current_set = 0
            if not internal.getPortExtended():
                # Forward note to other processor
                internal.sendCompleteInternalMidiMessage(command.getDataMIDI())
            command.handle("Next chord set")

    elif command.type is eventconsts.TYPE_PAD:
        if command.is_lift:
            if command.coord_Y == 1 and command.coord_X < 8:
                current_set = command.coord_X
                command.handle("Set chord set number")
            elif command.coord_X == 7 and command.coord_Y == 0:
                non_empty = -1
                for i in range(8):
                    if len(chord_sets[i]):
                        non_empty = i
                        break
                if non_empty != -1:
                    current_set = non_empty
                    INIT_COMPLETE = True
                    FORWARD_NOTES = False
                    command.handle("Finish setup")
                else:
                    command.handle("Couldn't finish setup - no notes added")
            elif command.coord_X == 6 and command.coord_Y == 0:
                bar_progresses_set = not bar_progresses_set
                command.handle("Toggle automatic set progression")
Ejemplo n.º 10
0
def process(command):
    """Processes events to forward them onto note processors

    Args:
        command (ParsedEvent): command to process
    """
    # If in note mode menu, use that processor
    if note_menu_active:
        processNoteModeMenu(command)
    
    # Otherwise use note processors
    else:
        for x in customProcessorsAll:
            object_to_call = getattr(noteprocessors, x)
            if object_to_call.NAME == internal.noteMode.getState():
                
                if object_to_call.FORWARD_NOTES and command.type == eventconsts.TYPE_NOTE and not internal.getPortExtended():
                    internal.sendCompleteInternalMidiMessage(command.getDataMIDI())
                
                object_to_call.process(command)
            
                if command.ignored: break
                
    # Then check the note mode menu button
    processNoteModeMenuOpener(command)