def OnUpdateTargetMixerTrack(self, delta): max_track_idx = mixer.trackCount() - 2 # One of the track is a control track prev_track = channels.getTargetFxTrack(channels.selectedChannel()) target_track = self.circular(0, max_track_idx, prev_track + delta) # Remember to unset the name of the previous pointed to track. mixer.setTrackNumber(target_track, midi.curfxMinimalLatencyUpdate) mixer.linkTrackToChannel(midi.ROUTE_ToThis) channel_idx = self._channel_with_route_to_mixer_track(prev_track) if channel_idx < 0: mixer.setTrackName(prev_track, '') elif mixer.getTrackName(prev_track) == mixer.getTrackName(target_track): mixer.setTrackName(prev_track, channels.getChannelName(channel_idx)) if target_track == 0: mixer.setTrackName(target_track, '')
def resetAllName(): if Flag_No_Sel_Names: return ui.setHintMsg("reset namePrefix") time.sleep(ST_HintMsg) for i in range(0, FL_TR_COUNT_MAX): lastName = mixer.getTrackName(i) if isSelName(lastName): mixer.setTrackName(i, lastName[5:])
def UpdateColT(self): f = self.FirstTrackT[self.FirstTrack] CurID = mixer.getTrackPluginId(mixer.trackNumber(), 0) for m in range(0, len(self.ColT)): self.ColT[m].KnobPressEventID = -1 # mixer if m == 8: self.ColT[m].TrackNum = -2 self.ColT[m].BaseEventID = midi.REC_MainVol self.ColT[m].SliderEventID = self.ColT[m].BaseEventID self.ColT[m].SliderName = 'Master Vol' else: self.ColT[m].TrackNum = midi.TrackNum_Master + ((f + m) % mixer.trackCount()) self.ColT[m].BaseEventID = mixer.getTrackPluginId(self.ColT[m].TrackNum, 0) self.ColT[m].SliderEventID = self.ColT[m].BaseEventID + midi.REC_Mixer_Vol s = mixer.getTrackName(self.ColT[m].TrackNum) self.ColT[m].SliderName = s + ' - Vol' self.ColT[m].KnobEventID = -1 self.ColT[m].KnobResetEventID = -1 self.ColT[m].KnobResetValue = midi.FromMIDI_Max >> 1 self.ColT[m].KnobName = '' self.ColT[m].KnobMode = 1 # parameter, pan, volume, off self.ColT[m].KnobCenter = -1 self.ColT[m].KnobEventID = self.ColT[m].BaseEventID + midi.REC_Mixer_Pan self.ColT[m].KnobResetEventID = self.ColT[m].KnobEventID self.ColT[m].KnobName = mixer.getTrackName( self.ColT[m].TrackNum) + ' - ' + 'Pan' # self.Flip knob & slider if self.Flip: self.ColT[m].KnobEventID, self.ColT[m].SliderEventID = utils.SwapInt(self.ColT[m].KnobEventID, self.ColT[m].SliderEventID) s = self.ColT[m].SliderName self.ColT[m].SliderName = self.ColT[m].KnobName self.ColT[m].KnobName = s self.ColT[m].KnobMode = 2 self.ColT[m].KnobCenter = -1 self.ColT[m].KnobResetValue = round(12800 * midi.FromMIDI_Max / 16000) self.ColT[m].KnobResetEventID = self.ColT[m].KnobEventID self.ColT[m].LastValueIndex = 48 + m * 6 self.ColT[m].Peak = 0 self.ColT[m].ZPeak = False self.UpdateCol(m)
def _find_data(self): prefix = self._get_pattern_name() name = mixer.getTrackName(mixer.trackCount() - 1) if name.startswith(prefix): line = name[len(prefix):] self._last_state = line return line return ''
def setPan(command, track, value): volume = getPanSend(value) mixer.setTrackPan(track, volume) action = "Set " + mixer.getTrackName(track) + " pan to " + getPanValue( value) if processorhelpers.didSnap(processorhelpers.toFloat(value, -1), internal.consts.MIXER_PAN_SNAP_TO): action += " [Snapped]" command.handle(action)
def setVolume(command, track, value): volume = getVolumeSend(value) mixer.setTrackVolume(track, volume) action = "Set " + mixer.getTrackName( track) + " volume to " + getVolumeValue(value) if processorhelpers.didSnap(processorhelpers.toFloat(value), internal.consts.MIXER_VOLUME_SNAP_TO): action += " [Snapped]" command.handle(action)
def selectActivArea(goTo): #mark the 8 tracks that are controlled if Flag_No_Sel_Names: return x = NK_NrOf_ControlGr #8 if goTo + NK_NrOf_ControlGr > FL_TR_COUNT_MAX: goL_Delta = (goTo + NK_NrOf_ControlGr - FL_TR_COUNT_MAX) x = x - goL_Delta for i in range(goTo, goTo + x): orgName = mixer.getTrackName(i) mixer.setTrackNumber(i, 1) if isSelName(orgName) == False: mixer.setTrackName(i, lsSelTrackNames[i - goTo] + orgName[0:])
def UpdateTextDisplay(self): s1 = '' for m in range(0, len(self.ColT) - 1): s = '' s = mixer.getTrackName(self.ColT[m].TrackNum, 6) for n in range(1, 7 - len(s) + 1): s = s + ' ' s1 = s1 + s self.TempMsgT[0] = s1 if self.CurMeterMode == 0: if self.TempMsgCount == 0: self.UpdateTempMsg() else: self.SendMsg(s1, 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)
def OnMidiMsg(self, event): #print('senderId', event.senderId) if (event.midiId == midi.MIDI_CONTROLCHANGE): if (event.midiChan == 0): event.inEv = event.data2 if event.inEv >= 0x40: event.outEv = -(event.inEv - 0x40) else: event.outEv = event.inEv # knobs if event.data1 in [0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17]: r = utils.KnobAccelToRes2(event.outEv) #todo outev signof Res = r * (1 / (40 * 2.5)) self.SetKnobValue(event.data1 - 0x10, event.outEv, Res) event.handled = True else: event.handled = False # for extra CCs in emulators else: event.handled = False # for extra CCs in emulators elif event.midiId == midi.MIDI_PITCHBEND: # pitch bend (faders) if event.midiChan <= 8: event.inEv = event.data1 + (event.data2 << 7) event.outEv = (event.inEv << 16) // 16383 event.inEv -= 0x2000 if self.ColT[event.midiChan].SliderEventID >= 0: # slider (mixer track volume) event.handled = True mixer.automateEvent(self.ColT[event.midiChan].SliderEventID, self.AlphaTrack_SliderToLevel(event.inEv + 0x2000), midi.REC_MIDIController, self.SmoothSpeed) # hint n = mixer.getAutoSmoothEventValue(self.ColT[event.midiChan].SliderEventID) s = mixer.getEventIDValueString(self.ColT[event.midiChan].SliderEventID, n) if s != '': s = ': ' + s self.OnSendTempMsg(self.ColT[event.midiChan].SliderName + s, 500) elif (event.midiId == midi.MIDI_NOTEON) | (event.midiId == midi.MIDI_NOTEOFF): # NOTE if event.midiId == midi.MIDI_NOTEON: if (event.pmeFlags & midi.PME_FromScript != 0): if event.data1 == 0x7F: self.SetFirstTrack(event.data2) # slider hold if event.data1 in [0x68, 0x69, 0x70]: self.SliderHoldCount += -1 + (int(event.data2 > 0) * 2) if (event.pmeFlags & midi.PME_System != 0): if (event.data1 == 0x2E) | (event.data1 == 0x2F): # mixer bank if event.data2 > 0: self.SetFirstTrack(self.FirstTrackT[self.FirstTrack] - 8 + int(event.data1 == 0x2F) * 16) elif (event.data1 == 0x30) | (event.data1 == 0x31): if event.data2 > 0: self.SetFirstTrack(self.FirstTrackT[self.FirstTrack] - 1 + int(event.data1 == 0x31) * 2) elif event.data1 == 0x32: # self.Flip if event.data2 > 0: self.Flip = not self.Flip self.UpdateColT() self.UpdateLEDs() elif event.data1 in [0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27]: # knob reset if event.data2 > 0: n = event.data1 - 0x20 self.SetKnobValue(n, midi.MaxInt) if (event.pmeFlags & midi.PME_System_Safe != 0): if event.data1 == 0x47: # link selected channels to current mixer track if event.data2 > 0: if self.Shift: mixer.linkTrackToChannel(midi.ROUTE_StartingFromThis) else: mixer.linkTrackToChannel(midi.ROUTE_ToThis) elif (event.data1 >= 0x18) & (event.data1 <= 0x1F): # select mixer track if event.data2 > 0: i = event.data1 - 0x18 ui.showWindow(midi.widMixer) mixer.setTrackNumber(self.ColT[i].TrackNum, midi.curfxScrollToMakeVisible | midi.curfxMinimalLatencyUpdate) elif (event.data1 >= 0x8) & (event.data1 <= 0xF): # solo if event.data2 > 0: i = event.data1 - 0x8 self.ColT[i].solomode = midi.fxSoloModeWithDestTracks if self.Shift: Include(self.ColT[i].solomode, midi.fxSoloModeWithSourceTracks) mixer.soloTrack(self.ColT[i].TrackNum, midi.fxSoloToggle, self.ColT[i].solomode) mixer.setTrackNumber(self.ColT[i].TrackNum, midi.curfxScrollToMakeVisible) elif (event.data1 >= 0x10) & (event.data1 <= 0x17): # mute if event.data2 > 0: mixer.enableTrack(self.ColT[event.data1 - 0x10].TrackNum) elif (event.data1 >= 0x0) & (event.data1 <= 0x7): # arm if event.data2 > 0: mixer.armTrack(self.ColT[event.data1].TrackNum) if mixer.isTrackArmed(self.ColT[event.data1].TrackNum): self.OnSendTempMsg(mixer.getTrackName(self.ColT[event.data1].TrackNum) + ' recording to ' + mixer.getTrackRecordingFileName(self.ColT[event.data1].TrackNum), 2500) else: self.OnSendTempMsg(mixer.getTrackName(self.ColT[event.data1].TrackNum) + ' unarmed') event.handled = True else: event.handled = False else: event.handled = False
def resetTrackName(event, lastIdx): if Flag_No_Sel_Names: return for i in range(lastIdx, lastIdx + 8): lastName = mixer.getTrackName(i) if isSelName(lastName): mixer.setTrackName(i, lastName[5:])
def getMixerTrackName(trackNum): if trackNum < 0: trackNum = 126 if trackNum > 126: trackNum = 0 return mixer.getTrackName(trackNum) + " (" + str(trackNum) + ")"
def updateMixerTracks(dataType: str, selectedTrack: int): """ Given the number of the selected track number on the mixer, it is able to know which track group should render into the screen device and bulk reports their information. ### Parameters - dataType: The kind of data you are going to update (PEAK is not valid. Use `updatePeak()` instead) - trackNumber: The number of the track that is currently selected, going from 0 to 125. `mixer.trackNumber()` can be used directly to fill the argument. """ # Uses the function to know which track group the current track belongs to and truncates the value to get the exact number trackGroup = math.trunc(1 / 8 * selectedTrack) # Multiplies the trackGroup to 8 to get the index of the first track that has to be shown trackFirst = trackGroup * 8 # If the selected track belongs to the 16th group, it will declare the last two tracks as non existant # Otherwise, it will declare all as existant if trackGroup == 15: nihia.mixerSendInfo("EXIST", 0, value=1) nihia.mixerSendInfo("EXIST", 1, value=1) nihia.mixerSendInfo("EXIST", 2, value=1) nihia.mixerSendInfo("EXIST", 3, value=1) nihia.mixerSendInfo("EXIST", 4, value=1) nihia.mixerSendInfo("EXIST", 5, value=1) nihia.mixerSendInfo("EXIST", 6, value=0) nihia.mixerSendInfo("EXIST", 7, value=0) else: for x in range(trackFirst, trackFirst + 8): nihia.mixerSendInfo("EXIST", x - trackFirst, value=1) # In case the group track is the 15th one, it will limit the declaration of tracks to 7 if trackGroup == 15: trackLimit = trackFirst + 7 elif trackGroup != 15: trackLimit = trackFirst + 8 # Loop that updates the info of the tracks one by one (sums the actual track number) for x in range(trackFirst, trackLimit): if dataType == "NAME": nihia.mixerSendInfo("NAME", x - trackFirst, info=mixer.getTrackName(x)) if dataType == "VOLUME": # Declares volume as minus infinite if the value is 0 if mixer.getTrackVolume(x) == 0: dB = "-oo" elif mixer.getTrackVolume(x) != 0: # Calculates the dB value of the current track -- based of a code snippet by soundwrightpro dB = (math.exp(mixer.getTrackVolume(x) * 1.25 * math.log(11)) - 1) * 0.1 dB = round(math.log10(dB) * 20, 1) dB = str(dB) + " dB" nihia.mixerSendInfo("VOLUME", x - trackFirst, info=dB) if dataType == "PAN": # Centered if math.trunc(mixer.getTrackPan(x)) == 0: nihia.mixerSendInfo("PAN", x - trackFirst, info="Centered") # Right if mixer.getTrackPan(x) > 0: nihia.mixerSendInfo( "PAN", x - trackFirst, info=str(round( (abs(mixer.getTrackPan(x)) * 100))) + "% " + "Right") # Left if mixer.getTrackPan(x) < 0: nihia.mixerSendInfo( "PAN", x - trackFirst, info=str(round( (abs(mixer.getTrackPan(x)) * 100))) + "% " + "Left") if dataType == "IS_MUTE": nihia.mixerSendInfo("IS_MUTE", x - trackFirst, value=mixer.isTrackMuted(x)) if dataType == "IS_SOLO": nihia.mixerSendInfo("IS_SOLO", x - trackFirst, value=mixer.isTrackSolo(x)) if dataType == "SELECTED": nihia.mixerSendInfo("SELECTED", x - trackFirst, value=mixer.isTrackSelected(x)) if dataType == "VOLUME_GRAPH": nihia.mixerSetGraph(x - trackFirst, "VOLUME", mixer.getTrackVolume(x)) if dataType == "PAN_GRAPH": nihia.mixerSetGraph(x - trackFirst, "PAN", mixer.getTrackPan(x)) # Checks the track group once more to clean up the last two tracks if trackGroup == 15: if dataType == "NAME": nihia.mixerSendInfo("NAME", 6, info="") nihia.mixerSendInfo("NAME", 7, info="") # Track 7 --> Current if dataType == "VOLUME": nihia.mixerSendInfo("VOLUME", 6, info=" ") nihia.mixerSendInfo("VOLUME", 7, info=" ") if dataType == "PAN": nihia.mixerSendInfo("PAN", 6, info=" ") nihia.mixerSendInfo("PAN", 7, info=" ") if dataType == "IS_MUTE": nihia.mixerSendInfo("IS_MUTE", 6, value=0) nihia.mixerSendInfo("IS_MUTE", 7, value=0) if dataType == "IS_SOLO": nihia.mixerSendInfo("IS_SOLO", 6, value=0) nihia.mixerSendInfo("IS_SOLO", 7, value=0) if dataType == "VOLUME_GRAPH": nihia.mixerSetGraph(6, "VOLUME", 0) nihia.mixerSetGraph(7, "VOLUME", 0) if dataType == "PAN_GRAPH": nihia.mixerSetGraph(6, "PAN", 0) nihia.mixerSetGraph(7, "PAN", 0)
def onMixerTrackButton(self, control, event): if control == controls.mixerTrackNext: selected_track = self.moveSelectedMixerTrack(1) elif control == controls.mixerTrackPrevious: selected_track = self.moveSelectedMixerTrack(-1) self.lcdText(mixer.getTrackName(selected_track))
def getName(self): return mixer.getTrackName(self.index)