def OnInit(self):
     if device.isAssigned():
         self.sysex(IMPULSE_INIT)
         self.encoderSwitcher.set(EncoderMode.Mixer)
         self.faderSwitcher.set(FaderMode.Mixer)
         self.lcdText(ui.getProgTitle())
         device.setHasMeters()
Beispiel #2
0
	def OnIdle(self):

		# refresh meters
		if device.isAssigned():
			f = False
			for m in range(0,  len(self.ColT) - 1):
				self.ColT[m].Tag = utils.Limited(self.ColT[m].Peak, 0, self.MeterMax)
				self.ColT[m].Peak = 0
				if self.ColT[m].Tag == 0:
					if self.ColT[m].ZPeak:
						continue
					else:
						self.ColT[m].ZPeak = True
				else:
					self.ColT[m].ZPeak = f
				device.midiOutMsg(midi.MIDI_CHANAFTERTOUCH + (self.ColT[m].Tag << 8) + (m << 12))

		# temp message
		if self.TempMsgDirty:
			self.UpdateTempMsg()
			self.TempMsgDirty = False

		if (self.TempMsgCount > 0) & (self.SliderHoldCount <= 0)  & (not ui.isInPopupMenu()):
			self.TempMsgCount -= 1
			if self.TempMsgCount == 0:
				self.UpdateTempMsg()
Beispiel #3
0
def OnInit():
    """Function called when script starts"""
    if device.isAssigned():
        print("Device assigned - ver 1.54")
        print(device.getName())
        print(f"Port Number: {device.getPortNumber()}")
    else:
        print("Not assigned - ver 1.54")
Beispiel #4
0
	def UpdateMeterMode(self):

		# force vertical (activity) meter mode for free controls page
		self.CurMeterMode = self.MeterMode

		if device.isAssigned():
			#clear peak indicators
			for m in range(0, len(self.ColT) - 1):
				device.midiOutMsg(midi.MIDI_CHANAFTERTOUCH + (0xF << 8) + (m << 12))
			# disable all meters
			for m in range (0, 8):
				device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x20, m, 0, 0xF7]))

		# reset stuff
		if self.CurMeterMode > 0:
			self.TempMsgCount = -1
		else:
			self.TempMsgCount = 500 // 48 + 1

		self.EmptyLastMsgT()
		self.MeterMax = 0xD + int(self.CurMeterMode == 1) # $D for horizontal, $E for vertical meters
		self.ActivityMax = 0xD - int(self.CurMeterMode == 1) * 6

		# meter split marks
		if self.CurMeterMode == 0:
			s2 = '';
			for m in range(0, len(self.ColT) - 1):
				s2 = s2 + '      .'
			self.SendMsg(s2, 1);
		else:
			self.UpdateTextDisplay()

		if device.isAssigned():
			# horizontal/vertical meter mode
			device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x21, int(self.CurMeterMode > 0), 0xF7]))

			# enable all meters
			if self.CurMeterMode == 2:
				n = 1
			else:
				n = 1 + 2;
			for m  in range(0, 8):
				device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x20, m, n, 0xF7]))
Beispiel #5
0
     def UpdateLEDs(self):

        if device.isAssigned():
            playstatus = [transport.isPlaying()]
            recstatus = [transport.isRecording()]
            loopstatus = [transport.getLoopMode()]
            metrostatus = [ui.isMetronomeEnabled()]
            prestatus = [ui.isPrecountEnabled()]
            quanstatus = [ui.getSnapMode()]
            mutestatusc = [channels.isChannelMuted(0)]
            solostatusc = [channels.isChannelSolo(0)]
            mutestatusm = [mixer.isTrackEnabled(mixer.trackNumber())]
            solostatusm = [mixer.isTrackSolo(mixer.trackNumber())]

            for a in playstatus:
              if a == 0: #not playing
                  KompleteDataOut(0x14, 0x01) #stop on

              elif a == 1: #playing
                  KompleteDataOut(0x14, 0x00) #stop off

            for b in recstatus:
               if b == 0: #not recording
                  KompleteDataOut(0x12, 0x00)

               elif b == 1: #recording
                  KompleteDataOut(0x12, 0x01)

            for c in loopstatus:
               if c == 0: #loop mood
                  KompleteDataOut(0x16, 0x00)

               elif c == 1: #playlist mode
                  KompleteDataOut(0x16, 0x01)

            for d in metrostatus:
               if d == 0: #metro off
                  KompleteDataOut(0x17, 0x00)

               elif d == 1: #metro on
                  KompleteDataOut(0x17, 0x01)

            for e in prestatus:
              if e == 0: #pre count on
                  KompleteDataOut(0x13, 0x00) 

              elif e == 1: #pre count off
                  KompleteDataOut(0x13, 0x01) 

            for f in quanstatus:
              if f == 3: #quantize off
                  KompleteDataOut(0x22, 0x00)

              elif f != 1: #quantize on
                  KompleteDataOut(0x22, 0x01)
Beispiel #6
0
	def UpdateLEDs(self):

		if device.isAssigned():
			r = transport.isRecording()
			b = 0
			for m in range(0,  mixer.trackCount()):
			  if mixer.isTrackArmed(m):
			    b = 1 + int(r)
			    break

			device.midiOutNewMsg((0x73 << 8) + midi.TranzPort_OffOnBlinkT[b], 16)
Beispiel #7
0
 def updateLED(self, control, color=None, animation=0):
     if device.isAssigned():
         control_type, control_name, control_id, control_note_or_color = control.split(
             ".")
         control_id = int(control_id)
         control_note_or_color = int(control_note_or_color)
         isRGB = bool(control_note_or_color)
         if color is None:
             if isRGB:
                 color = COLORS.RGB.DARK_GRAY
             else:
                 color = COLORS.BW.DARK_GRAY
         status = midi.MIDI_CONTROLCHANGE + animation if control_type == "Button" else midi.MIDI_NOTEON + animation
         data1 = eval(f"{hex(control_id)} << 8")
         data2 = eval(f"{hex(color)} << 16")
         device.midiOutMsg(status + data1 + data2)
Beispiel #8
0
	def UpdateCol(self, Num):

		data1 = 0
		data2 = 0
		baseID = 0
		center = 0
		b = False

		if device.isAssigned():
			sv = mixer.getEventValue(self.ColT[Num].SliderEventID)

			if Num < 8:
				# V-Pot
				center = self.ColT[Num].KnobCenter
				if self.ColT[Num].KnobEventID >= 0:
					m = mixer.getEventValue(self.ColT[Num].KnobEventID, midi.MaxInt, False)
					if center < 0:
						if self.ColT[Num].KnobResetEventID == self.ColT[Num].KnobEventID:
							center = int(m !=  self.ColT[Num].KnobResetValue)
						else:
							center = int(sv !=  self.ColT[Num].KnobResetValue)

					if self.ColT[Num].KnobMode < 2:
						data1 = 1 + round(m * (10 / midi.FromMIDI_Max))
					else:
						data1 = round(m * (11 / midi.FromMIDI_Max))
					if self.ColT[Num].KnobMode > 3:
						data1 = (center << 6)
					else:
						data1 = data1 + (self.ColT[Num].KnobMode << 4) + (center << 6)
				else:
					Data1 = 0

				device.midiOutNewMsg(midi.MIDI_CONTROLCHANGE + ((0x30 + Num) << 8) + (data1 << 16), self.ColT[Num].LastValueIndex)

				# arm, solo, mute
				device.midiOutNewMsg( ((0x00 + Num) << 8) + midi.TranzPort_OffOnBlinkT[int(mixer.isTrackArmed(self.ColT[Num].TrackNum)) * (1 + int(transport.isRecording()))], self.ColT[Num].LastValueIndex + 1)
				device.midiOutNewMsg( ((0x08 + Num) << 8) + midi.TranzPort_OffOnT[mixer.isTrackSolo(self.ColT[Num].TrackNum)], self.ColT[Num].LastValueIndex + 2)
				device.midiOutNewMsg( ((0x10 + Num) << 8) + midi.TranzPort_OffOnT[not mixer.isTrackEnabled(self.ColT[Num].TrackNum)], self.ColT[Num].LastValueIndex + 3)

			# slider
			data1 = self.AlphaTrack_LevelToSlider(sv)
			data2 = data1 & 127
			data1 = data1 >> 7
			device.midiOutNewMsg(midi.MIDI_PITCHBEND + Num + (data2 << 8) + (data1 << 16), self.ColT[Num].LastValueIndex + 5)

			Dirty = False
Beispiel #9
0
	def OnDeInit(self):

		if device.isAssigned():

			for m in range(0, 8):
				device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x20, m, 0, 0xF7]))

			if ui.isClosing():
				self.SendMsg(ui.getProgTitle() + ' session closed at ' + time.ctime(time.time()), 0)
			else:
				self.SendMsg('')

			self.SendMsg('', 1)
			self.SendAssignmentMsg('  ')
			self.EmptyLastMsgT()

		print('OnDeInit ready')
Beispiel #10
0
	def OnInit(self):

		self.FirstTrackT[0] = 1
		self.FirstTrack = 0
		self.SmoothSpeed = 469
		self.Clicking = True

		device.setHasMeters()
		for m in range (0, len(self.FreeCtrlT)):
			self.FreeCtrlT[m] = 8192 # default free faders to center
		if device.isAssigned():
			for x in range(0, 8):
				device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x0C, 1, 0xF7]))

		self.SetBackLight(2) # backlight timeout to 2 minutes
		self.UpdateClicking()
		self.UpdateMeterMode()

		self.SetPage()
		self.OnSendTempMsg('Linked to ' + ui.getProgTitle() + ' (' + ui.getVersion() + ')', 2000);
		print('OnInit ready')
Beispiel #11
0
	def SetBackLight(self, Minutes): # set backlight timeout (0 should switch off immediately, but doesn't really work well)

		if device.isAssigned():
			device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x0B, Minutes, 0xF7]))
Beispiel #12
0
	def UpdateClicking(self): # switch self.Clicking for transport buttons

		if device.isAssigned():
			device.midiOutSysex(bytes([0xF0, 0x00, 0x00, 0x66, 0x15, 0x0A, int(self.Clicking), 0xF7]))
    def OnRefresh(self, flags):

        if device.isAssigned():
            print("On Refresh")

            i = mixer.trackNumber()

            Volume = mixer.getTrackVolume(i)
            sVol = self.scaleValue(Volume, 1, 127)
            self.UpdateKnobs(self.KNOB.VOL, sVol)
            self.UpdateLEDs(self.KNOB.VOL, self.COLOR.BRIGHT_GREEN,
                            self.ANI.SOLID)

            Pan = 1 + (mixer.getTrackPan(i))
            sPan = self.scaleValue(Pan, 2, 127)
            self.UpdateKnobs(self.KNOB.PAN, sPan)

            if mixer.isTrackSolo(i):
                self.UpdateLEDs(self.BTN.SOLO, self.COLOR.GREEN_YELLOW,
                                self.ANI.PULSE)
            else:
                if (Pan < 1):
                    self.UpdateLEDs(self.KNOB.PAN, self.COLOR.YELLOW,
                                    self.ANI.SOLID)
                elif (Pan > 1):
                    self.UpdateLEDs(self.KNOB.PAN, self.COLOR.RED,
                                    self.ANI.SOLID)
                else:
                    self.UpdateLEDs(self.KNOB.PAN, self.COLOR.BRIGHT_GREEN,
                                    self.ANI.SOLID)

            if mixer.isTrackEnabled(i):
                self.UpdateLEDs(self.BTN.MUTE, self.COLOR.BRIGHT_GREEN,
                                self.ANI.SOLID)
            else:
                self.UpdateLEDs(self.BTN.MUTE, self.COLOR.GREEN_YELLOW,
                                self.ANI.PULSE)

            if mixer.isTrackArmed(i):
                self.UpdateLEDs(self.KNOB.VOL, self.COLOR.RED, self.ANI.PULSE)

            color = mixer.getTrackColor(i)

            if transport.isPlaying():
                self.UpdateLEDs(self.BTN.PLAY, self.COLOR.GREEN,
                                self.ANI.PULSE)
                self.UpdateLEDs(self.BTN.STOP, self.COLOR.GREEN,
                                self.ANI.SOLID)
            else:
                self.UpdateLEDs(self.BTN.PLAY, self.COLOR.DARK_BLUE,
                                self.ANI.SOLID)
                self.UpdateLEDs(self.BTN.STOP, self.COLOR.DARK_BLUE,
                                self.ANI.SOLID)

            if transport.isRecording():
                self.UpdateLEDs(self.BTN.RECORD, self.COLOR.RED,
                                self.ANI.PULSE)
            else:
                self.UpdateLEDs(self.BTN.RECORD, self.COLOR.YELLOW,
                                self.ANI.SOLID)

            if transport.getLoopMode():
                self.UpdateLEDs(self.BTN.LOOP_MODE, self.COLOR.BRIGHT_GREEN,
                                self.ANI.SOLID)
            else:
                self.UpdateLEDs(self.BTN.LOOP_MODE, self.COLOR.LIGHT_ORANGE,
                                self.ANI.SOLID)
Beispiel #14
0
	def UpdateMixer_Sel(self):

		if device.isAssigned():
			for m in range(0, len(self.ColT) - 1):
				device.midiOutNewMsg(((0x18 + m) << 8) + midi.TranzPort_OffOnT[self.ColT[m].TrackNum == mixer.trackNumber()], self.ColT[m].LastValueIndex + 4)
 def Reset(self):
     if device.isAssigned():
         device.midiOutMsg(0xB0)
         device.midiOutMsg(0x0300B0)
Beispiel #16
0
	def SendAssignmentMsg(self, Msg):

		s_ansi = Msg + chr(0) #AnsiString(Msg);
		if device.isAssigned():
			for m in range(1, 3):
				device.midiOutMsg(midi.MIDI_CONTROLCHANGE + ((0x4C - m) << 8) + (ord(s_ansi[m]) << 16))
 def OnDeInit(self):
     if device.isAssigned():
         self.sysex(IMPULSE_DEINIT)
Beispiel #18
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)))