Beispiel #1
0
def OnShortPressDrumPad(event):
    global _pad_recording_task
    note = event.data1
    velocity = event.data2
    if _recorder.IsRecording():
        log('midi', 'Stop Recording. short press detected for %s' % str(note))
        _recorder.StopRecording()
        _scheduler.CancelTask(_pad_recording_task)
        _pad_recording_task = None
    elif event.status == 153:
        global _sustain_enabled
        log(
            'midi', 'Play. short press detected for %s. Sustain=%s' %
            (str(note), _sustain_enabled))
        if not _recorder.Play(note, loop=_sustain_enabled):
            if config.ENABLE_MPC_STYLE_PADS:
                index = note - 0x24
                if index < channels.channelCount():
                    # 0x3C corresponds to middle C
                    channels.midiNoteOn(index, 0x3C, velocity)
            else:
                channels.midiNoteOn(channels.selectedChannel(), note,
                                    _fallback_pad_values[note])
    elif event.status == 137:
        if not _recorder.HasRecording(note):
            if config.ENABLE_MPC_STYLE_PADS:
                index = note - 0x24
                if index < channels.channelCount():
                    # 0x3C corresponds to middle C
                    channels.midiNoteOn(index, 0x3C, 0)
            else:
                channels.midiNoteOn(channels.selectedChannel(), note, 0)
Beispiel #2
0
 def OnEncoderDecreased(self, control, event):
     control_type, control_name, control_id, control_note_or_color = control.split(
         ".")
     control_number = int(control_name)
     if ui.getFocused(midi.widMixer):
         index = mixer.trackNumber() + control_number - 1
         if self.mixer.encodersTarget == ENCODERS_NUM_TARGETS.MIXER.TRACK_VOL:
             mixer.setTrackVolume(index,
                                  mixer.getTrackVolume(index) - VOL_INC)
         elif self.mixer.encodersTarget == ENCODERS_NUM_TARGETS.MIXER.TRACK_PAN:
             mixer.setTrackPan(index, mixer.getTrackPan(index) - PAN_INC)
     elif ui.getFocused(midi.widChannelRack
                        ) and control_number <= channels.channelCount():
         index = channels.channelNumber() + control_number - 1
         if self.channels.encodersTarget == ENCODERS_NUM_TARGETS.CHANNELS.CHANNEL_VOL:
             channels.setChannelVolume(
                 index,
                 channels.getChannelVolume(index) - VOL_INC)
         elif self.channels.encodersTarget == ENCODERS_NUM_TARGETS.CHANNELS.CHANNEL_PAN:
             channels.setChannelPan(index,
                                    channels.getChannelPan(index) - PAN_INC)
     elif ui.getFocused(midi.widPlaylist):
         index = playlist.trackNumber() + control_number - 1
         if self.playlist.encodersTarget == ENCODERS_NUM_TARGETS.TRACK_VOL:
             pass
	def pad_hit(event):

		if event.midiId == 144:
			temp_step.clear()
			temp_step.append(event.data1 + offset[Switch.offset_iter])

		if ui.getFocused(5) and plugins.isValid(channels.selectedChannel()):
			if event.midiId == 128 and event.data2 != 0:
				print('skip')
			elif plugins.getPluginName(channels.selectedChannel()) == 'FPC' and event.data1 in alesis_pads:
				print('FPC')
				channels.midiNoteOn(channels.selectedChannel(), FPC_pads[alesis_pads.index(event.data1 + offset[Switch.offset_iter])], event.data2)
				event.handled = True

		elif Switch.mode_toggle == 1 and event.midiId == 144:						
			if channels.getGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter]) == 0:						
				channels.setGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter], 1)	
				event.handled = True
			else:															
				channels.setGridBit(channels.selectedChannel(), event.data1 - 60 + offset[Switch.offset_iter], 0)    
				event.handled = True	

		elif Switch.mode_toggle == 2  and 60 <= event.data1 < (channels.channelCount() + 60):
			channels.setChannelPitch(event.data1-60,  mapvalues(Switch.pitch_num, -1, 1, 0, 127))
			channels.selectOneChannel(event.data1-60)  
			channels.midiNoteOn(event.data1-60, 60, event.data2, Switch.pitch_num)
			print('a pad has been hit')
			event.handled = True
Beispiel #4
0
 def _recolor_mixer_track(self, index):
     if index != 0:
         for i in range(channels.channelCount()):
             if channels.getTargetFxTrack(i) == index:
                 mixer.setTrackColor(index, channels.getChannelColor(i))
                 return
     mixer.setTrackColor(index, -10261391)
Beispiel #5
0
 def _next_free_mixer_track(self):
     last_track = 0
     for i in range(channels.channelCount()):
         if i == channels.selectedChannel():
             # Skip the assignment for the channel we are assigning.
             continue
         last_track = max(last_track, channels.getTargetFxTrack(i))
     return last_track + 1
def _select_channel_from_name(name):
    base = name.split(' [')[0]
    for i in range(channels.channelCount()):
        if base == channels.getChannelName(i):
            channels.deselectAll()
            channels.selectChannel(i, 1)
            return True
    return False
Beispiel #7
0
 def sync_all_colors(unused_param_value):
     """Sync all colors"""
     num_channels = channels.channelCount()
     for i in range(num_channels):
         color = channels.getChannelColor(i)
         mixer_index = channels.getTargetFxTrack(i)
         if mixer_index <= 0:
             # Nothing to sync
             continue
         mixer.setTrackColor(mixer_index, color)
Beispiel #8
0
def redraw(lights):
    """Called when a redraw is taking place. Use this to draw menus to allow your users to choose options. Most of the time, you should leave this empty.

    Args:
        lights (LightMap): The lights to draw to
    """
    for ctr in range(min(channels.channelCount(1), 16)):
        x = ctr % 8
        y = ctr // 8
        lights.setPadColour(x, y, lightingconsts.colours.getClosestInt(channels.getChannelColor(ctr)))

    lights.solidifyAll()
Beispiel #9
0
    def _select_one_channel(self, index):
        if index >= channels.channelCount() or index < 0:
            return
        if SCRIPT_VERSION >= 8:
            channels.selectOneChannel(index)
        else:
            channels.deselectAll()
            channels.selectChannel(index, 1)

        if config.ENABLE_CONTROLS_FL_HINTS:
            ui.setHintMsg('[%d:%d] %s' % (channels.selectedChannel() + 1, patterns.patternNumber(),
                                          channels.getChannelName(channels.selectedChannel())))
Beispiel #10
0
def getTrackArmID():
    #loop over all plugins (we take the channelCount because we can't know for sure how much plugin are initialized
    #but we can be sure that it's not more than the number of channel)
    for y in range(0,channels.channelCount()):
        #necessary check (or it display an error)
        if plugins.isValid(y):
            #if the name of the plugin is Plume
            if plugins.getPluginName(y) == "Plume":
                #loop over all the parameter of Plume
                for x in range(0,plugins.getParamCount(y)):
                    #if the parameter is call track_arm return it
                    if plugins.getParamName(x,y) == "track_arm":
                        return x
Beispiel #11
0
def setPan(command, channel, value):
    if channels.channelCount() <= channel:
        command.handle("Channel out of range. Couldn't set pan", silent=True)
        return

    volume = getPanSend(value)
    channels.setChannelPan(channel, volume)
    action = "Set " + channels.getChannelName(
        channel) + " pan to " + getPanValue(value)
    if processorhelpers.didSnap(processorhelpers.toFloat(value, -1),
                                internal.consts.CHANNEL_PAN_SNAP_TO):
        action = "[Snapped]"
    command.handle(action)
Beispiel #12
0
def refreshAllPlumesTrackArmParameter():
    trackArmId  = getTrackArmID()
    # loop over all channels (in the channel rack)
    for y in range(0,channels.channelCount()):
        #call getTrackArmId
        
        #call isPlume track to check if the current track of the loop is a Plume one
        if isPlumeTrack(y):
            #if the current channel in the loop is the one selected
            if channels.isChannelSelected(y):
                #change the plugin parameter value (value, track_arm id, channel id)
                plugins.setParamValue(1,trackArmId,y)
            else:
                plugins.setParamValue(0,trackArmId,y)
Beispiel #13
0
def processMuteSolo(channel, command):

    if channels.channelCount() <= channel:
        command.handle("Channel out of range. Couldn't process mute",
                       silent=True)
        return

    if command.value == 0: return
    if channels.isChannelSolo(channel) and channels.channelCount() != 1:
        channels.soloChannel(channel)
        action = "Unsolo channel"

    elif command.is_double_click:
        channels.soloChannel(channel)
        action = "Solo channel"
    else:
        channels.muteChannel(channel)
        if channels.isChannelMuted(channel):
            action = "Mute channel"
        else:
            action = "Unmute channel"

    command.handle(action)
Beispiel #14
0
def setGridBits(lights):
    current_track = channels.selectedChannel()

    if channels.channelCount() <= current_track:
        return

    # Set scroll indicator
    light_num_scroll = gridBits.scroll
    if light_num_scroll < 8:

        if not gridBits.getBit(current_track, light_num_scroll):
            lights.setPadColour(light_num_scroll, 0,
                                lightingconsts.colours["LIGHT LILAC"])
        else:
            lights.setPadColour(light_num_scroll, 0,
                                lightingconsts.colours["PINK"],
                                lightingconsts.MODE_PULSE)

    # Set zoom indicator
    light_num_zoom = 7 - int(math.log(gridBits.zoom, 2))
    if light_num_zoom >= 0 and internal.window.getAnimationTick() > 7:
        if not gridBits.getBit(current_track, light_num_zoom):
            lights.setPadColour(light_num_zoom, 0,
                                lightingconsts.colours["LIGHT LIGHT BLUE"])
        else:
            lights.setPadColour(light_num_zoom, 0,
                                lightingconsts.colours["BLUE"],
                                lightingconsts.MODE_PULSE)

    # If zoom and scroll lie on same pad
    if light_num_scroll == light_num_zoom:
        if not gridBits.getBit(current_track, light_num_zoom):
            lights.setPadColour(light_num_zoom, 0,
                                lightingconsts.colours["LIGHT YELLOW"])
        else:
            lights.setPadColour(light_num_zoom, 0,
                                lightingconsts.colours["PINK"],
                                lightingconsts.MODE_PULSE)

    # Set remaining grid bits
    for i in range(8):
        if i <= internal.window.getAnimationTick():
            if gridBits.getBit(current_track, i):
                lights.setPadColour(i, 0, lightingconsts.colours["RED"],
                                    lightingconsts.MODE_PULSE)
            else:
                lights.setPadColour(i, 0, lightingconsts.colours["DARK GREY"])

    return
Beispiel #15
0
def isPlumeTrack(ID):
    PlumeTab = []
    for y in range(0,channels.channelCount()):
        try :
            if plugins.getPluginName(y) == "Plume":
                #if the plugin at the y indice is Plume add the indice to the array PlumeTab
                PlumeTab.append(y)
        except:
            pass
    try:
        #if we can find the ID passed in the function in the PlumeTab we return true, else we return false
        PlumeTab.index(ID)
        return True
    except:
        return False
        pass
Beispiel #16
0
    def _update_lights(self):
        is_knobs_panning = (self._current_mode == ArturiaInputControls.INPUT_MODE_MIXER_OVERVIEW and
                            self._mixer_knobs_panning)
        is_mixer_mode = self._current_mode == ArturiaInputControls.INPUT_MODE_MIXER_OVERVIEW
        is_plugin_mode = self._current_mode == ArturiaInputControls.INPUT_MODE_CHANNEL_PLUGINS

        self._lights.SetLights({
            ArturiaLights.ID_BANK_NEXT: ArturiaLights.AsOnOffByte(is_knobs_panning),
            ArturiaLights.ID_BANK_PREVIOUS: ArturiaLights.AsOnOffByte(is_mixer_mode),
        })

        channel_idx = channels.selectedChannel()
        selected_idx = channel_idx - (self._current_index_mixer * 8)

        if is_plugin_mode:
            values = [ArturiaLights.rgb2int(0x7F, 0, 0) if v else 0 for v in self._get_current_toggle_values()]
            self._lights.SetBankLights(values, rgb=True)
        else:
            values = [0]*9
            if config.ENABLE_COLORIZE_BANK_LIGHTS:
                for i in range(8):
                    idx = (self._current_index_mixer * 8) + i
                    if idx < channels.channelCount():
                        values[i] = ArturiaLights.fadedColor(channels.getChannelColor(idx))

            # Bank lights
            if not arturia_leds.ESSENTIAL_KEYBOARD:
                if config.ENABLE_COLORIZE_BANK_LIGHTS:
                    if 0 <= selected_idx < 8:
                        values[selected_idx] = ArturiaLights.fullColor(channels.getChannelColor(channel_idx))
                    self._lights.SetBankLights(values, rgb=True)
                else:
                    if 0 <= selected_idx < 8:
                        values[selected_idx] = ArturiaLights.LED_ON
                    self._lights.SetBankLights(values, rgb=False)

        # Pad lights
        should_color_pads = ((arturia_leds.ESSENTIAL_KEYBOARD and config.ENABLE_COLORIZE_BANK_LIGHTS) or
                             (not arturia_leds.ESSENTIAL_KEYBOARD and config.ENABLE_MK2_COLORIZE_PAD_LIGHTS))

        if should_color_pads:
            selected_color = ArturiaLights.fadedColor(channels.getChannelColor(channel_idx))
            pad_values = ArturiaLights.ZeroMatrix(zero=selected_color)
            self._lights.SetPadLights(pad_values, rgb=True)
Beispiel #17
0
	def knob_turn(self):
		global proceed

		if proceed == True and temp_chan == self.data_one:
			print("proceeding")
			if ui.getFocused(0) and Switch.mixer_num == 0:
				if mixer.trackNumber() == 0 and self.data_one == 20:
					mixer.setTrackVolume(0, self.data_two/127)
				else:
					mixer.setTrackVolume(self.data_one-19, self.data_two/127)
			elif ui.getFocused(0) and Switch.mixer_num == 1:
				mixer.setTrackPan(self.data_one-19, mapvalues(self.data_two, -1, 1, 0, 127))
				# print(f'panning: {mapvalues(self.data_two, -1, 1, 0, 127)}')
			elif ui.getFocused(1) and self.data_one-20 < channels.channelCount()  and Switch.shift_status == False:
				# print(f'volume: {mapvalues(self.data_two, -1, 1, 0, 127)}')
				channels.setChannelVolume(self.data_one-20, mapvalues(self.data_two, 0, 1, 0, 127))
		elif proceed == True and temp_chan != self.data_one:
			print("proceed no more")
			proceed = False		
Beispiel #18
0
def OnLongPressDrumPad(note):
    global _pad_recording_led, _drop_note
    if _recorder.IsRecording():
        log('midi', 'Stop Recording. Long press detected for %s' % str(note))
        _recorder.StopRecording()
    else:
        log('midi', 'Start Recording. Long press detected for %s' % str(note))
        if config.ENABLE_MPC_STYLE_PADS:
            index = note - 0x24
            if index < channels.channelCount():
                # 0x3C corresponds to middle C
                channels.midiNoteOn(index, 0x3C, 0)
        else:
            channels.midiNoteOn(channels.selectedChannel(), note, 0)

        _drop_note = note
        _recorder.StartRecording(note)
        _pad_recording_led = False
        BlinkLight(note)
Beispiel #19
0
 def OnEncoderTempoDecreased(self, control, event):
     if self.controls.isButtonShiftPressed:
         transport.globalTransport(midi.FPT_TempoJog, -10)
     elif ui.getFocused(midi.widChannelRack):
         idx = channels.channelNumber(1)
         print(idx)
         if idx == -1:
             channels.selectChannel(channels.channelCount() - 1, 1)
         elif idx > 0:
             channels.deselectAll()
             channels.selectChannel(idx - 1, 1)
     elif ui.getFocused(midi.widPlaylist):
         idx = patterns.patternNumber()
         if idx > 1:  # TODO figure out why patternNumber starts at one instead of zero!
             patterns.jumpToPattern(idx - 1)
     elif ui.getFocused(midi.widMixer):
         idx = mixer.trackNumber()
         if idx > 1:  # do not include the master track (0)
             mixer.setTrackNumber(idx - 1)
    def handleJog(self, encoder, event):
        display_message = ''
        display_value = None

        i = encoder.index
        jogmap = self.encoderJogs[controls.shift.value]
        if i in jogmap:
            target, display_message = jogmap[i]
            fpt.callFPT(target, encoder.value, event)

            direction = '>' if encoder.value > 0 else '<'
            display_message += ' ' + direction
        elif i == 4:
            selected_track = self.moveSelectedMixerTrack(encoder.value)
            display_message = mixer.getTrackName(selected_track)
            display_value = selected_track
        elif i == 5:
            selected_pattern = (patterns.patternNumber() +
                                encoder.value) % patterns.patternMax()
            patterns.jumpToPattern(selected_pattern)
            display_message = patterns.getPatternName(selected_pattern)
            display_value = selected_pattern
        elif i == 6:
            group_channel_count = channels.channelCount(0)
            current_channel = channels.channelNumber(0)
            selected_group_index = self.cycleChannels(
                current=0,
                count=group_channel_count,
                condition_func=lambda c: channels.getChannelIndex(
                    c) == current_channel) or 0
            selected_index = (selected_group_index +
                              encoder.value) % group_channel_count
            channels.deselectAll()
            channels.selectChannel(selected_index)
            display_message = channels.getChannelName(selected_index)
            display_value = selected_index

        self.lcdText(display_message)
        if display_value:
            self.lcdValueText(display_value)
Beispiel #21
0
def processBitMode(command):
    current_channel = channels.selectedChannel()

    if command.type == eventconsts.TYPE_PAD and command.is_lift:
        # Grid bits
        if command.coord_Y == 0 and command.coord_X != 8:

            if channels.channelCount() <= current_channel:
                command.handle("Channel out of range", silent=True)
                return

            gridBits.toggleBit(current_channel, command.coord_X)
            command.handle("Grid Bits: Toggle bit")

        coord = [command.coord_X, command.coord_Y]

        # Scroll grid bits
        if coord == [4, 1]:
            if command.is_double_click:
                gridBits.resetScroll()
                command.handle("Grid Bits: Reset scroll")
            else:
                gridBits.scrollLeft()
                command.handle("Grid Bits: Scroll left")
        if coord == [5, 1]:
            gridBits.scrollRight()
            command.handle("Grid Bits: Scroll right")
        # Zoom grid bits
        if coord == [6, 1]:
            gridBits.zoomOut()
            command.handle("Grid Bits: Zoom out")
        if coord == [7, 1]:
            if command.is_double_click:
                gridBits.resetZoom()
                command.handle("Grid Bits: Reset zoom")
            else:
                gridBits.zoomIn()
                command.handle("Grid Bits: Zoom in")
 def OnNavigationKnobPressed(self, event):
     debug.log('OnNavigationKnobPressed', 'Dispatched', event=event)
     ## DEBUG ONLY ##
     transport.globalTransport(midi.FPT_F8, midi.FPT_F8)
     debug.log('DEBUG', 'Trying to show editor for %d' % channels.channelCount())
 def OnBankSelect(self, event):
     bank_index = event.controlNum - 24
     if bank_index < channels.channelCount():
         channels.selectOneChannel(bank_index)
     debug.log('OnBankSelect', 'Selected bank index=%d' % bank_index, event=event)
Beispiel #24
0
    def updateLEDs(self):
        if device.isAssigned():
            # play button
            if transport.isPlaying() and transport.getLoopMode():
                self.updateLED(CONTROLS.BUTTONS.PLAY, COLORS.RGB.GREEN,
                               ANIMATIONS.BLINKING.QUARTER)
            elif transport.isPlaying():
                self.updateLED(CONTROLS.BUTTONS.PLAY, COLORS.RGB.ORANGE,
                               ANIMATIONS.BLINKING.QUARTER)
            else:
                self.updateLED(CONTROLS.BUTTONS.PLAY)

            # record button
            if transport.isRecording():
                self.updateLED(CONTROLS.BUTTONS.RECORD, COLORS.RGB.RED)
            else:
                self.updateLED(CONTROLS.BUTTONS.RECORD)

            # double loop [song/pattern] button
            if transport.getLoopMode():
                self.updateLED(CONTROLS.BUTTONS.DOUBLE_LOOP)
            else:
                self.updateLED(CONTROLS.BUTTONS.DOUBLE_LOOP, COLORS.BW.WHITE)

            # metronome button
            if ui.isMetronomeEnabled():
                self.updateLED(CONTROLS.BUTTONS.METRONOME, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.METRONOME)

            # device [channel rack] button
            if ui.getFocused(midi.widChannelRack):
                self.updateLED(CONTROLS.BUTTONS.DEVICE, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.DEVICE)

            # mix [mixer] button
            if ui.getFocused(midi.widMixer):
                self.updateLED(CONTROLS.BUTTONS.MIX, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.MIX)

            # clip [playlist] button
            if ui.getFocused(midi.widPlaylist):
                self.updateLED(CONTROLS.BUTTONS.CLIP, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.CLIP)

            # browse [browser] button
            # if ui.getFocused(midi.widBrowser):
            #     self.updateLED(CONTROLS.BUTTONS.BROWSE, COLORS.BW.WHITE)
            # else:
            #     self.updateLED(CONTROLS.BUTTONS.BROWSE)

            # layout button
            if ui.getFocused(midi.widPlaylist):
                if self.playlist.layout == LAYOUTS.PLAYLIST.PATTERNS:
                    self.updateLED(CONTROLS.BUTTONS.LAYOUT, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.LAYOUT)

            # quantize/snap button
            if ui.getSnapMode() != 3:
                self.updateLED(CONTROLS.BUTTONS.QUANTIZE, COLORS.BW.WHITE)
            else:
                self.updateLED(CONTROLS.BUTTONS.QUANTIZE)

            # numbered upper buttons
            for idx, button in enumerate(CONTROLS.BUTTONS_UPPER, 1):
                if ui.getFocused(midi.widMixer):
                    if (idx == self.mixer.encodersTarget):
                        self.updateLED(button, COLORS.RGB.WHITE)
                    else:
                        self.updateLED(button)
                elif ui.getFocused(midi.widChannelRack):
                    if (idx == self.channels.encodersTarget):
                        self.updateLED(button, COLORS.RGB.ORANGE)
                    else:
                        self.updateLED(button)
                elif ui.getFocused(midi.widPlaylist):
                    if (idx == self.playlist.encodersTarget):
                        self.updateLED(button, COLORS.RGB.GREEN)
                    else:
                        self.updateLED(button)
                else:
                    self.updateLED(button)

            # pads
            for idx, pad in enumerate(CONTROLS.PADS_64):
                self.updateLED(pad, 0)
                if ui.getFocused(midi.widMixer):
                    idx += 1  # do not include the master track (0)
                    if idx < mixer.trackCount():
                        self.updateLED(
                            pad, getClosestColor(mixer.getTrackColor(idx)))
                        if mixer.isTrackSelected(
                                idx) and not mixer.isTrackEnabled(idx):
                            self.updateLED(pad, COLORS.RGB.GREEN)
                            self.updateLED(pad, COLORS.RGB.RED,
                                           ANIMATIONS.BLINKING.HALF)
                        elif mixer.isTrackSelected(idx):
                            self.updateLED(pad, COLORS.RGB.GREEN)
                            self.updateLED(
                                pad, getClosestColor(mixer.getTrackColor(idx)),
                                ANIMATIONS.PULSING.HALF)
                        elif not mixer.isTrackEnabled(idx):
                            self.updateLED(pad, COLORS.RGB.RED,
                                           ANIMATIONS.PULSING.HALF)
                elif ui.getFocused(midi.widChannelRack):
                    if idx < channels.channelCount():
                        self.updateLED(
                            pad,
                            getClosestColor(channels.getChannelColor(idx)))
                        if channels.isChannelSelected(
                                idx) and not channels.isChannelMuted(
                                    idx):  # NOTE asked this bug to be fixed!
                            self.updateLED(pad, COLORS.RGB.GREEN)
                            self.updateLED(pad, COLORS.RGB.RED,
                                           ANIMATIONS.BLINKING.HALF)
                        elif channels.isChannelSelected(idx):
                            self.updateLED(pad, COLORS.RGB.GREEN)
                            self.updateLED(
                                pad,
                                getClosestColor(channels.getChannelColor(idx)),
                                ANIMATIONS.PULSING.HALF)
                        elif not channels.isChannelMuted(
                                idx):  # NOTE asked this bug to be fixed!
                            self.updateLED(pad, COLORS.RGB.RED,
                                           ANIMATIONS.PULSING.HALF)
                elif ui.getFocused(midi.widPlaylist):
                    idx += 1  # NOTE asked this bug to be fixed!
                    if idx <= patterns.patternCount():
                        # self.updateLED(pad, getClosestColor(patterns.getPatternColor(idx)))
                        # if patterns.isPatternSelected(idx) and not patterns.isPatternEnabled(idx):
                        #     self.updateLED(pad, COLORS.RGB.GREEN)
                        #     self.updateLED(pad, COLORS.RGB.RED, ANIMATIONS.BLINKING.HALF)
                        # elif patterns.isPatternSelected(idx):
                        #     self.updateLED(pad, COLORS.RGB.GREEN)
                        #     self.updateLED(pad, getClosestColor(patterns.getPatternColor(idx)), ANIMATIONS.PULSING.HALF)
                        # elif not patterns.isPatternEnabled(idx):
                        #     self.updateLED(pad, COLORS.RGB.RED, ANIMATIONS.PULSING.HALF)
                        if (idx == patterns.patternNumber()):
                            # self.updateLED(pad, getClosestColor(patterns.getPatternColor(idx)))
                            self.updateLED(pad, COLORS.RGB.GREEN)
                            self.updateLED(pad, COLORS.RGB.RED,
                                           ANIMATIONS.PULSING.HALF)
                        else:
                            self.updateLED(
                                pad,
                                getClosestColor(patterns.getPatternColor(idx)))
Beispiel #25
0
	def switch_moment(event):
		"""handles momentary witch midi events"""
		if event.data1 == button["pad_mode_toggle"]:				# This Rotates through pad modes - standard, step sequencer, pad to channel		
			Switch.mode_toggle += 1
			if Switch.mode_toggle == 4:
				Switch.mode_toggle = 0
			print('Pad Mode: ' + mode[Switch.mode_toggle])
			ui.setHintMsg(mode[Switch.mode_toggle])

		elif event.midiId == 224: 								# pitch wheel
			Switch.pitch_num = event.data2	
			if Switch.shift_status == True:
				print(data.notes_list[int(mapvalues(Switch.pitch_num, 0, 11, 0, 244))])

		elif event.data1 == button["play"]:			
			transport.start()
			event.handled = True

		elif event.data1 == button["offset_range"]:
			Switch.offset_iter += 1
			if Switch.offset_iter == 2:     								# 2 here will limit to 32 steps, knobs. Changing to 4 will allow up to 64 steps, knobs. 
				Switch.offset_iter = 0
			ui.setHintMsg("Offset Range: " + str(Switch.offset_iter))
	
		elif event.data1 == button["stop"]:
			print('Stop')
			transport.stop()
			event.handled = True						
																	
		elif event.data1 == button["record"]:			
			print('Record')
			transport.record()
			event.handled = True

		elif event.data1 == button["pattern_down"]:
			if ui.getFocused(5):
				print("Previous Preset")
				ui.previous()
			else:
				print('Pattern Down')
				transport.globalTransport(midi.FPT_PatternJog, -1)
				event.handled = True
					
		elif event.data1 == button["pattern_up"]:
			if ui.getFocused(5):
				print("Next Preset")
				ui.next()
			else:
				print('Pattern Up')
				transport.globalTransport(midi.FPT_PatternJog, 1)
				event.handled = True
																	# Set mod wheel to control channels when channels focused and tracks when mixer
		elif event.data1 == button["mod_wheel"]:					
			if ui.getFocused(0):
				mixer.setTrackNumber(int(mapvalues(event.data2, 0, 64, 0, 127)))
				ui.scrollWindow(midi.widMixer, mixer.trackNumber())
			elif ui.getFocused(1):
				print("Channel Number: " + str(channels.selectedChannel()))
				channels.selectOneChannel(int(round(mapvalues(event.data2, channels.channelCount()-1, 0, 0, 127), 0)))				

		elif event.data1 == 72:
			print(channels.getChannelColor(channels.selectedChannel())) 
			Switch.color_num += 1
			if Switch.color_num == len(colors):
				Switch.color_num = 0
			if ui.getFocused(1):
				channels.setChannelColor(channels.selectedChannel(), colors[Switch.color_num])
			elif ui.getFocused(0):
				mixer.setTrackColor(mixer.trackNumber(), colors[Switch.color_num])
			event.handled = True
		
		elif event.data1 == button["enter"]:
			if ui.getFocused(4):
				print("Select Browser Item")
				ui.selectBrowserMenuItem()		
				event.handled = True
			elif ui.getFocused(1):
				print("Mute Channel")
				channels.muteChannel(channels.selectedChannel())
			elif ui.getFocused(0):
				print("Mute Track")
				mixer.muteTrack(mixer.trackNumber())
			else:
				print('enter')
				ui.enter()
				event.handled = True

		elif event.data1 in range(59, 64) and config.PATTERN_JUMP_ON:						# Sets jump to pattern
			patterns.jumpToPattern(event.data1 - 58)
			event.handled = True		

		elif event.data1 in range(75, 80) and config.PATTERN_JUMP_ON:
			patterns.jumpToPattern(event.data1 - 69)
			event.handled = True

		elif event.data1 == button["solo"]:
			print('Solo')
			if ui.getFocused(0):
				mixer.soloTrack(mixer.trackNumber())
			elif ui.getFocused(1):
				channels.soloChannel(channels.selectedChannel())

		elif event.data1 == button["view_plugin_picker"]:
			print('View Plugin Picker')
			transport.globalTransport(midi.FPT_F8, 67)
			event.handled = True	
			
		elif event.data1 == button["song_mode_toggle"]:			
			print('Toggle Song and Pattern Mode')
			transport.setLoopMode()
			event.handled = True
			
		elif event.data1 == button["view_playlist"]:			
			print('View Playlist')
			transport.globalTransport(midi.FPT_F5, 65)
			event.handled = True
			
		elif event.data1 == button["view_piano_roll"]:
			print('View Piano Roll')
			transport.globalTransport(midi.FPT_F7, 66)
			event.handled = True
		
		elif event.data1 == button["view_channel_rack"]:
			print('View Channel Rack')
			transport.globalTransport(midi.FPT_F6, 65)
			event.handled = True
			
		elif event.data1 == button["view_mixer"]:
			print('View Mixer')
			transport.globalTransport(midi.FPT_F9, 68)
			event.handled = True
																	# Toggle through step parameter options - pitch, pan etc. No Shift control right now. 
		elif event.data1 == button["step_parameter"]:
			
			if ui.getFocused(1) and Switch.mode_toggle == 1:
				print('Toggle Step Parameter')
				Switch.parameter += 1
				if Switch.parameter == 7:
					Switch.parameter = 0
				print(Switch.parameter)
				ui.setHintMsg(parameters[Switch.parameter])

			elif ui.getFocused(0):
				Switch.mixer_num += 1
				if Switch.mixer_num == 2:
					Switch.mixer_num = 0
				print('Mixer Mode: ' + str(Switch.mixer_num))
				ui.setHintMsg(mixer_choice[Switch.mixer_num])
			event.handled = True

		elif event.data1 == button["open_channel_sampler"]:			
			print('Open Sampler Channel')
			channels.showCSForm(channels.channelNumber(), -1)
			event.handled = True					
							
		elif event.data1 == button["left"]:							
			print('Left')
			ui.left()
			event.handled = True	
		
		elif event.data1 == button["down"]:							
			print('Down')
			ui.down()
			event.handled = True				
			
		elif event.data1 == button["right"]:						
			print('Right')
			ui.right()
			event.handled = True			

		elif event.data1 == button["save"]:
			print('Save')
			transport.globalTransport(midi.FPT_Save, 92)
																	# If mixer is open and mute mode selected, top row will mute respective track 
		elif event.data1 == button["undo"]:					
				print('Undo')
				transport.globalTransport(midi.FPT_Undo, 20)
				device.midiOutMsg(144, 1, 63, 80)
				event.handled = True

		elif event.data1 == button["escape"]:
			print('Escape')
			ui.escape()
			event.handled = True
		
		elif event.data1 == button["up"]:
			print('Up')
			ui.up()
			event.handled = True			

		elif event.data1 == button["rotate_window"]:				
			print('Rotate Window')
			ui.nextWindow()
			event.handled = True

		elif event.data1 == button["browser"]:				
			print('Browser')
			if Switch.shift_status == False:
				if ui.getFocused(4):
					ui.hideWindow(4)
					event.handled = True
				else:
					ui.showWindow(4)
					ui.setFocused(4)
					event.handled = True
			
		elif event.data1 == button["step_rec"]:	
			if ui.getFocused(0):
				mixer.armTrack(mixer.trackNumber())	
				print("Toggle Track Rec")
			else:			
				transport.globalTransport(midi.FPT_StepEdit, 114)
				print('Step Record')
				event.handled = True							

		elif event.data1 == button["quantize"]:
			print('quantize')
			channels.quickQuantize(channels.channelNumber())
			event.handled = True

		elif event.data1 == button["link_chan"]:
			print('link channel')
			mixer.linkTrackToChannel(0)

		elif event.data1 == button["rand_steps"]:
			print("Random")
			print(f'Pitch Bend: {event.pitchBend}')
			for i in range(patterns.getPatternLength(patterns.patternNumber())):
				channels.setGridBit(channels.channelNumber(), i, 0)
			for z in range (patterns.getPatternLength(patterns.patternNumber())):
				y = num_gen()
				if y > ( Switch.pitch_num * 516):
					channels.setGridBit(channels.channelNumber(), z, 1)
				else:
					pass
			event.handled = True

		elif event.data1 == button["rand_notes"]:
			print("Randomize Notes")
			Switch.note_gen()
			event.handled = True
Beispiel #26
0
def channelMidiNoteOn(channelNum, note, event):
	if channelNum < channels.channelCount():
		channels.midiNoteOn(channelNum, note, event.data2, -1)
Beispiel #27
0
 def OnUpdateChannel(self, delta):
     index = self.clip(0,
                       channels.channelCount() - 1,
                       channels.selectedChannel() + delta)
     self._select_one_channel(index)
Beispiel #28
0
 def _channel_with_route_to_mixer_track(self, track):
     max_channel = channels.channelCount()
     for i in range(max_channel):
         if channels.getTargetFxTrack(i) == track:
             return i
     return -1
Beispiel #29
0
def channelSelect(channelNum):
	if channelNum < channels.channelCount():
		channels.selectOneChannel(channelNum)
 def selectMixerTrackChannel(self, track_index):
     current = channels.channelNumber()
     count = channels.channelCount()
     return self.cycleChannels(
         current, count,
         lambda i: channels.getTargetFxTrack(i) == track_index)