Skip to content

Commit

Permalink
refactors, prep for mixer effects mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
nfxbeats committed Dec 11, 2022
1 parent 59066bd commit eaa8553
Show file tree
Hide file tree
Showing 9 changed files with 732 additions and 244 deletions.
465 changes: 319 additions & 146 deletions device_FIRE-NFX.py

Large diffs are not rendered by default.

39 changes: 34 additions & 5 deletions fireNFX_Classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, name, username = "", type = cpChannelPlugin):
self.FLChannelType = -1
self.PresetGroups = {}
self.Type = type
self.ParamPadMaps = []
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 All @@ -64,11 +65,15 @@ def copy(self):
return newPlugin

def getID(self):
chanName= channels.getChannelName(channels.selectedChannel())
chanName = channels.getChannelName(channels.selectedChannel())
number = channels.selectedChannel()
if(self.Type == cpMixerPlugin):
number = mixer.trackNumber()
chanName = mixer.getTrackName(number)
presetName = "NONE"
if(plugins.isValid(channels.selectedChannel())):
presetName = plugins.getName(channels.selectedChannel(), -1, 6, -1)
return "{}-{}-{}".format(self.PluginName, chanName, presetName)
return "{}-{}-{}-{}".format(self.PluginName, chanName, presetName, number)

def getParamNamesForGroup(self, groupName):
params = []
Expand Down Expand Up @@ -186,18 +191,18 @@ def isTempNavSet(self):
return self.NavSet.NavSetID in self.TempNavSets

def SetNavSet(self, navSet):
if(navSet not in self.TempNavSets) and (navSet != self.NavSet.NavSetID):
if(self.NavSet.NavSetID in self.AllowedNavSets):
self.NavSetHist.append(self.NavSet.NavSetID) # store current NS to recall later
if(len(self.NavSetHist) > 10):
self.NavSetHist.pop(0)
self.NavSet.SetNavSet(navSet)

def RecallPrevNavSet(self):
self.NavSet.InitData()
prevNS = self.AllowedNavSets[0] # default
if(len(self.NavSetHist) > 0):
prevNS = self.NavSetHist.pop()
self.NavSet.SetNavSet(prevNS)
self.SetNavSet(prevNS)



class TnfxProgressStep:
Expand All @@ -220,13 +225,22 @@ def __init__(self, number, name, ticks):
def __str__(self):
return "Marker #{}, {}, SongPos: {}".format(self.Number, self.Name, self.SongPosAbsTicks)

class TnfxMixerEffectSlot:
def __init__(self, slotIdx, pluginName, color = 0x000000) -> None:
self.SlotIndex = slotIdx
self.PluginName = pluginName
self.Color = color
self.Muted = False
self.MixLevel = 0

class TnfxMixer:
def __init__(self, flIdx):
self.FLIndex = flIdx
self.Name = ''
self.Color = 0x000000
self.Muted = False
self.Selected = False
self.Effects = []
self.Update()
def __str__(self):
return "Mixer #{}.{} ({}) Muted:{}, Selected:{}".format(self.FLIndex, self.Name, self.Color, self.Muted, self.Selected)
Expand Down Expand Up @@ -395,6 +409,21 @@ def __init__(self):
ptMacro = 5
ptNav = 6
ptProgress = 7
ptParameter = 8

class TnfxParamPadMapping:
def __init__(self, offset, color = 0x000000, padList = []):
self.Offset = offset
self.Color = color
self.Pads = padList
def getValueFromPad(self, padIdx):
val = -1
if(padIdx in self.Pads):
size = len(self.Pads) - 1 # -1 because FL calcs this way
incby = 1 / size
val = self.Pads.index(padIdx) * incby
return val


class TnfxPadMap:
def __init__(self, padIndex, flIndex, color, tag):
Expand Down
2 changes: 2 additions & 0 deletions fireNFX_CustomPlugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

#mixer
from pluginFruityLimiter import pluginFruityLimiter
from pluginGrossBeat import pluginGrossBeat


60 changes: 33 additions & 27 deletions fireNFX_Defs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# name = FireNFX Definitions
#
# much of this is copied from the Image-Line device_Fire code
from harmonicScales import *
from fireNFX_HarmonicScales import *

# PAD Modes
MODE_PATTERNS = 0 # was MODE_STEP
Expand Down Expand Up @@ -97,6 +97,11 @@
IDPadFirst = 54
IDPadLast = 117

PAD_Count = 0
PAD_Semitone = 1 #Retrieve semitone for pad specified by padIndex
PAD_Color = 2 #Retrieve color for pad specified by padIndex


TransportCtrls = [IDPatternSong, IDPlay, IDStop, IDRec]
ShiftAltCtrls = [IDShift, IDAlt]
PadModeCtrls = [IDStepSeq, IDNote, IDDrum, IDPerform]
Expand Down Expand Up @@ -193,33 +198,34 @@ def getNonPadLightCtrls():

OctavesList = [1,2,3,4,5]

ScalesList = [
HARMONICSCALE_CHROMATIC,
#build a scales list
# ScalesList = [
# HARMONICSCALE_CHROMATIC,

# descriptions/key notes from jake @ signals music studio - https://www.youtube.com/channel/UCRDDHLvQb8HjE2r7_ZuNtWA
# Tonality KeyNote Description
HARMONICSCALE_MAJOR, # Major 7th Bright, Happy, Melodic, Joyous
HARMONICSCALE_DORIAN , # Minor 6th Mellow, Smooth, Semi-dark, Spicy
HARMONICSCALE_PHRYGIAN , # Minor 2nd Dark, Tense, Creepy, Exotic
HARMONICSCALE_LYDIAN , # Major 4th Floaty, Quirky, Sci-Fi, Spacy *Jakes fave.
HARMONICSCALE_MIXOLYDIAN , # Major 7th Bright, Upbeat, Rockish, Irish
HARMONICSCALE_AEOLIAN , # Minor 6th Dark, Rock, Sad-ish,
HARMONICSCALE_LOCRIAN , # Diminished ??? ??? (No natural fifth, hard to use)
HARMONICSCALE_MAJORPENTATONIC, # Major
HARMONICSCALE_MINORPENTATONIC, # Minor
HARMONICSCALE_BLUES,
HARMONICSCALE_HARMONICMINOR,
HARMONICSCALE_MELODICMINOR,
HARMONICSCALE_WHOLETONE,
HARMONICSCALE_DIMINISHED,
HARMONICSCALE_MAJORBEBOP,
HARMONICSCALE_DOMINANTBEBOP,
HARMONICSCALE_ENIGMATIC,
HARMONICSCALE_NEAPOLITAN,
HARMONICSCALE_NEAPOLITANMINOR,
HARMONICSCALE_HUNGARIANMINOR,
HARMONICSCALE_ARABIC,
HARMONICSCALE_JAPINSEN]
# # descriptions/key notes from jake @ signals music studio - https://www.youtube.com/channel/UCRDDHLvQb8HjE2r7_ZuNtWA
# # Tonality KeyNote Description
# HARMONICSCALE_MAJOR, # Major 7th Bright, Happy, Melodic, Joyous
# HARMONICSCALE_DORIAN , # Minor 6th Mellow, Smooth, Semi-dark, Spicy
# HARMONICSCALE_PHRYGIAN , # Minor 2nd Dark, Tense, Creepy, Exotic
# HARMONICSCALE_LYDIAN , # Major 4th Floaty, Quirky, Sci-Fi, Spacy *Jakes fave.
# HARMONICSCALE_MIXOLYDIAN , # Major 7th Bright, Upbeat, Rockish, Irish
# HARMONICSCALE_AEOLIAN , # Minor 6th Dark, Rock, Sad-ish,
# HARMONICSCALE_LOCRIAN , # Diminished ??? ??? (No natural fifth, hard to use)
# HARMONICSCALE_MAJORPENTATONIC, # Major
# HARMONICSCALE_MINORPENTATONIC, # Minor
# HARMONICSCALE_BLUES,
# HARMONICSCALE_HARMONICMINOR,
# HARMONICSCALE_MELODICMINOR,
# HARMONICSCALE_WHOLETONE,
# HARMONICSCALE_DIMINISHED,
# HARMONICSCALE_MAJORBEBOP,
# HARMONICSCALE_DOMINANTBEBOP,
# HARMONICSCALE_ENIGMATIC,
# HARMONICSCALE_NEAPOLITAN,
# HARMONICSCALE_NEAPOLITANMINOR,
# HARMONICSCALE_HUNGARIANMINOR,
# HARMONICSCALE_ARABIC,
# HARMONICSCALE_JAPINSEN]

lvlN = -2 # Never
lvlA = -1 # Always
Expand Down
151 changes: 151 additions & 0 deletions fireNFX_HarmonicScales.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# name=harmonic scales
# url=
# this is a modified and expanded version of harmonicScales.py from the original Fire script.
#

HARMONICSCALE_LAST = 0 # retain compatibility
HarmonicScaleNamesT = [] # retain compatibility
HarmonicScaleList = [] # retain compatibility

HarmonicScaleGroups = {}
HarmonicScalesLoaded = []

def addScale(scaleName, noteList, groupName = 'UNSORTED'):
global HARMONICSCALE_LAST
global HarmonicScaleNamesT
global HarmonicScaleList
HarmonicScaleList.append(noteList)
HarmonicScalesLoaded.append(noteList)
HarmonicScaleNamesT.append(scaleName)
if(groupName in HarmonicScaleGroups.keys()):
HarmonicScaleGroups[groupName].append(noteList)
else:
HarmonicScaleGroups[groupName] = [noteList]
HARMONICSCALE_LAST = len(HarmonicScaleList)-1
return HarmonicScaleNamesT[-1], HarmonicScaleList[-1], HARMONICSCALE_LAST

def GetScaleNoteCount(scale):
Result = 0
for n in range(0, 13):
if HarmonicScaleList[scale][ n] != -1:
Result += 1
return Result

def IsNoteInScale(note, scale):
c = GetScaleNoteCount(scale)
for n in range(0, c + 1):
if (note % 12) == HarmonicScaleList[scale][ n]:
return True
return False

def IsRootNote(note, scale, offset):
return ((offset - note) % 12) == HarmonicScaleList[scale][ 0]

def IsBlackKey(note):
return (note % 12) in [1, 3, 6, 8, 10]

def BuildNoteGrid(grid, sizeX, sizeY, baseNote, baseOctave, scale, rowNoteOffset = 3, bottomToTop = True):
currentNote = 0
octaveOffset = 0
nextRowNote = 0
for j in range(0, sizeY):
for i in range(0, sizeX):
if bottomToTop:
y = sizeY - j - 1
else:
y = j
grid[i][y] = baseNote + ((baseOctave + octaveOffset) * 12) + HarmonicScaleList[scale][ currentNote]
currentNote += 1
if HarmonicScaleList[scale][ currentNote] == -1:
currentNote = 0;
octaveOffset += 1

octaveOffset = 0;
nextRowNote += rowNoteOffset
currentNote = nextRowNote
if currentNote >= GetScaleNoteCount(scale):
currentNote -= GetScaleNoteCount(scale)
octaveOffset += 1

def InitScales():
# Chromatic ALWAYS needs to be first and always needs to be in the list for fireNFX to function properly.
addScale('Chromatic', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1], '')

# Define the scales chromatic offsets
# you can comment or uncomment to remove or add scales.
#
#addScale('Ionian', [0, 2, 4, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1])
addScale('Major-ION', [0, 2, 4, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1], 'Faves')
addScale('Maj-Penta', [0, 2, 4, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1], 'Faves')
addScale('Minor-AEO', [0, 2, 3, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1], 'Faves')
addScale('Min-Penta', [0, 3, 5, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1], 'Faves')
# addScale('Min-Harmonic', [0, 2, 3, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Min-Melodic', [0, 2, 3, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Whole Tone', [0, 2, 4, 6, 8, 10, -1, -1, -1, -1, -1, -1, -1])
# addScale('Diminished', [0, 2, 3, 5, 6, 8, 9, 11, -1, -1, -1, -1, -1])
# addScale('Japinsen', [0,1, 5, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Major BeBop', [0, 2, 4, 5, 7, 8, 9, 11, -1, -1, -1, -1, -1])
# addScale('Dominant BeBop', [0,2,4,5,7,9,10,11,-1,-1,-1,-1,-1])
addScale('Blues', [0, 3, 5, 6, 7, 10, -1, -1, -1, -1, -1, -1, -1])
# addScale('Arabian', [0, 2, 4, 5, 6, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('ArabicOrig', [0, 1, 4, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Enigmatic', [0, 1, 4, 6, 8, 10, 11, -1, -1, -1, -1, -1, -1])
# addScale('Neopolitan', [0, 1, 3, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('NeopolitanOrig', [0, 1, 3, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Neap. Minor', [0, 1, 3, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('Neap. Minor Orig', [0, 1, 3, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
addScale('Gypsy', [0, 2, 3, 6, 7, 8, 11, -1, -1, -1, -1, -1, -1], 'Ethnic')
# addScale('DORIAN', [0, 2, 3, 5, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('DOR #4', [0, 2, 3, 6, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('DOR B2', [0, 1, 3, 5, 6, 8, 9, -1, -1, -1, -1, -1, -1])
addScale('PHRYGIAN', [0, 1, 3, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1], 'MODES')
addScale('FLAM PHRYGIAN', [0, 1, 3, 4, 5, 7, 8, 10, -1, -1, -1, -1, -1], 'MODES')
# addScale('LYDIAN', [0, 2, 4, 6, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('LYD #9', [0, 3, 4, 6, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('LYD B7', [0, 2, 4, 6, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('MIXO', [0, 2, 4, 5, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('MIXO B6', [0, 2, 4, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('LOCRIAN', [0, 1, 3, 5, 6, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('LOC 2', [0, 2, 3, 5, 6, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('LOC 6', [0, 1, 3, 5, 6, 9, 10, -1, -1, -1, -1, -1, -1])

# addScale('6-Tone Symmetrical', [0, 1, 4, 5, 8, 9, -1, -1, -1, -1, -1, -1, -1])
# addScale('8-Tone Spanish', [0, 1, 3, 4, 5, 6, 8, 10, -1, -1, -1, -1, -1])
# addScale('Altered', [0, 1, 3, 4, 6, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('Altered Bb7', [0, 1, 3, 4, 6, 8, 9, -1, -1, -1, -1, -1, -1])
# addScale('Augm. Ionian', [0, 2, 4, 5, 8, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Augm. Lydian', [0, 2, 4, 6, 8, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Augmented', [0, 3, 4, 7, 8, 11, -1, -1, -1, -1, -1, -1, -1])
# addScale('Balinese', [0, 1, 3, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Byzantine', [0, 1, 4, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Chinese', [0, 4, 6, 7, 11, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Dim. Half-Wholetone', [0, 1, 3, 4, 6, 7, 9, 10, -1, -1, -1, -1, -1])
# addScale('Dim. Lydian', [0, 2, 3, 6, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Dim. Whole-Halftone', [0, 2, 3, 5, 6, 8, 9, 11, -1, -1, -1, -1, -1])
# addScale('Double Harmonic', [0, 1, 4, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Egyptian', [0, 2, 5, 7, 10, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Hindu', [0, 2, 4, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('Hirajoshi', [0, 2, 3, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Hungarian Major', [0, 3, 4, 6, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('Ichikosucho', [0, 2, 4, 5, 6, 7, 9, 11, -1, -1, -1, -1, -1])
# addScale('Kumoi', [0, 2, 3, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Leading Whole Tone', [0, 2, 4, 6, 8, 10, 11, -1, -1, -1, -1, -1, -1])
# addScale('Major Phrygian', [0, 1, 4, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('Minor Lydian', [0, 2, 4, 6, 7, 8, 10, -1, -1, -1, -1, -1, -1])

# addScale('Mohammedan', [0, 2, 3, 5, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Mongolian', [0, 2, 4, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Natural Minor', [0, 2, 3, 5, 7, 8, 10, -1, -1, -1, -1, -1, -1])
# addScale('Neap. Major', [0, 1, 3, 5, 7, 9, 11, -1, -1, -1, -1, -1, -1])
# addScale('Overtone', [0, 2, 4, 6, 7, 9, 10, -1, -1, -1, -1, -1, -1])
# addScale('Pelog', [0, 1, 3, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1])
# addScale('Persian', [0, 1, 4, 5, 6, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Prometheus', [0, 2, 4, 6, 9, 10, -1, -1, -1, -1, -1, -1, -1])
# addScale('Prometheus Neap.', [0, 1, 4, 6, 9, 10, -1, -1, -1, -1, -1, -1, -1])
# addScale('Purvi Theta', [0, 1, 4, 6, 7, 8, 11, -1, -1, -1, -1, -1, -1])
# addScale('Todi Theta', [0, 1, 3, 6, 7, 8, 11, -1, -1, -1, -1, -1, -1])


InitScales()
print('{} scales loaded.'.format(len(HarmonicScaleList)))

Loading

0 comments on commit eaa8553

Please sign in to comment.