Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
window detection. more features
Browse files Browse the repository at this point in the history
  • Loading branch information
nfxbeats committed Oct 25, 2022
1 parent c1c1c26 commit 3ecd3f4
Show file tree
Hide file tree
Showing 17 changed files with 1,266 additions and 319 deletions.
562 changes: 337 additions & 225 deletions device_FIRE-NFX.py

Large diffs are not rendered by default.

Empty file added fireNFX_Anim.py
Empty file.
108 changes: 96 additions & 12 deletions fireNFX_Classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ def clonePluginParams(srcPlugin, destPlugin):
destPlugin.assignParameterToUserKnob(KM_USER2, knob, newParam2 )
return destPlugin


cpGlobal = 0
cpChannel = 1
cpChannelPlugin = 2
cpMixer = 3
cpMixerPlugin = 4
class TnfxChannelPlugin:
def __init__(self, name, username = ""):
self.Name = name
self.PluginName = name
self.UserName = username
self.ParameterGroups = {} # { groupName: [TnfxParameters] }
self.Parameters = []
#self.GroupName = ''
Expand All @@ -45,7 +50,9 @@ def __init__(self, name, username = ""):
self.User2Knobs = []
self.isNative = False
self.AlwaysRescan = True
self.ChannelType = -1
self.FLChannelType = -1
self.PresetGroups = {}
self.Type = cpChannel
for i in range(4): # pre-allocate these to have 4 each
p = TnfxParameter(-1,'',i,'',False) # offset = -1 to identify it's unassigned
self.User1Knobs.append(p)
Expand Down Expand Up @@ -80,24 +87,74 @@ def getGroupNames(self):
def addParamToGroup(self, groupName, nfxParameter):
nfxParameter.GroupName = groupName
self.Parameters.append(nfxParameter) # add to root level Param list

if(groupName in self.ParameterGroups.keys()): # add to group
self.ParameterGroups[groupName].append(nfxParameter)
else:
self.ParameterGroups[groupName] = [nfxParameter]

def assignKnobsFromParamGroup(self, groupName):
offslist = []
for param in self.ParameterGroups[groupName]:
offslist.append(param.Offset)
if(len(offslist) > 0):
self.assignKnobs(offslist)
return True
return False

def getCurrentKnobParamOffsets(self):
u1 = []
u2 = []
res = []
for i in range(4): # pre-allocate these to have 4 each
if(self.User1Knobs[i].Offset > -1):
u1.append(self.User1Knobs[i].Offset)
if(self.User2Knobs[i].Offset > -1):
u2.append(self.User2Knobs[i].Offset)
res.extend(u1)
res.extend(u2)
return res

def assignParameterToUserKnob(self, knobMode, knobIdx, nfxParameter):
#print('ass', knobMode, knobIdx, nfxParameter.Offset )
if(4 < knobIdx < 0):
return
if(knobMode == KM_USER1):
self.User1Knobs[knobIdx] = nfxParameter
elif(knobMode == KM_USER2):
self.User2Knobs[knobIdx] = nfxParameter


def assignOffsetToUserKnob(self, usermode, knob, paramOffs):
self.assignParameterToUserKnob(usermode, knob, self.getParamFromOffset(paramOffs) )

def assignKnobsFromParamList(self, paramList):
offsetList = []
for param in paramList:
offsetList.append(param.Offset)
#print('appended offset', param.Offset)
self.assignKnobs(offsetList)

def assignKnobs(self, offsetList, PresetGroup = ''):
#print('offsets', offsetList)
res = 0
for idx, offs in enumerate(offsetList):
if idx > 7:
return idx
km = KM_USER1
ko = idx
if idx > 3:
km = KM_USER2
ko = idx - 4
if(offs < 0) or (self.getParamFromOffset(offs) == None):
self.assignParameterToUserKnob(km, ko, None)
else:
self.assignOffsetToUserKnob(km, ko, offs)
res = idx + 1
if(PresetGroup != ''):
self.PresetGroups[PresetGroup] = res
return res

class TnfxParameter:
def __init__(self, offset, caption, value, valuestr, bipolar, stepsAfterZero = 0):
def __init__(self, offset, caption, value=0, valuestr='', bipolar= False, stepsAfterZero = 0):
self.Offset = offset
self.Caption = caption
self.Value = value
Expand All @@ -106,15 +163,12 @@ def __init__(self, offset, caption, value, valuestr, bipolar, stepsAfterZero = 0
self.StepsAfterZero = stepsAfterZero
self.GroupName = ''
def __str__(self):
#0, 'Chord Type', 0, 'Movable', False
# 0, 'Chord Type', 0, 'Movable', False
return "{}, '{}', {}, '{}'".format(self.Offset, self.Caption, self.Value, self.ValueStr)
def getFullName(self):
return self.GroupName + "-" + self.Caption
def updateCaption(self, caption):
self.Caption = caption




class TnfxPadMode:
def __init__(self, name, mode, btnId = IDStepSeq, isAlt = False):
Expand All @@ -127,7 +181,6 @@ def __init__(self, name, mode, btnId = IDStepSeq, isAlt = False):
self.AllowedNavSets = [nsDefault]
self.AllowedNavSetIdx = 0
self.LayoutIdx = 0


class TnfxProgressStep:
def __init__(self, padIdx, color, songpos, abspos, barnum, selected = False):
Expand Down Expand Up @@ -163,7 +216,10 @@ def __init__(self, flIdx, name):
self.Mixer = TnfxMixer(-1, "")
self.LoopSize = 0
self.Muted = 0
self.Color = 0
self.PadAColor = 0
self.DimA = 3
self.PadBColor = 0
self.DimB = 3
self.ChannelType = -1
self.GlobalIndex = -1
self.ShowChannelEditor = -1
Expand Down Expand Up @@ -289,10 +345,11 @@ def __init__(self, padIndex, flIndex, color, tag):
self.NoteInfo = TnfxNoteInfo()

class TnfxMacro:
def __init__(self, name, color):
def __init__(self, name, color, command = None):
self.Name = name
self.PadIndex = -1
self.PadColor = color
self.Execute = command

class TnfxColorMap:
def __init__(self, padIndex, color, dimFactor):
Expand Down Expand Up @@ -328,3 +385,30 @@ def addSubItem(self, item):
break
if(not exists):
self.SubItems.append(item)

_rd3d2PotParams = {} # 'PluginName':[param1, .., paramX]
_rd3d2PotParamOffsets = {}
try:
# from native_pot_parameters import PluginParameter, native_plugin_parameters as npp
# until rd3d2 approves my submitted code I will use the local file.
from rd3d2_pot_params import PluginParameter, native_plugin_parameters as npp
if(len(npp) < 1): # no error, but no list either
print('rd3d2 Pot Parameters found, but the dictionary did not load.')
else:
print('rd3d2 Pot Parameters found. {} plugins available in the dictionary.'.format(len(npp)))
for plugin in npp.keys():
_rd3d2PotParams[plugin] = []
# for param in npp[plugin]:
# if param != None:
# bipolar = param.deadzone_centre != None
# name = param.name
# if name == '':
# name = '?'
# nfxParam = TnfxParameter(param.index, name, 0, '', bipolar)
# _rd3d2PotParams[plugin].append(nfxParam)
# _rd3d2PotParamOffsets[plugin].append(param.index)
print('rd3d2 Pot Parameters conversion. {} plugins converted.'.format(len(_rd3d2PotParams)))
except ImportError:
print('rd3d2 Pot Parameters NOT found.')# Failed to import - assume they don't have custom settings


2 changes: 2 additions & 0 deletions fireNFX_CustomPlugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# custom imports go after this line. :
from pluginSoundFontPlayer import pluginSoundFontPlayer
7 changes: 7 additions & 0 deletions fireNFX_DefaultSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def __init__(self) -> None:
# Set this to False to prevent them from auto mapping.
self.AUTO_MAP_KNOWN_PARAMS_TO_USER_KNOBS = True

self.STARTUP_TEXT_TOP = "-={ FIRE-NFX-V2 }=-"
self.STARTUP_TEXT_BOT = "Version 2.0"
self.STARTUP_FL_HINT = 'FIRE-NFX-V2 loaded.'

self.DBL_TAP_DELAY_MS = 220
self.DBL_TAP_ZOOM = 4


# DO NOT EDIT BELOW:
Settings = TnfxDefaultSettings()
Expand Down
1 change: 0 additions & 1 deletion fireNFX_Defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,3 @@ def getNonPadLightCtrls():

FLEFFECTS = 'CHAN FX'
NOSUPPTEXT = "UNSUPPORTED"

2 changes: 1 addition & 1 deletion fireNFX_Display.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def DisplayText(Font, Justification, PageTop, Text, CheckIfSame, DisplayTime = 0
screen.displayText(Font, Justification, PageTop, Text, CheckIfSame, DisplayTime)
screen.update()
except Exception as e:
print('Display Text exception: ' + str(e))
print('Display Text Exception: ' + str(e))
return

def DisplayBar3(p1, p2, Text, Value, Bipolar):
Expand Down
38 changes: 38 additions & 0 deletions fireNFX_Helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import general
from midi import *
import channels
import mixer
from older.OBS_midi import REC_SetChanged

def getCurrChanIdx(): # backwards compatibility
return channels.selectedChannel()

def SetNativeParam(offset, value):
return general.processRECEvent(offset, value, REC_SetAll) # REC_SetAll forces the refresh...

def GetNativeParam(offset):
return general.processRECEvent(offset, 0, REC_GetValue)

def SetChannelFXParam(offset, value, chanNum = -1):
if(chanNum == -1):
chanNum = channels.selectedChannel()
recEventID = channels.getRecEventId(chanNum)
return general.processRECEvent(recEventID + offset, value, REC_SetAll) # REC_SetAll forces the refresh...

def GetChannelFXParam(offset, chanNum = -1):
if(chanNum == -1):
chanNum = channels.selectedChannel()
recEventID = channels.getRecEventId(chanNum)
return general.processRECEvent(recEventID + offset, 0, REC_GetValue)

def SetMixerParam(offset, value, trkNum = -1):
if(trkNum == -1):
trkNum = mixer.trackNumber()
recEventID = channels.getRecEventId(trkNum)
return general.processRECEvent(recEventID + offset, value, REC_SetAll) # REC_SetAll forces the refresh...

def GetMixerParam(offset, trkNum = -1):
if(trkNum == -1):
trkNum = getCurrChanIdx()
recEventID = channels.getRecEventId(trkNum)
return general.processRECEvent(recEventID + offset, 0, REC_GetValue)
67 changes: 67 additions & 0 deletions fireNFX_Macros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from midi import *
import transport
import ui
import general
from fireNFX_Classes import TnfxMacro
from fireNFX_Colors import *
from fireNFX_DefaultSettings import Settings
from fireNFX_Utils import getShade, shDark, shDim, shLight, shNorm, NavigateFLMenu

# code for macros
def Undo():
if(Settings.UNDO_STYLE == 0):
general.undoUp()
else:
general.undo()

def ZoomSelection(zoomVal = Settings.DBL_TAP_ZOOM):
zStr = 'DDDDDDDD'[0:zoomVal]
print("[{}]".format(zStr))
NavigateFLMenu(',DRDDDDDR,DD,{}E'.format(zStr) )

def Articulate():
NavigateFLMenu(',R,DR,DDDE')

def QuickQuantize():
NavigateFLMenu(',R,DR,DDDDE')

def ShowScriptOutputWindow():
ui.showWindow(widChannelRack) # make CR the active window so it pulls up the main menu
NavigateFLMenu(',LLLLDDDDDDDDDDE') # series of keys to pass

def CloseAll():
transport.globalTransport(FPT_F12, 1) # close all...
if(Settings.REOPEN_WINDOWS_AFTER_CLOSE_ALL):
ui.showWindow(widBrowser)
ui.showWindow(widChannelRack)
ui.showWindow(widPlaylist)
ui.showWindow(widMixer)

# BUILT-IN MACROS DEFINED HERE
#
macCloseAll = TnfxMacro("Close All", getShade(cCyan, shDim), CloseAll) # special
macTogChanRack = TnfxMacro("Chan Rack", cCyan)
macTogPlaylist = TnfxMacro("Playlist", cCyan)
macTogMixer = TnfxMacro("Mixer", cCyan)
#
macUndo = TnfxMacro("Undo", getShade(cYellow, shNorm), Undo )
macCopy = TnfxMacro("Copy", getShade(cBlue, shLight), ui.copy)
macCut = TnfxMacro("Cut", getShade(cMagenta, shNorm), ui.cut )
macPaste = TnfxMacro("Paste", getShade(cGreen, shLight), ui.paste)
#
macShowScriptWindow = TnfxMacro("Script Window", cWhite, ShowScriptOutputWindow)
macZoom = TnfxMacro("Zoom", cWhite, ZoomSelection)
macZoom = TnfxMacro("Zoom", cWhite, ZoomSelection)
macZoom = TnfxMacro("Zoom", cWhite, ZoomSelection)


# master macro list
_MacroList = [macCloseAll, macTogChanRack, macTogPlaylist, macTogMixer,
macUndo, macCopy, macCut, macPaste ]







4 changes: 2 additions & 2 deletions fireNFX_PadDefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ def getDrumPads(isAlt, noNav, layoutIdx):
pdMacros = [ 12, 13, 14, 15, 28, 29, 30, 31]

# thx to "a candle" for the tab idea
pdShiftTab = 44
pdMenu = 44
pdEsc = 45
pdUp = 46
pdEnter = 47
pdTab = 60
pdLeft = 61
pdDown = 62
pdRight = 63
pdUDLR = [pdShiftTab, pdEsc, pdUp, pdEnter, pdTab, pdLeft, pdDown, pdRight]
pdUDLR = [pdMenu, pdEsc, pdUp, pdEnter, pdTab, pdLeft, pdDown, pdRight]

# for modes that need channel specific window control - ie Note mode, FPC, etc
pdShowChanEditor = 44
Expand Down
Loading

0 comments on commit 3ecd3f4

Please sign in to comment.