예제 #1
0
 def OnButtonUndoPressed(self, control, event):
     self.updateLED(control, COLORS.BW.WHITE)
     if self.controls.isButtonShiftPressed:
         general.undoDown()
     else:
         general.undoUp()
예제 #2
0
    def OnMidiIn(self, event):

        #tbuttons
        if (event.data1 == playb):
            transport.start()  #play
            self.UpdateLEDs()

        if (event.data1 == recb):
            transport.record()  #record
            self.UpdateLEDs()

        if (event.data1 == stopb):
            transport.stop()  #stop
            self.UpdateLEDs()

        if (event.data1 == loopb):
            transport.setLoopMode()  #loop/pattern mode
            self.UpdateLEDs()

        if (event.data1 == metrob):  # metronome/button
            transport.globalTransport(midi.FPT_Metronome, 110)
            self.UpdateLEDs()

        if (event.data1 == tempob):
            transport.stop()  #tap tempo

        if (event.data1 == quantizeb):
            transport.globalTransport(midi.FPT_Snap, 48)  #snap toggle

        if (event.data1 == squantizeb):
            ui.snapMode(1)  #snap toggle

        if (event.data1 == srecb):
            transport.globalTransport(midi.FPT_CountDown,
                                      115)  #countdown before recordin

        #if (event.data1 == sstopb):
        #   transport.globalTransport(midi.FPT_F12, 71) #clear all windows

        if (event.data1 == undob):
            general.undoUp()  #undo

        if (event.data1 == sundob):
            general.undo()  #redo

        if (event.data1 == squantizeb):
            transport.globalTransport(midi.FPT_SnapMode, 49,
                                      event.pmeFlags)  #snap toggle
            self.UpdateLEDs()

        if (event.data1 == tempob):
            transport.globalTransport(midi.FPT_TapTempo, 106)  #tap tempo

        #4D controller
        if (event.data1 == knobe):
            transport.globalTransport(midi.FPT_Enter, 80)  #enter

        if (event.data1 == knobsp) & (event.data2
                                      == right):  #4d encoder spin right
            ui.jog(1)

        elif (event.data1 == knobsp) & (event.data2
                                        == left):  #4d encoder spin left
            ui.jog(-1)

        if (event.data1 == knoblr) & (event.data2
                                      == right):  #4d encoder push right
            transport.globalTransport(midi.FPT_Right, 1)

        elif (event.data1 == knoblr) & (event.data2
                                        == left):  #4d encoder push left
            transport.globalTransport(midi.FPT_Left, 1)

        if (event.data1 == knobud) & (event.data2 == up):  #4d encoder push up
            transport.globalTransport(midi.FPT_Up, 1)
        elif (event.data1 == knobud) & (event.data2
                                        == down):  #4d encoder push down
            transport.globalTransport(midi.FPT_Down, 1)

        #8 volume knobs for mixer & channel rack, 8 tracks at a time

        volinc = .005  #volume increments
        paninc = .01  # pan increments

        if ui.getFocused(0) == 1:  #mixer volume control

            if (event.data1 == muteb):
                mixer.enableTrack(mixer.trackNumber())  #mute

            if (event.data1 == solob):
                mixer.soloTrack(mixer.trackNumber())  #solo

            # VOLUME CONTROL

            #knob 1
            if (event.data1 == knob1):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 0,
                        mixer.getTrackVolume(mixer.trackNumber()) + 0 -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 0,
                        mixer.getTrackVolume(mixer.trackNumber()) + 0 +
                        volinc)  # volume values go up

            #knob 2
            if (event.data1 == knob2):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 1,
                        mixer.getTrackVolume(mixer.trackNumber() + 1) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 1,
                        mixer.getTrackVolume(mixer.trackNumber() + 1) +
                        volinc)  # volume values go up

            #knob 3
            if (event.data1 == knob3):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 2,
                        mixer.getTrackVolume(mixer.trackNumber() + 2) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 2,
                        mixer.getTrackVolume(mixer.trackNumber() + 2) +
                        volinc)  # volume values go up

            #knob 4
            if (event.data1 == knob4):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 3,
                        mixer.getTrackVolume(mixer.trackNumber() + 3) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 3,
                        mixer.getTrackVolume(mixer.trackNumber() + 3) +
                        volinc)  # volume values go up

            #knob5
            if (event.data1 == knob5):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 4,
                        mixer.getTrackVolume(mixer.trackNumber() + 4) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 4,
                        mixer.getTrackVolume(mixer.trackNumber() + 4) +
                        volinc)  # volume values go up

            #knob 6
            if (event.data1 == knob6):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 5,
                        mixer.getTrackVolume(mixer.trackNumber() + 5) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 5,
                        mixer.getTrackVolume(mixer.trackNumber() + 5) +
                        volinc)  # volume values go up

            #knob 7
            if (event.data1 == knob7):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 6,
                        mixer.getTrackVolume(mixer.trackNumber() + 6) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 6,
                        mixer.getTrackVolume(mixer.trackNumber() + 6) +
                        volinc)  # volume values go up

            #knob 8
            if (event.data1 == knob8):
                if event.data2 == 127:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 7,
                        mixer.getTrackVolume(mixer.trackNumber() + 7) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + 7,
                        mixer.getTrackVolume(mixer.trackNumber() + 7) +
                        volinc)  # volume values go up

            # PAN CONTROL

            #sknob 1
            if (event.data1 == sknob1):
                if event.data2 == 127:
                    mixer.setTrackPan(mixer.trackNumber() + 0,
                                      mixer.getTrackPan(mixer.trackNumber()) +
                                      0 - paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(mixer.trackNumber() + 0,
                                      mixer.getTrackPan(mixer.trackNumber()) +
                                      0 + paninc)  # volume values go up

            #sknob 2
            if (event.data1 == sknob2):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 1,
                        mixer.getTrackPan(mixer.trackNumber() + 1) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 1,
                        mixer.getTrackPan(mixer.trackNumber() + 1) +
                        paninc)  # volume values go up

            #sknob 3
            if (event.data1 == sknob3):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 2,
                        mixer.getTrackPan(mixer.trackNumber() + 2) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 2,
                        mixer.getTrackPan(mixer.trackNumber() + 2) +
                        paninc)  # volume values go up

            #sknob 4
            if (event.data1 == sknob4):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 3,
                        mixer.getTrackPan(mixer.trackNumber() + 3) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 3,
                        mixer.getTrackPan(mixer.trackNumber() + 3) +
                        paninc)  # volume values go up

            #sknob5
            if (event.data1 == sknob5):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 4,
                        mixer.getTrackPan(mixer.trackNumber() + 4) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 4,
                        mixer.getTrackPan(mixer.trackNumber() + 4) +
                        paninc)  # volume values go up

            #sknob 6
            if (event.data1 == sknob6):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 5,
                        mixer.getTrackPan(mixer.trackNumber() + 5) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 5,
                        mixer.getTrackPan(mixer.trackNumber() + 5) +
                        paninc)  # volume values go up

            #sknob 7
            if (event.data1 == sknob7):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 6,
                        mixer.getTrackPan(mixer.trackNumber() + 6) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 6,
                        mixer.getTrackPan(mixer.trackNumber() + 6) +
                        paninc)  # volume values go up

            #sknob 8
            if (event.data1 == sknob8):
                if event.data2 == 127:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 7,
                        mixer.getTrackPan(mixer.trackNumber() + 7) -
                        paninc)  # volume values go down

                elif event.data2 == 1:
                    mixer.setTrackPan(
                        mixer.trackNumber() + 7,
                        mixer.getTrackPan(mixer.trackNumber() + 7) +
                        paninc)  # volume values go up

        elif ui.getFocused(0) == 0:  # channel rack

            if (event.data1 == muteb):
                channels.muteChannel(channels.channelNumber())  #mute

            if (event.data1 == solob):
                channels.soloChannel(channels.channelNumber())  #solo

            # VOLUME CONTROL

            #knob 1
            if (event.data1 == knob1):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 0,
                        channels.getChannelVolume(channels.channelNumber() + 0)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 0,
                        channels.getChannelVolume(channels.channelNumber() + 0)
                        + volinc)  # volume values go up

            #knob 2
            if (event.data1 == knob2):
                if event.data2 == 127:

                    channels.setChannelVolume(
                        channels.channelNumber() + 1,
                        channels.getChannelVolume(channels.channelNumber() + 1)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 1,
                        channels.getChannelVolume(channels.channelNumber() + 1)
                        + volinc)  # volume values go up

            #knob 3
            if (event.data1 == knob3):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 2,
                        channels.getChannelVolume(channels.channelNumber() + 2)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 2,
                        channels.getChannelVolume(channels.channelNumber() + 2)
                        + volinc)  # volume values go up

            #knob 4
            if (event.data1 == knob4):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 3,
                        channels.getChannelVolume(channels.channelNumber() + 3)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 3,
                        channels.getChannelVolume(channels.channelNumber() + 3)
                        + volinc)  # volume values go up

            #knob 5
            if (event.data1 == knob5):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 4,
                        channels.getChannelVolume(channels.channelNumber() + 4)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 4,
                        channels.getChannelVolume(channels.channelNumber() + 4)
                        + volinc)  # volume values go up

            #knob 6
            if (event.data1 == knob6):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 5,
                        channels.getChannelVolume(channels.channelNumber() + 5)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 5,
                        channels.getChannelVolume(channels.channelNumber() + 5)
                        + volinc)  # volume values go up

            #knob 7
            if (event.data1 == knob7):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 6,
                        channels.getChannelVolume(channels.channelNumber() + 6)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 6,
                        channels.getChannelVolume(channels.channelNumber() + 6)
                        + volinc)  # volume values go up

            #knob 8
            if (event.data1 == knob8):
                if event.data2 == 127:
                    channels.setChannelVolume(
                        channels.channelNumber() + 7,
                        channels.getChannelVolume(channels.channelNumber() + 7)
                        - volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelVolume(
                        channels.channelNumber() + 7,
                        channels.getChannelVolume(channels.channelNumber() + 7)
                        + volinc)  # volume values go up

            # PAN CONTROL

            #sknob 1
            if (event.data1 == sknob1):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 0,
                        channels.getChannelPan(channels.channelNumber() + 0) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 0,
                        channels.getChannelPan(channels.channelNumber() + 0) +
                        volinc)  # volume values go up

            #sknob 2
            if (event.data1 == sknob2):
                if event.data2 == 127:

                    channels.setChannelPan(
                        channels.channelNumber() + 1,
                        channels.getChannelPan(channels.channelNumber() + 1) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 1,
                        channels.getChannelPan(channels.channelNumber() + 1) +
                        volinc)  # volume values go up

            #sknob 3
            if (event.data1 == sknob3):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 2,
                        channels.getChannelPan(channels.channelNumber() + 2) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 2,
                        channels.getChannelPan(channels.channelNumber() + 2) +
                        volinc)  # volume values go up

            #sknob 4
            if (event.data1 == sknob4):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 3,
                        channels.getChannelPan(channels.channelNumber() + 3) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 3,
                        channels.getChannelPan(channels.channelNumber() + 3) +
                        volinc)  # volume values go up

            #sknob 5
            if (event.data1 == sknob5):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 4,
                        channels.getChannelPan(channels.channelNumber() + 4) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 4,
                        channels.getChannelPan(channels.channelNumber() + 4) +
                        volinc)  # volume values go up

            #sknob 6
            if (event.data1 == sknob6):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 5,
                        channels.getChannelPan(channels.channelNumber() + 5) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 5,
                        channels.getChannelPan(channels.channelNumber() + 5) +
                        volinc)  # volume values go up

            #sknob 7
            if (event.data1 == sknob7):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 6,
                        channels.getChannelPan(channels.channelNumber() + 6) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 6,
                        channels.getChannelPan(channels.channelNumber() + 6) +
                        volinc)  # volume values go up

            #sknob 8
            if (event.data1 == sknob8):
                if event.data2 == 127:
                    channels.setChannelPan(
                        channels.channelNumber() + 7,
                        channels.getChannelPan(channels.channelNumber() + 7) -
                        volinc)  # volume values go down

                elif event.data2 == 1:
                    channels.setChannelPan(
                        channels.channelNumber() + 7,
                        channels.getChannelPan(channels.channelNumber() + 7) +
                        volinc)  # volume values go up
def OnMidiIn(event):
    """ Wrapper for the OnMidiIn thread. """
    # Play button
    if event.data1 == nihia.buttons.get("PLAY"):
        event.handled = True
        transport.start()

    # Restart button
    elif event.data1 == nihia.buttons.get("RESTART"):
        event.handled = True
        transport.setLoopMode()

    # Record button
    elif event.data1 == nihia.buttons.get("REC"):
        event.handled = True
        transport.record()

    # Count-In button
    elif event.data1 == nihia.buttons.get("COUNT_IN"):
        event.handled = True

        # Defines the standard behaviour (just to toggle "Countdown before recording" on/off)
        if COUNT_IN_BEHAVIOUR == 0:
            transport.globalTransport(midi.FPT_CountDown, 1)

        # Defines behaviour of the button if the user chooses the Maschine-alike behaviour
        if COUNT_IN_BEHAVIOUR == 1:

            # Toggles recording on if it isn't enabled already
            if transport.isRecording() == 0:
                transport.record()

            # Toggles countdown before recording on if it isn't enabled already
            if ui.isPrecountEnabled() == 0:
                transport.globalTransport(midi.FPT_CountDown, 1)

            # Stops playback if FL Studio is playing
            if transport.isPlaying() == True:
                transport.stop()

            # Then turns playback on again. This time record and countdown before recording will be activated
            transport.start()

    # Stop button
    elif event.data1 == nihia.buttons.get("STOP"):
        event.handled = True
        transport.stop()

    # Clear button
    # This one in other DAWs (in Maschine, specifically) this button is meant to clear the MIDI clip you're
    # on so you can record again on it without having to use a mouse to delete all of the notes on the clip before
    # recording again
    #
    # However, since the MIDI API on FL Studio doesn't allow control over the piano roll specifically, for now it will only just
    # emulate the delete button (which does the same)
    elif event.data1 == nihia.buttons.get("CLEAR"):
        event.handled = True
        ui.delete()

    # Loop button (toggles loop recording on/off)
    elif event.data1 == nihia.buttons.get("LOOP"):
        event.handled = True
        transport.globalTransport(midi.FPT_LoopRecord, 1)

    # Metronome button
    elif event.data1 == nihia.buttons.get("METRO"):
        event.handled = True
        transport.globalTransport(midi.FPT_Metronome, 1)

    # Tempo button
    elif event.data1 == nihia.buttons.get("TEMPO"):
        event.handled = True
        transport.globalTransport(midi.FPT_TapTempo, 1)

    # Undo button
    elif event.data1 == nihia.buttons.get("UNDO"):
        event.handled = True
        general.undoUp()

    # Redo button
    elif event.data1 == nihia.buttons.get("REDO"):
        event.handled = True
        general.undo()

    # Quantize button
    # TODO: Not imlpemented yet in FL Studio MIDI API
    #
    # Instead, it changes between FL windows
    # TODO: The code is correctly written, but the ui.showWindow() method has a bug that causes the Piano roll and Browser windows not to
    # appear when invoked. It has been said it should be fixed in a future update.
    # -----------------------------------------------------------------------------------------------------------------------------------
    # if event.data1 == nihia.buttons.get("QUANTIZE"):
    #     global window
    #     window += 1

    #     if window <= 4:
    #         ui.showWindow(window)
    #         print("if reached")
    #     elif window > 4:
    #         window = 0
    #         ui.showWindow(window)
    # -----------------------------------------------------------------------------------------------------------------------------------
    #
    # Alternative implementation: Emulate the Fn buttons
    elif event.data1 == nihia.buttons.get("QUANTIZE"):
        event.handled = True
        global window2
        window2 += 1

        # Normal behaviour if the action ID is between the desired range
        if window2 <= 68 and window2 != 67:
            transport.globalTransport(window2, 1)

        # Skips the 67 value which calls the full screen plugin picker and calls the mixer instead
        elif window2 == 67:
            window2 += 1
            transport.globalTransport(window2, 1)

        # Once window value is out of range, it sets it again to the first value in range
        elif window2 > 68:
            window2 = 64
            transport.globalTransport(window2, 1)

    # Automation button
    # Enables and disables the recording automation events
    # TODO: Not implemented yet in FL Studio MIDI API
    #
    # Instead, it shows the full-screen plugin browser
    elif event.data1 == nihia.buttons.get("AUTO"):
        event.handled = True
        transport.globalTransport(midi.FPT_F8, 1)

    # Mute button - A-Series
    elif event.data1 == nihia.buttons.get("MUTE_SELECTED"):
        event.handled = True
        mixer.muteTrack(mixer.trackNumber())

    # Solo button - A-Series
    elif event.data1 == nihia.buttons.get("SOLO_SELECTED"):
        event.handled = True
        mixer.soloTrack(mixer.trackNumber())

    # Mute button - S-Series
    elif event.data1 == nihia.buttons.get("MUTE"):
        event.handled = True
        mixerMuteSoloHandler("MUTE", event.data2, mixer.trackNumber())

    # Solo button - S-Series
    elif event.data1 == nihia.buttons.get("SOLO"):
        event.handled = True
        mixerMuteSoloHandler("SOLO", event.data2, mixer.trackNumber())

    # 4D Encoder +
    elif event.data1 == nihia.buttons.get(
            "ENCODER_GENERAL") and event.data2 == nihia.buttons.get("PLUS"):
        event.handled = True

        # Mixer navigation (right)
        if ui.getFocused(midi.widMixer) == True:
            ui.right()

        # Playback jogging
        elif (ui.getFocused(midi.widPianoRoll) == True) or (ui.getFocused(
                midi.widPlaylist) == True):
            transport.setSongPos(
                transport.getSongPos(midi.SONGLENGTH_S) + 1, midi.SONGLENGTH_S)

        # General navigation
        else:
            ui.down()

    # 4D Encoder -
    elif event.data1 == nihia.buttons.get(
            "ENCODER_GENERAL") and event.data2 == nihia.buttons.get("MINUS"):
        event.handled = True

        # Mixer navigation
        if ui.getFocused(midi.widMixer) == True:
            ui.left()

        elif (ui.getFocused(midi.widPianoRoll) == True) or (ui.getFocused(
                midi.widPlaylist) == True):
            transport.setSongPos(
                transport.getSongPos(midi.SONGLENGTH_S) - 1, midi.SONGLENGTH_S)

        # General navigation
        else:
            ui.up()

    # 4D Encoder + (selected track volume)
    elif event.data1 == nihia.buttons.get(
            "ENCODER_VOLUME_SELECTED") and event.data2 == nihia.buttons.get(
                "PLUS"):
        event.handled = True
        mixer.setTrackVolume(mixer.trackNumber(),
                             mixer.getTrackVolume(mixer.trackNumber()) + 0.01)

    # 4D Encoder - (selected track volume)
    elif event.data1 == nihia.buttons.get(
            "ENCODER_VOLUME_SELECTED") and event.data2 == nihia.buttons.get(
                "MINUS"):
        event.handled = True
        mixer.setTrackVolume(mixer.trackNumber(),
                             mixer.getTrackVolume(mixer.trackNumber()) - 0.01)

    # 4D Encoder + (selected track pan)
    elif event.data1 == nihia.buttons.get(
            "ENCODER_PAN_SELECTED") and event.data2 == nihia.buttons.get(
                "PLUS"):
        event.handled = True
        mixer.setTrackPan(mixer.trackNumber(),
                          mixer.getTrackPan(mixer.trackNumber()) + 0.01)

    # 4D Encoder + (selected track pan)
    elif event.data1 == nihia.buttons.get(
            "ENCODER_PAN_SELECTED") and event.data2 == nihia.buttons.get(
                "MINUS"):
        event.handled = True
        mixer.setTrackPan(mixer.trackNumber(),
                          mixer.getTrackPan(mixer.trackNumber()) - 0.01)

    # 4D Encoder up
    elif event.data1 == encoderHandler(
            "Y") and event.data2 == nihia.buttons.get("UP"):
        event.handled = True
        ui.up()

    # 4D Encoder down
    elif event.data1 == encoderHandler(
            "Y") and event.data2 == nihia.buttons.get("DOWN"):
        event.handled = True
        ui.down()

    # 4D Encoder (using FPT because ui.left doesn't work on the playlist)
    elif event.data1 == encoderHandler(
            "X") and event.data2 == nihia.buttons.get("LEFT"):
        event.handled = True
        if ui.getFocused(midi.widMixer) == True:
            # This one doesn't move the mixer view as you get to the border
            # ----------------------------------------------------
            # mixer.setTrackNumber(mixer.trackNumber() - 1)
            # ----------------------------------------------------
            ui.left()

        else:
            ui.left()

    # 4D Encoder (using FPT because ui.right doesn't work on the playlist)
    elif event.data1 == encoderHandler(
            "X") and event.data2 == nihia.buttons.get("RIGHT"):
        event.handled = True
        if ui.getFocused(midi.widMixer) == True:
            # This one doesn't move the mixer view as you get to the border
            # ----------------------------------------------------
            # mixer.setTrackNumber(mixer.trackNumber() + 1)
            # ----------------------------------------------------
            ui.right()

        else:
            ui.right()

    # 4D Encoder button
    elif event.data1 == nihia.buttons.get("ENCODER_BUTTON"):
        event.handled = True
        ui.enter()

    # 4D Encoder button (shifted)
    elif event.data1 == nihia.buttons.get("ENCODER_BUTTON_SHIFTED"):
        event.handled = True
        transport.globalTransport(midi.FPT_Menu, 1)

    # Knobs
    # Normal knobs - increase values
    elif event.data1 == nihia.knobs.get(
            "KNOB_1A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(0, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_2A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(1, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_3A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(2, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_4A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(3, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_5A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(4, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_6A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(5, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_7A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(6, "VOLUME", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_8A") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(7, "VOLUME", "INCREASE", mixer.trackNumber())

    # Normal knobs - decrease values
    elif event.data1 == nihia.knobs.get(
            "KNOB_1A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(0, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_2A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(1, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_3A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(2, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_4A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(3, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_5A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(4, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_6A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(5, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_7A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(6, "VOLUME", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_8A") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(7, "VOLUME", "DECREASE", mixer.trackNumber())

    # Shifted knobs - increase values
    elif event.data1 == nihia.knobs.get(
            "KNOB_1B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(0, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_2B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(1, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_3B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(2, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_4B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(3, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_5B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(4, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_6B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        adjustMixer(5, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_7B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(6, "PAN", "INCREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_8B") and event.data2 == nihia.knobs.get("INCREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(7, "PAN", "INCREASE", mixer.trackNumber())

    # Shifted knobs - decrease values
    elif event.data1 == nihia.knobs.get(
            "KNOB_1B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(0, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_2B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(1, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_3B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(2, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_4B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(3, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_5B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(4, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_6B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        adjustMixer(5, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_7B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(6, "PAN", "DECREASE", mixer.trackNumber())

    elif event.data1 == nihia.knobs.get(
            "KNOB_8B") and event.data2 == nihia.knobs.get("DECREASE"):
        event.handled = True
        # Handles track group 15 exception
        if math.trunc(1 / 8 * mixer.trackNumber()) == 15:
            return
        else:
            adjustMixer(7, "PAN", "DECREASE", mixer.trackNumber())
예제 #4
0
 def undo(unused_param_value):
     """Undo"""
     general.undoUp()
예제 #5
0
    def process(self, command):
        """Process events in shift menu

        Args:
            command (ParsedEvent): Event to process
        """
        command.addProcessor("Main shift menu")
        if command.type == eventconsts.TYPE_FADER_BUTTON:
            snap.processSnapMode(command)
            self.use()
        elif command.type == eventconsts.TYPE_PAD:
            if command.is_lift:
                if command.note == eventconsts.Pads[0][1]:
                    ui.showWindow(consts.WINDOW_PLAYLIST)
                    self.use()
                    command.handle("Switched window to Playlist")

                elif command.note == eventconsts.Pads[1][1]:
                    ui.showWindow(consts.WINDOW_CHANNEL_RACK)
                    self.use()
                    command.handle("Switched window to Channel rack")

                elif command.note == eventconsts.Pads[2][1]:
                    ui.showWindow(consts.WINDOW_PIANO_ROLL)
                    self.use()
                    command.handle("Switched window to Piano roll")

                elif command.note == eventconsts.Pads[3][1]:
                    ui.showWindow(consts.WINDOW_MIXER)
                    self.use()
                    command.handle("Switched window to Mixer")

                elif command.note == eventconsts.Pads[4][1]:
                    ui.showWindow(consts.WINDOW_BROWSER)
                    self.use()
                    command.handle("Switched window to Browser")

                elif command.note == eventconsts.Pads[6][0]:
                    ui.selectWindow(True)
                    self.use()
                    command.handle("Previous window")

                elif command.note == eventconsts.Pads[7][0]:
                    ui.selectWindow(False)
                    self.use()
                    command.handle("Next window")

                elif command.note == eventconsts.Pads[0][0]:
                    general.undoUp()
                    self.use()
                    command.handle("Undo")

                elif command.note == eventconsts.Pads[1][0]:
                    general.undoDown()
                    self.use()
                    command.handle("Redo")

                elif command.note == eventconsts.Pads[7][1]:
                    transport.globalTransport(eventconsts.midi.FPT_F8, 1)
                    self.use()
                    command.handle("Launch Plugin Picker")

                elif command.note == eventconsts.Pads[3][0]:
                    transport.globalTransport(eventconsts.midi.FPT_Save, 1)
                    self.use()
                    command.handle("Save project")
                else:
                    command.handle("Shift menu catch others", True)

            else:
                command.handle("Shift menu catch press", True)
        elif command.id == eventconsts.PITCH_BEND:
            self.use()
            pitch_val = -pitchBend.getParsedVal()
            increase = -pitchBend.getDirection()

            if pitch_val > 0 and increase == 1:
                direction = 1
            elif pitch_val < 0 and increase == -1:
                direction = -1
            else:
                direction = 0
            ui.jog(direction)
            command.handle("Pitch bend jog wheel")
예제 #6
0
    def OnMidiMsg(self, event):
        event.handled = False

        # FOR PRINTING DATA ON SCRIPT OUTPUT

        print("status: {}, port: {}, midiId: {}, data1: {}, data2: {}".format(
            event.status, event.port, event.midiId, event.data1, event.data2))

        # CONTROL CHANGE EVENT FOR BUTTONS OF MIDI
        if event.midiId == midi.MIDI_CONTROLCHANGE:
            if event.data2 > 0:

                if event.data1 == Play:
                    print('Playback')
                    transport.start()
                    ui.setHintMsg("Play/Pause")
                    event.handled = True
                elif event.data1 == Record:
                    print('Record')
                    transport.record()
                    ui.setHintMsg("Record")
                    event.handled = True
                elif event.data1 == Stop:
                    print('Stop')
                    transport.stop()
                    ui.setHintMsg("Stop")
                    event.handled = True
                elif event.data1 == ToggleLoop:
                    print('Toggle Loop')
                    transport.setLoopMode()
                    ui.setHintMsg("Pattern/Song")
                    event.handled = True

                elif event.data1 == Left:
                    print('Previous Tab')
                    transport.globalTransport(midi.FPT_WindowJog, -1)
                    ui.setHintMsg("Previous Tab")
                    event.handled = True
                elif event.data1 == Right:
                    print('Next Tab')
                    transport.globalTransport(midi.FPT_WindowJog, 1)
                    ui.setHintMsg("Next Tab")
                    event.handled = True

                elif event.data1 == Up:
                    print('Undo Up')
                    general.undoUp()
                    ui.setHintMsg("Undo Up")
                    event.handled = True
                elif event.data1 == Down:
                    print('Undo Down/ReDo')
                    general.restoreUndo()
                    ui.setHintMsg("Undo Down/ReDo")
                    event.handled = True

                elif event.data1 in Knobs:
                    mixer.setTrackVolume(
                        mixer.trackNumber() + Knobs.index(event.data1),
                        event.data2 / 127)
                    event.handled = True

        #MIDI NOTE ON/OFF FOR NOTE EVENTS
        elif event.midiId == midi.MIDI_NOTEON:
            if (event.pmeFlags & midi.PME_System != 0):

                if event.data1 == Playlist:
                    print('Playlist')
                    transport.globalTransport(midi.FPT_F5, 1)
                    ui.setHintMsg("Playlist")
                    event.handled = True
                elif event.data1 == ChannelRack:
                    print('ChannelRack')
                    transport.globalTransport(midi.FPT_F6, 1)
                    ui.setHintMsg("ChannelRack")
                    event.handled = True
                elif event.data1 == PianoRoll:
                    print('PianoRoll')
                    transport.globalTransport(midi.FPT_F7, 1)
                    ui.setHintMsg("PianoRoll")
                    event.handled = True
                elif event.data1 == Mixer:
                    print('Mixer')
                    transport.globalTransport(midi.FPT_F9, 1)
                    ui.setHintMsg("Mixer")
                    event.handled = True

                elif event.data1 == Previous:
                    print('Previous')
                    ui.previous()
                    ui.setHintMsg("Previous")
                    event.handled = True
                elif event.data1 == Next:
                    print('Next')
                    ui.next()
                    ui.setHintMsg("Next")
                    event.handled = True

                elif event.data1 == Mute:
                    print('Mute')
                    channels.muteChannel(channels.channelNumber())
                    ui.setHintMsg("Mute")
                    event.handled = True
                elif event.data1 == Solo:
                    print('Solo')
                    channels.soloChannel(channels.channelNumber())
                    ui.setHintMsg("Solo")
                    event.handled = True

                elif event.data1 == PatternUp:
                    print('Pattern Up')
                    transport.globalTransport(midi.FPT_PatternJog, -1)
                    ui.setHintMsg("Pattern Up")
                    event.handled = True
                elif event.data1 == PatternDown:
                    print('Pattern Down')
                    transport.globalTransport(midi.FPT_PatternJog, 1)
                    ui.setHintMsg("Pattern Down")
                    event.handled = True

                elif event.data1 == Overdub:
                    print('Overdub')
                    transport.globalTransport(midi.FPT_Overdub, 1)
                    ui.setHintMsg("Overdub")
                    event.handled = True
                elif event.data1 == LoopRecord:
                    print('Loop Record')
                    transport.globalTransport(midi.FPT_LoopRecord, 1)
                    ui.setHintMsg("Loop Record")
                    event.handled = True

                elif event.data1 == SnapUp:
                    print('Snap -1')
                    transport.globalTransport(midi.FPT_SnapMode, -1)
                    ui.setHintMsg("Snap -1")
                    event.handled = True
                elif event.data1 == SnapDown:
                    print('Snap +1')
                    transport.globalTransport(midi.FPT_SnapMode, 1)
                    ui.setHintMsg("Snap +1")
                    event.handled = True

                elif event.data1 == TapTempo:
                    print('Tap Tempo')
                    transport.globalTransport(midi.FPT_TapTempo, 1)
                    ui.setHintMsg("Tap Tempo")
                    event.handled = True
                elif event.data1 == Metro:
                    print('Metronome')
                    transport.globalTransport(midi.FPT_Metronome, 1)
                    ui.setHintMsg("Metronome")
                    event.handled = True
예제 #7
0
    def OnMidiIn(self, event):

        print("Output from M32: data 1 =", event.data1, ", data 2 =",
              event.data2, ", handled ", event.handled)
        u = 0
        #tbuttons
        if (event.data1 == playb):
            transport.start()  #play

        if (event.data1 == recb):
            transport.record()  #record

        if (event.data1 == stopb):
            transport.stop()  #stop

        if (event.data1 == loopb):
            transport.setLoopMode()  #loop/pattern mode

        if (event.data1 == metrob):  # metronome/button self.Clicking
            transport.globalTransport(midi.FPT_Metronome, 110)

        if (event.data1 == tempob):
            transport.stop()  #tap tempo

        if (event.data1 == quantizeb):
            transport.globalTransport(midi.FPT_Snap, 48)  #snap toggle

        if (event.data1 == squantizeb):
            transport.globalTransport(midi.FPT_Snap, 48)  #snap toggle

        if (event.data1 == srecb):
            transport.globalTransport(midi.FPT_CountDown,
                                      115)  #countdown before recordin

        if (event.data1 == sstopb):
            transport.globalTransport(midi.FPT_F12, 71)  #clear all windows

        if (event.data1 == sstopb):
            transport.globalTransport(midi.FPT_F12, 71)  #clear all windows

        if (event.data1 == undob):
            general.undoUp()  #undo

        if (event.data1 == sundob):
            general.undo()  #redo

        if (event.data1 == squantizeb):
            transport.globalTransport(midi.FPT_SnapMode, 49,
                                      event.pmeFlags)  #snap toggle

        if (event.data1 == tempob):
            transport.globalTransport(midi.FPT_TapTempo, 106)  #tap tempo

        #knobs
        if (event.data1 == knobe):
            transport.globalTransport(midi.FPT_Enter, 80)  #enter

        if (event.data1 == knobsp) & (event.data2
                                      == right):  #4d encoder spin right
            transport.globalTransport(midi.FPT_Jog, 1)

        elif (event.data1 == knobsp) & (event.data2
                                        == left):  #4d encoder spin left
            transport.globalTransport(midi.FPT_Jog, -1)

        if (event.data1 == knoblr) & (event.data2
                                      == right):  #4d encoder push right
            transport.globalTransport(midi.FPT_Right, 1)

        elif (event.data1 == knoblr) & (event.data2
                                        == left):  #4d encoder push left
            transport.globalTransport(midi.FPT_Left, 1)

        if (event.data1 == knobud) & (event.data2 == up):  #4d encoder push up
            transport.globalTransport(midi.FPT_Up, 1)
        elif (event.data1 == knobud) & (event.data2
                                        == down):  #4d encoder push down
            transport.globalTransport(midi.FPT_Down, 1)