diff --git a/compile.sh b/compile.sh index 58c8c81..25c95c0 100755 --- a/compile.sh +++ b/compile.sh @@ -146,8 +146,10 @@ for luaScript in "${luaScripts[@]}"; do includes=(common widgets modular) elif [ $luaScript == 'modular/motionSequencerInput' ]; then includes=(common widgets scales resolutions modular tableMotion) - elif [ $luaScript == 'modular/pulseTrigger' ] || [ $luaScript == 'modular/bounceTrigger' ] || [ $luaScript == 'modular/probabilityTrigger' ] || [ $luaScript == 'modular/swarmTrigger' ] || [ $luaScript == 'synths/tweaksynth' ] || [ $luaScript == 'sequencers/jumpingSequencer' ] || [ $luaScript == 'sequencers/polyphonicSequencer' ] || [ $luaScript == 'sequencers/stochasticDrumSequencer' ] || [ $luaScript == 'sequencers/stochasticSequencer' ] || [ $luaScript == 'util/randomGate' ] || [ $luaScript == 'modulators/bouncer' ] || [ $luaScript == 'modulators/randomChange' ] || [ $luaScript == 'effects/noteBouncer' ]; then + elif [ $luaScript == 'modular/pulseTrigger' ] || [ $luaScript == 'modular/bounceTrigger' ] || [ $luaScript == 'modular/probabilityTrigger' ] || [ $luaScript == 'modular/swarmTrigger' ]; then includes=(common widgets resolutions) + elif [ $luaScript == 'synths/tweaksynth' ] || [ $luaScript == 'sequencers/jumpingSequencer' ] || [ $luaScript == 'sequencers/polyphonicSequencer' ] || [ $luaScript == 'sequencers/stochasticDrumSequencer' ] || [ $luaScript == 'sequencers/stochasticSequencer' ] || [ $luaScript == 'util/randomGate' ] || [ $luaScript == 'modulators/bouncer' ] || [ $luaScript == 'modulators/randomChange' ] || [ $luaScript == 'effects/noteBouncer' ]; then + includes=(common resolutions) elif [ $luaScript == 'modular/rythmicMotionsTrigger' ] ; then includes=(common widgets resolutions tableMotion) elif [ $luaScript == 'sequencers/midiControlSequencer' ] || [ $luaScript == 'modulators/modulationSequencer' ]; then diff --git a/compiled/effects/noteBouncerCompiled.lua b/compiled/effects/noteBouncerCompiled.lua index b700f15..b2d9dac 100644 --- a/compiled/effects/noteBouncerCompiled.lua +++ b/compiled/effects/noteBouncerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/generators/generativeStrategySequencerCompiled.lua b/compiled/generators/generativeStrategySequencerCompiled.lua index fa35adf..c83e19e 100644 --- a/compiled/generators/generativeStrategySequencerCompiled.lua +++ b/compiled/generators/generativeStrategySequencerCompiled.lua @@ -2525,7 +2525,7 @@ end minResolution:changed() storeButton.changed = function(self) - table.insert(storedFragments, getFragmentState()) + table.insert(storedFragments, rythmicFragments.getFragmentState()) recallButton.enabled = true loadFragmentMenu.enabled = true loadFragmentMenu:addItem("State " .. #storedFragments) @@ -2732,7 +2732,7 @@ end function recall() -- Find the state we are to recall - setFragmentState(storedFragments[recallStoredState]) + rythmicFragments.setFragmentState(storedFragments[recallStoredState]) --print("Recalled fragments from stored state", recallStoredState) recallStoredState = nil end diff --git a/compiled/modular/pulseTriggerCompiled.lua b/compiled/modular/pulseTriggerCompiled.lua index 03f1beb..7701b46 100644 --- a/compiled/modular/pulseTriggerCompiled.lua +++ b/compiled/modular/pulseTriggerCompiled.lua @@ -722,7 +722,7 @@ local function pulse() local note = 0 while isPlaying do local duration = resolutions.getResolution(resolution) - playNote(note, velocity, beat2ms(resolutions.getPlayDuration(duration, gate))) + playNote(note, velocity, beat2ms(resolutions.getPlayDuration(duration, gate)), nil, channel) waitBeat(duration) end end diff --git a/compiled/modular/rythmicFragmentsTriggerCompiled.lua b/compiled/modular/rythmicFragmentsTriggerCompiled.lua index 731757c..34b27b3 100644 --- a/compiled/modular/rythmicFragmentsTriggerCompiled.lua +++ b/compiled/modular/rythmicFragmentsTriggerCompiled.lua @@ -1321,7 +1321,6 @@ local colours = { textColourOn = textColourOn, } ---setKeyColour(24, "FF0000") setBackgroundColour(backgroundColour) -------------------------------------------------------------------------------- @@ -1330,15 +1329,11 @@ setBackgroundColour(backgroundColour) local isPlaying = false local playIndex = 1 -local evolveFragmentProbability = 0 -local randomizeCurrentResolutionProbability = 0 -local adjustBias = 50 local channel = 1 ---local seqVelTable ---local velocityRandomization -local seqGateTable -local gateRandomization +--local seqGateTable +--local gateRandomization local numVoices = 1 +local maxVoices = 4 local playingVoices = {} local playingIndex = {} local roundCounterPerVoice = {} @@ -1347,16 +1342,28 @@ local beatResolution = 1 local recallStoredState = nil -- Holds the index of the stored fragment state to recall local storedFragments = {} -- Holds stored fragment states local partOrder = {} -- Holds the playing order of the parts +local partOrderButton +local evolveButton +local evolveFragmentProbability +local randomizeCurrentResolutionProbability +local adjustBias +local fragmentSlots = {} -------------------------------------------------------------------------------- -- Sequencer Functions -------------------------------------------------------------------------------- local function randomizeGate(gate) + if type(seqGateTable) == "nil" then + return gate + end return gem.randomizeValue(gate, seqGateTable.min, seqGateTable.max, gateRandomization.value) end local function getGate(pos) + if type(seqGateTable) == "nil" then + return 100 + end return seqGateTable:getValue(pos), gem.inc(pos, 1, seqGateTable.length) end @@ -1392,9 +1399,9 @@ local function play(voice, uniqueId, partDuration) local reverseFragment = false local fragmentRepeatCount = 0 --local velocityPos = 1 - local velocity = 64--seqVelTable:getValue(velocityPos) + local velocity = 64 local gatePos = 1 - local gate = seqGateTable:getValue(gatePos) + local gate = nil -- Start loop while playingIndex[voice] == uniqueId do roundCounterPerVoice[voice] = roundCounterPerVoice[voice] + 1 @@ -1402,7 +1409,7 @@ local function play(voice, uniqueId, partDuration) --velocity, velocityPos = getVelocity(velocityPos) gate, gatePos = getGate(gatePos) - -- TODO Param? + -- TODO Param for source per voice? -- Default is multivoice uses the fragment that corresponds to the voice local sources = nil if numVoices > 1 then @@ -1459,6 +1466,13 @@ local function play(voice, uniqueId, partDuration) end end +local function recall() + -- Find the state we are to recall + rythmicFragments.setFragmentState(storedFragments[recallStoredState]) + --print("Recalled fragments from stored state", recallStoredState) + recallStoredState = nil +end + local function playVoices(partDuration) for voice=1,numVoices do if playingVoices[voice] == false then @@ -1473,6 +1487,27 @@ local function playVoices(partDuration) end end +-- Parse the part order input +-- Format: separated by comma (use e instead of x to activate evolve). Example: 1x16,2e8,3 +-- Set the part to zero "0" to use the current state instead of loading a part +local function setPartOrder(partOrderText) + partOrder = {} -- Reset + for s in string.gmatch(partOrderText, "[^,]+") do + local evolve = type(string.find(s, "e", 1, true)) == "number" -- Check if "e" is given for evolve + local part = tonumber(string.sub(s, 1, 1)) -- Parts are 1-8, so we get the first pos in the string + local repeats = tonumber(string.sub(s, 3)) -- Get repeats from the third pos to the end - if any is set + if type(repeats) ~= "number" then + repeats = 1 + end + if type(part) == "number" then + --print("setPartOrder part, repeats, evolve", part, repeats, evolve) + table.insert(partOrder, {part=part,repeats=repeats,evolve=evolve}) + end + end + --print("#partOrder", #partOrder) + return partOrder +end + local function sequenceRunner() local previous = nil -- Previous resolution when using evolve local partOrderPos = 1 -- Position in the part order @@ -1489,7 +1524,7 @@ local function sequenceRunner() while isPlaying do print("Playing beat", beatCounter) if beatCounter == 1 then - --[[ if partOrderButton.value and #partOrder > 0 then + if partOrderButton.value and #partOrder > 0 then if partOrderRepeatCounter == 0 then -- Start new part partInfo = partOrder[partOrderPos] @@ -1501,6 +1536,7 @@ local function sequenceRunner() remainingDuration = partDuration -- If slot is already selected, deactivate so we can select it again if slotIndex > 0 then + print("slotIndex", slotIndex, type(fragmentSlots)) if fragmentSlots[slotIndex].value == true then fragmentSlots[slotIndex]:setValue(false) end @@ -1512,13 +1548,13 @@ local function sequenceRunner() partOrderRepeatCounter = partOrderRepeatCounter - 1 -- Decrement repeat counter --print("Decrementing partOrderRepeatCounter", partOrderRepeatCounter) - end ]] + end - --[[ if type(recallStoredState) == "number" then - --initVoices() + if type(recallStoredState) == "number" then + initVoices() recall() evolveButton:setValue(startEvolve) - end ]] + end --print("beatCounter, remainingDuration, partDuration", beatCounter, remainingDuration, partDuration) if type(partDuration) == "nil" or remainingDuration == partDuration or remainingDuration == 0 then @@ -1536,9 +1572,11 @@ local function sequenceRunner() beatCounter = gem.inc(beatCounter) -- Increment counter if beatCounter > beatBase then beatCounter = 1 -- Reset counter - --[[ if evolveButton.value and gem.getRandomBoolean(evolveFragmentProbability.value) then + print("type(evolveFragmentProbability)", type(evolveFragmentProbability)) + print("type(evolveButton)", type(evolveButton)) + if evolveButton.value and gem.getRandomBoolean(evolveFragmentProbability.value) then previous = rythmicFragments.evolveFragments(previous, randomizeCurrentResolutionProbability.value, adjustBias.value) - end ]] + end end end end @@ -1574,7 +1612,7 @@ rythmPanel.backgroundColour = "404040" rythmPanel.x = sequencerPanel.x rythmPanel.y = sequencerPanel.y + sequencerPanel.height + 0 rythmPanel.width = sequencerPanel.width -rythmPanel.height = 264 +rythmPanel.height = (75 - maxVoices) * maxVoices -- TODO Adjust to fit other maxVoices settings -------------------------------------------------------------------------------- -- Sequencer Options @@ -1590,7 +1628,7 @@ sequencerLabel.fontSize = 22 sequencerLabel.position = {0,0} sequencerLabel.size = {sequencerPanel.width,30} -local numVoicesInput = sequencerPanel:NumBox("NumVoices", numVoices, 1, 4, true) +local numVoicesInput = sequencerPanel:NumBox("NumVoices", numVoices, 1, maxVoices, true) numVoicesInput.displayName = "Voices" numVoicesInput.tooltip = "Number of voices" numVoicesInput.size = {90,22} @@ -1648,9 +1686,325 @@ end -- Rythm Panel -------------------------------------------------------------------------------- -paramsPerFragment = rythmicFragments.getParamsPerFragment(rythmPanel, nil, colours, 4, 18, 12) +paramsPerFragment = rythmicFragments.getParamsPerFragment(rythmPanel, nil, colours, maxVoices, 18, 12) + +--[[ local templates = { + "Action...", + "Clear all fragment settings", + "Clear fragment inputs", + "Randomize all fragment settings", + "Randomize fragment inputs", + "Randomize fragments (single)", + "Randomize fragments (slow)", + "Randomize fragments (extended)", +} +local templateMenu = rythmPanel:Menu("Templates", templates) +templateMenu.tooltip = "Randomize fragments - NOTE: Will change current settings!" +templateMenu.showLabel = false +templateMenu.height = 18 +templateMenu.width = 100 +templateMenu.x = 685 - templateMenu.width +templateMenu.y = rythmLabel.y +templateMenu.backgroundColour = menuBackgroundColour +templateMenu.textColour = widgetTextColour +templateMenu.arrowColour = menuArrowColour +templateMenu.outlineColour = menuOutlineColour +templateMenu.changed = function(self) + if self.value == 1 then + return + end + for _,v in ipairs(paramsPerFragment) do + if self.selectedText == "Clear fragment inputs" then + v.fragmentInput.text = "" + elseif self.selectedText == "Clear all fragment settings" then + v.fragmentInput.text = "" + v.fragmentPlayProbability.value = v.fragmentPlayProbability.default + v.fragmentActive.value = v.fragmentActive.default + v.fragmentRepeatProbability.value = v.fragmentRepeatProbability.default + v.fragmentRepeatProbabilityDecay.value = v.fragmentRepeatProbabilityDecay.default + v.fragmentMinRepeats.value = v.fragmentMinRepeats.default + v.reverseFragmentProbability.value = v.reverseFragmentProbability.default + v.randomizeFragmentProbability.value = v.randomizeFragmentProbability.default + v.restProbability.value = v.restProbability.default + elseif self.selectedText == "Randomize all fragment settings" then + v.fragmentInput.text = getRandomFragment(1) + v.fragmentPlayProbability.value = gem.getRandom(100) + v.fragmentActive.value = true + v.fragmentRepeatProbability.value = gem.getRandom(100) + v.fragmentRepeatProbabilityDecay.value = gem.getRandom(100) + v.fragmentMinRepeats.value = gem.getRandom(100) + v.reverseFragmentProbability.value = gem.getRandom(100) + v.randomizeFragmentProbability.value = gem.getRandom(100) + v.restProbability.value = gem.getRandom(100) + elseif self.selectedText == "Randomize fragment inputs" then + v.fragmentInput.text = getRandomFragment(1) + elseif self.selectedText == "Randomize fragments (single)" then + v.fragmentInput.text = getRandomFragment(2) + elseif self.selectedText == "Randomize fragments (extended)" then + v.fragmentInput.text = getRandomFragment(3) + elseif self.selectedText == "Randomize fragments (slow)" then + v.fragmentInput.text = getRandomFragment(4) + end + end + -- Must be last + self:setValue(1, false) +end ]] + +--- Structure - Store/recall parts, set playing order etc. --- + +local loadFragmentMenu = rythmPanel:Menu("LoadFragmentMenu", {"Load..."}) +loadFragmentMenu.enabled = false + +local storeButton = rythmPanel:Button("StoreButton") +storeButton.displayName = "Store" +storeButton.tooltip = "Store the current state of the fragments" +storeButton.width = 75 +storeButton.height = 20 +storeButton.x = 15 +storeButton.y = 220 + +local slotSpacing = 3 +local unusedSlotDefaultText = "Unused" +local actions = {"Save..."} +local slotToStoredIndex = {} -- Holds the index of the stored fragment for each slot +for i=1,8 do + local fragmentSlot = rythmPanel:OnOffButton("StoreFragmentSlot" .. i) + fragmentSlot.backgroundColourOff = backgroundColourOff + fragmentSlot.backgroundColourOn = backgroundColourOn + fragmentSlot.textColourOff = textColourOff + fragmentSlot.textColourOn = textColourOn + fragmentSlot.displayName = "" .. i + fragmentSlot.enabled = false + fragmentSlot.tooltip = unusedSlotDefaultText + fragmentSlot.width = 20 + fragmentSlot.height = storeButton.height + fragmentSlot.x = storeButton.x + storeButton.width + ((i-1) * (fragmentSlot.width + slotSpacing)) + 10 + fragmentSlot.y = storeButton.y + fragmentSlot.changed = function(self) + if self.value then + local storedIndex = slotToStoredIndex[i] + if type(storedFragments[storedIndex]) == "table" then + recallStoredState = storedIndex + --print("Set part/recallStoredState", i, recallStoredState) + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end + end + end + for j,v in ipairs(fragmentSlots) do + if j ~= i then + v:setValue(false, false) + end + end + end + table.insert(fragmentSlots, fragmentSlot) + table.insert(slotToStoredIndex, nil) + table.insert(actions, "Save to " .. i) +end + +local slotActions = rythmPanel:Menu("SlotActions", actions) +slotActions.tooltip = "Save current fragment state to the selected slot" +slotActions.showLabel = false +slotActions.height = storeButton.height +slotActions.width = 90 +slotActions.x = storeButton.x + storeButton.width + ((fragmentSlots[1].width + slotSpacing) * #fragmentSlots) + 15 +slotActions.y = storeButton.y +slotActions.backgroundColour = menuBackgroundColour +slotActions.textColour = widgetTextColour +slotActions.arrowColour = menuArrowColour +slotActions.outlineColour = menuOutlineColour +slotActions.changed = function(self) + -- 1 is the menu label... + if self.value == 1 then + return + end + + local index = self.value - 1 + + -- Save current fragment state + -- TODO Add options to remove? + if index <= #fragmentSlots then + storeButton:changed() -- Store the current state + slotToStoredIndex[index] = #storedFragments -- Set the most recent stored fragment to this slot + fragmentSlots[index].tooltip = "Part " .. index .. " - Stored state " .. slotToStoredIndex[index] + fragmentSlots[index].enabled = true + end + + -- Must be last + self:setValue(1, false) +end + +loadFragmentMenu.tooltip = "Load a stored fragment state" +loadFragmentMenu.showLabel = false +loadFragmentMenu.height = storeButton.height +loadFragmentMenu.width = slotActions.width +loadFragmentMenu.x = slotActions.x + slotActions.width + 10 +loadFragmentMenu.y = slotActions.y +loadFragmentMenu.backgroundColour = menuBackgroundColour +loadFragmentMenu.textColour = widgetTextColour +loadFragmentMenu.arrowColour = menuArrowColour +loadFragmentMenu.outlineColour = menuOutlineColour +loadFragmentMenu.changed = function(self) + -- 1 is the menu label... + if self.value == 1 then + return + end -seqGateTable = rythmPanel:Table("Velocity", 8, 90, 0, 100, true) + local index = self.value - 1 + + if type(storedFragments[index]) == "table" then + recallStoredState = index + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end + end + + -- Must be last + self:setValue(1, false) +end + +partOrderButton = rythmPanel:OnOffButton("PartOrderLabel") +partOrderButton.displayName = "Part Order" +partOrderButton.tooltip = "Activate part order" +partOrderButton.width = 60 +partOrderButton.height = 20 +partOrderButton.backgroundColourOff = backgroundColourOff +partOrderButton.backgroundColourOn = backgroundColourOn +partOrderButton.textColourOff = textColourOff +partOrderButton.textColourOn = textColourOn +partOrderButton.x = loadFragmentMenu.x + loadFragmentMenu.width + 10 +partOrderButton.y = loadFragmentMenu.y + +local partOrderInput = rythmPanel:Label("PartOrderInput") +partOrderInput.text = "" +partOrderInput.tooltip = "Set the playing order of the parts (1-8 as stored in the slots). Format separated by comma (use e instead of x to activate evolve). Example: 1x16,2e8,3" +partOrderInput.editable = true +partOrderInput.backgroundColour = "black" +partOrderInput.backgroundColourWhenEditing = "white" +partOrderInput.textColour = "white" +partOrderInput.textColourWhenEditing = "black" +partOrderInput.x = partOrderButton.x + partOrderButton.width +partOrderInput.y = partOrderButton.y +partOrderInput.width = 156 +partOrderInput.height = 20 +partOrderInput.fontSize = 15 +partOrderInput.changed = function(self) + setPartOrder(self.text) +end + +--- Evolve --- + +local recallButton = rythmPanel:Button("RecallButton") +recallButton.displayName = "Recall" +recallButton.enabled = false +recallButton.tooltip = "Recall the last stored fragment state" +recallButton.width = storeButton.width +recallButton.height = storeButton.height +recallButton.x = storeButton.x +recallButton.y = storeButton.y + storeButton.height + 10 + +evolveButton = rythmPanel:OnOffButton("EvolveActive", false) +evolveButton.backgroundColourOff = backgroundColourOff +evolveButton.backgroundColourOn = backgroundColourOn +evolveButton.textColourOff = textColourOff +evolveButton.textColourOn = textColourOn +evolveButton.displayName = "Evolve" +evolveButton.tooltip = "Activate evolve" +evolveButton.width = recallButton.width +evolveButton.height = recallButton.height +evolveButton.x = recallButton.x + recallButton.width + 10 +evolveButton.y = recallButton.y + +evolveFragmentProbability = rythmPanel:NumBox("EvolveFragmentProbability", 50, 0, 100, true) +evolveFragmentProbability.unit = Unit.Percent +evolveFragmentProbability.textColour = widgetTextColour +evolveFragmentProbability.backgroundColour = widgetBackgroundColour +evolveFragmentProbability.displayName = "Amount" +evolveFragmentProbability.tooltip = "Set the probability that fragments will change over time, using the resolutions present in the fragments" +evolveFragmentProbability.width = 105 +evolveFragmentProbability.height = recallButton.height +evolveFragmentProbability.x = evolveButton.x + evolveButton.width + 10 +evolveFragmentProbability.y = evolveButton.y + +randomizeCurrentResolutionProbability = rythmPanel:NumBox("RandomizeCurrentResolutionProbability", 0, 0, 100, true) +randomizeCurrentResolutionProbability.unit = Unit.Percent +randomizeCurrentResolutionProbability.textColour = widgetTextColour +randomizeCurrentResolutionProbability.backgroundColour = widgetBackgroundColour +randomizeCurrentResolutionProbability.displayName = "Adjust" +randomizeCurrentResolutionProbability.tooltip = "Set the probability that evolve will adjust resolutions (double, half, dot/tri), based on the resolutions present in the fragments" +randomizeCurrentResolutionProbability.width = evolveFragmentProbability.width +randomizeCurrentResolutionProbability.height = evolveFragmentProbability.height +randomizeCurrentResolutionProbability.x = evolveFragmentProbability.x + evolveFragmentProbability.width + 10 +randomizeCurrentResolutionProbability.y = evolveFragmentProbability.y + +local biasLabel = rythmPanel:Label("BiasLabel") +biasLabel.text = "Bias slow > fast" +biasLabel.tooltip = "Adjust bias: <50=more slow resolutions, >50=more fast resolutions" +biasLabel.alpha = 0.5 +biasLabel.fontSize = 15 +biasLabel.width = 95 +biasLabel.height = randomizeCurrentResolutionProbability.height +biasLabel.x = randomizeCurrentResolutionProbability.x + randomizeCurrentResolutionProbability.width + 10 +biasLabel.y = randomizeCurrentResolutionProbability.y + +adjustBias = rythmPanel:Knob("Bias", 50, 0, 100, true) +adjustBias.showLabel = false +adjustBias.showValue = false +adjustBias.displayName = "Bias" +adjustBias.tooltip = biasLabel.tooltip +adjustBias.backgroundColour = widgetBackgroundColour +adjustBias.fillColour = knobFillColour +adjustBias.outlineColour = widgetTextColour +adjustBias.width = 20 +adjustBias.height = biasLabel.height +adjustBias.x = biasLabel.x + biasLabel.width +adjustBias.y = biasLabel.y + +local minResLabel = rythmPanel:Label("MinResolutionsLabel") +minResLabel.text = "Min resolution" +minResLabel.alpha = 0.5 +minResLabel.fontSize = 15 +minResLabel.width = biasLabel.width +minResLabel.height = adjustBias.height +minResLabel.x = adjustBias.x + adjustBias.width + 10 +minResLabel.y = adjustBias.y + +local minResolution = rythmPanel:Menu("MinResolution", resolutions.getResolutionNames()) +minResolution.displayName = minResLabel.text +minResolution.tooltip = "The highest allowed resolution for evolve adjustments" +minResolution.selected = 26 +minResolution.showLabel = false +minResolution.width = 69 +minResolution.height = adjustBias.height +minResolution.backgroundColour = widgetBackgroundColour +minResolution.textColour = widgetTextColour +minResolution.arrowColour = menuArrowColour +minResolution.outlineColour = menuOutlineColour +minResolution.x = minResLabel.x + minResLabel.width +minResolution.y = minResLabel.y +minResolution.changed = function(self) + rythmicFragments.setMaxResolutionIndex(self.value) +end +minResolution:changed() + +storeButton.changed = function(self) + table.insert(storedFragments, rythmicFragments.getFragmentState()) + recallButton.enabled = true + loadFragmentMenu.enabled = true + loadFragmentMenu:addItem("State " .. #storedFragments) +end + +recallButton.changed = function(self) + recallStoredState = #storedFragments + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end +end + +--[[ seqGateTable = rythmPanel:Table("Velocity", 8, 90, 0, 100, true) seqGateTable.unit = Unit.Percent seqGateTable.tooltip = "Set gate pattern. If a gate step is set to zero, that step is muted." seqGateTable.showPopupDisplay = true @@ -1659,7 +2013,7 @@ seqGateTable.sliderColour = sliderColour seqGateTable.width = rythmPanel.width - 140 seqGateTable.height = 45 seqGateTable.x = 10 -seqGateTable.y = 210 +seqGateTable.y = rythmPanel.height - 57 local gateTableLength = rythmPanel:NumBox("GateTableLength", 8, 1, 64, true) gateTableLength.displayName = "Gate Len" @@ -1683,7 +2037,7 @@ gateRandomization.textColour = menuTextColour gateRandomization.width = gateTableLength.width gateRandomization.height = gateTableLength.height gateRandomization.x = gateTableLength.x -gateRandomization.y = gateTableLength.y + gateTableLength.height + 1 +gateRandomization.y = gateTableLength.y + gateTableLength.height + 1 ]] -------------------------------------------------------------------------------- -- Handle events @@ -1717,18 +2071,56 @@ end function onSave() local fragmentInputData = {} + local fragmentSlotsData = {} for _,v in ipairs(paramsPerFragment) do table.insert(fragmentInputData, v.fragmentInput.text) end - return {fragmentInputData} + for _,v in ipairs(fragmentSlots) do + table.insert(fragmentSlotsData, v.tooltip) + end + + return {fragmentInputData, fragmentSlotsData, storedFragments, partOrderInput.text, slotToStoredIndex} end function onLoad(data) local fragmentInputData = data[1] + local fragmentSlotsData = data[2] + storedFragments = data[3] + partOrderInput.text = tostring(data[4]) + slotToStoredIndex = data[5] + + setPartOrder(partOrderInput.text) + + if type(storedFragments) == "nil" then + storedFragments = {} + end + + if type(fragmentSlotsData) == "nil" then + fragmentSlotsData = {} + end + + if type(slotToStoredIndex) == "nil" then + slotToStoredIndex = {} + for i=1,#fragmentSlots do + table.insert(slotToStoredIndex, nil) + end + end + + recallButton.enabled = #storedFragments > 0 + + for i=1,#storedFragments do + loadFragmentMenu:addItem("State " .. i) + end + loadFragmentMenu.enabled = #storedFragments > 0 for i,v in ipairs(fragmentInputData) do paramsPerFragment[i].fragmentInput.text = v end + + for i,v in ipairs(fragmentSlotsData) do + fragmentSlots[i].tooltip = v + fragmentSlots[i].enabled = type(slotToStoredIndex[i]) == "number" + end end diff --git a/compiled/modular/sequencerInputCompiled.lua b/compiled/modular/sequencerInputCompiled.lua index 8d5b517..38b0653 100644 --- a/compiled/modular/sequencerInputCompiled.lua +++ b/compiled/modular/sequencerInputCompiled.lua @@ -568,6 +568,7 @@ local tableLength = 8 local sequencerPos = 1 local octaveRange = 1 local bipolar = true +local pitchOffsetSwapProbability = 0 widgets.setSection({ width = 720, @@ -635,11 +636,11 @@ local sequencerTable = widgets.table(tableLength, 0, { }) widgets.setSection({ - width = 120, + width = 114, yOffset = widgets.posUnder(sequencerTable) + 5, }) -local noteInput = widgets.numBox("Root", baseNote, { +local noteInput = widgets.numBox("Root Note", baseNote, { unit = Unit.MidiKey, tooltip = "Set the root note", changed = function(self) baseNote = self.value end @@ -666,6 +667,10 @@ local function setRange() else sequencerTable:setRange(0, tableRange) end + for i=1,tableLength do + sequencerTable:setValue(i, math.max(sequencerTable.min, sequencerTable:getValue(i))) + sequencerTable:setValue(i, math.min(sequencerTable.max, sequencerTable:getValue(i))) + end end widgets.numBox("Octave Range", octaveRange, { @@ -687,12 +692,25 @@ widgets.button("Bipolar", bipolar, { end }) +widgets.numBox("Offset Rand", pitchOffsetSwapProbability, { + tooltip = "Probability that the pitch offset from another step will be used", + unit = Unit.Percent, + changed = function(self) pitchOffsetSwapProbability = self.value end +}) + -------------------------------------------------------------------------------- -- Handle Events -------------------------------------------------------------------------------- local function getNote() - return baseNote + sequencerTable:getValue(sequencerPos) + local pitchOffset = 0 + if gem.getRandomBoolean(pitchOffsetSwapProbability) then + randomPos = gem.getRandom(tableLength) + pitchOffset = sequencerTable:getValue(randomPos) + else + pitchOffset = sequencerTable:getValue(sequencerPos) + end + return baseNote + pitchOffset end function onNote(e) diff --git a/compiled/modulators/bouncerCompiled.lua b/compiled/modulators/bouncerCompiled.lua index 52358cd..1447c4b 100644 --- a/compiled/modulators/bouncerCompiled.lua +++ b/compiled/modulators/bouncerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/modulators/randomChangeCompiled.lua b/compiled/modulators/randomChangeCompiled.lua index 435a22a..a81f4a2 100644 --- a/compiled/modulators/randomChangeCompiled.lua +++ b/compiled/modulators/randomChangeCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/sequencers/jumpingSequencerCompiled.lua b/compiled/sequencers/jumpingSequencerCompiled.lua index 76c80a1..455ba3c 100644 --- a/compiled/sequencers/jumpingSequencerCompiled.lua +++ b/compiled/sequencers/jumpingSequencerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/sequencers/polyphonicSequencerCompiled.lua b/compiled/sequencers/polyphonicSequencerCompiled.lua index d256e74..b3ce0d8 100644 --- a/compiled/sequencers/polyphonicSequencerCompiled.lua +++ b/compiled/sequencers/polyphonicSequencerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/sequencers/stochasticDrumSequencerCompiled.lua b/compiled/sequencers/stochasticDrumSequencerCompiled.lua index 0b43927..1abd342 100644 --- a/compiled/sequencers/stochasticDrumSequencerCompiled.lua +++ b/compiled/sequencers/stochasticDrumSequencerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- @@ -1196,7 +864,7 @@ for page=1,maxPages do local pitchRand = sequencerPanel:NumBox("PitchOffsetRandomization" .. i, 0, 0, 100, true) pitchRand.displayName = "Pitch" - pitchRand.tooltip = "Set probability pitch from another step will be used" + pitchRand.tooltip = "Probability that the pitch offset from another step will be used" pitchRand.visible = isVisible pitchRand.unit = Unit.Percent pitchRand.size = directionProbability.size diff --git a/compiled/sequencers/stochasticSequencerCompiled.lua b/compiled/sequencers/stochasticSequencerCompiled.lua index ccb9626..e8d98bc 100644 --- a/compiled/sequencers/stochasticSequencerCompiled.lua +++ b/compiled/sequencers/stochasticSequencerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/synths/tweaksynthCompiled.lua b/compiled/synths/tweaksynthCompiled.lua index 8c4fa6c..a013999 100644 --- a/compiled/synths/tweaksynthCompiled.lua +++ b/compiled/synths/tweaksynthCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/util/noteTriggerCompiled.lua b/compiled/util/noteTriggerCompiled.lua index fadc2a3..6d2c044 100644 --- a/compiled/util/noteTriggerCompiled.lua +++ b/compiled/util/noteTriggerCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- @@ -1196,7 +864,7 @@ for page=1,maxPages do local pitchRand = sequencerPanel:NumBox("PitchOffsetRandomization" .. i, 0, 0, 100, true) pitchRand.displayName = "Pitch" - pitchRand.tooltip = "Set probability pitch from another step will be used" + pitchRand.tooltip = "Probability that the pitch offset from another step will be used" pitchRand.visible = isVisible pitchRand.unit = Unit.Percent pitchRand.size = directionProbability.size diff --git a/compiled/util/randomGateCompiled.lua b/compiled/util/randomGateCompiled.lua index 8181de2..4dcac77 100644 --- a/compiled/util/randomGateCompiled.lua +++ b/compiled/util/randomGateCompiled.lua @@ -171,338 +171,6 @@ local gem = { getRandomFromTable = getRandomFromTable, } --------------------------------------------------------------------------------- --- Functions for creating an positioning widgets --------------------------------------------------------------------------------- - -local panelNameIndex = 1 -local widgetNameIndex = 1 - -local widgetDefaults = { - panel = Panel("DefaultPanel"), - width = 120, - height = 20, - menuHeight = 45, - xOffset = 0, - yOffset = 0, - xSpacing = 0, - ySpacing = 0, - col = 0, - row = 0, - cols = 6 -} - -local widgetColours = { - backgroundColour = "202020", - widgetBackgroundColour = "01011F", -- Dark - menuBackgroundColour = "01011F", -- widgetBackgroundColour - widgetTextColour = "9f02ACFE", -- Light - tableBackgroundColour = "191E25", - sliderColour = "5FB5FF", -- Table slider colour - labelTextColour = "black", -- Light - labelBackgoundColour = "CFFFFE", - menuArrowColour = "66AEFEFF", -- labelTextColour - menuOutlineColour = "5f9f02ACFE", -- widgetTextColour - menuTextColour = "9f02ACFE", - backgroundColourOff = "ff084486", - backgroundColourOn = "ff02ACFE", - textColourOff = "ff22FFFF", - textColourOn = "efFFFFFF", -} - -local function getWidgetValue(value, default) - if type(value) == "nil" then - return default - end - return value -end - -local function setColours(colours) - widgetColours.backgroundColour = getWidgetValue(colours.backgroundColour, widgetColours.backgroundColour) - widgetColours.widgetBackgroundColour = getWidgetValue(colours.widgetBackgroundColour, widgetColours.widgetBackgroundColour) - widgetColours.menuBackgroundColour = getWidgetValue(colours.menuBackgroundColour, widgetColours.menuBackgroundColour) - widgetColours.widgetTextColour = getWidgetValue(colours.widgetTextColour, widgetColours.widgetTextColour) - widgetColours.tableBackgroundColour = getWidgetValue(colours.tableBackgroundColour, widgetColours.tableBackgroundColour) - widgetColours.sliderColour = getWidgetValue(colours.sliderColour, widgetColours.sliderColour) - widgetColours.labelTextColour = getWidgetValue(colours.labelTextColour, widgetColours.labelTextColour) - widgetColours.labelBackgoundColour = getWidgetValue(colours.labelBackgoundColour, widgetColours.labelBackgoundColour) - widgetColours.menuArrowColour = getWidgetValue(colours.menuArrowColour, widgetColours.menuArrowColour) - widgetColours.menuOutlineColour = getWidgetValue(colours.menuOutlineColour, widgetColours.menuOutlineColour) - widgetColours.menuTextColour = getWidgetValue(colours.menuTextColour, widgetColours.menuTextColour) - widgetColours.backgroundColourOff = getWidgetValue(colours.backgroundColourOff, widgetColours.backgroundColourOff) - widgetColours.backgroundColourOn = getWidgetValue(colours.backgroundColourOn, widgetColours.backgroundColourOn) - widgetColours.textColourOff = getWidgetValue(colours.textColourOff, widgetColours.textColourOff) - widgetColours.textColourOn = getWidgetValue(colours.textColourOn, widgetColours.textColourOn) -end - -local function setSection(settings) - if type(settings) ~= "table" then - settings = {} - end - widgetDefaults.width = getWidgetValue(settings.width, widgetDefaults.width) - widgetDefaults.height = getWidgetValue(settings.height, widgetDefaults.height) - widgetDefaults.menuHeight = getWidgetValue(settings.menuHeight, widgetDefaults.menuHeight) - widgetDefaults.xOffset = getWidgetValue(settings.xOffset, widgetDefaults.xOffset) - widgetDefaults.yOffset = getWidgetValue(settings.yOffset, widgetDefaults.yOffset) - widgetDefaults.xSpacing = getWidgetValue(settings.xSpacing, widgetDefaults.xSpacing) - widgetDefaults.ySpacing = getWidgetValue(settings.ySpacing, widgetDefaults.ySpacing) - widgetDefaults.cols = getWidgetValue(settings.cols, widgetDefaults.cols) - widgetDefaults.col = getWidgetValue(settings.col, 0) - widgetDefaults.row = getWidgetValue(settings.row, 0) -end - -local function getWidgetName(name, panel) - if panel then - name = getWidgetValue(name, "Panel" .. panelNameIndex) - panelNameIndex = panelNameIndex + 1 - elseif type(name) == "nil" then - name = "Widget" .. widgetNameIndex - widgetNameIndex = widgetNameIndex + 1 - end - return name -end - -local function getWidgetX(options) - if type(options.x) == "number" then - return options.x - end - - -- Calculate widget x position - local col = getWidgetValue(options.col, widgetDefaults.col) - local width = col * widgetDefaults.width - local xSpacing = col * widgetDefaults.xSpacing - return widgetDefaults.xOffset + width + xSpacing -end - -local function getWidgetY(options) - if type(options.y) == "number" then - return options.y - end - - -- Calculate widget y position - local row = getWidgetValue(options.row, widgetDefaults.row) - local height = row * widgetDefaults.height - local ySpacing = row * widgetDefaults.ySpacing - return widgetDefaults.yOffset + height + ySpacing -end - -local function incrementRow(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.row = widgetDefaults.row + i - widgetDefaults.col = 0 -end - -local function incrementCol(i) - if type(i) == "nil" then - i = 1 - end - widgetDefaults.col = widgetDefaults.col + i - if widgetDefaults.col >= widgetDefaults.cols then - incrementRow() - end - --print("widgetDefaults.col, widgetDefaults.row", widgetDefaults.col, widgetDefaults.row) -end - -local function getWidgetBounds(options, increment) - local x = getWidgetX(options) - local y = getWidgetY(options) - local w = getWidgetValue(options.width, widgetDefaults.width) - local h = getWidgetValue(options.height, widgetDefaults.height) - - -- Increment col and row - if increment and options.increment ~= false then - incrementCol() - end - - return {x, y, w, h} -end - -local function getWidgetOptions(options, displayName, default, panel) - if type(options) ~= "table" then - options = {} - end - options.default = getWidgetValue(default, options.default) - options.name = getWidgetName(options.name, panel) - options.displayName = getWidgetValue(displayName, options.name) - options.tooltip = getWidgetValue(options.tooltip, options.displayName) - options.integer = getWidgetValue(options.integer, (options.unit == Unit.Percent or options.unit == Unit.MidiKey)) - options.min = getWidgetValue(options.min, 0) - options.default = getWidgetValue(options.default, options.min) - if options.unit == Unit.MidiKey then - options.max = getWidgetValue(options.max, 127) - elseif options.unit == Unit.Percent then - options.max = getWidgetValue(options.max, 100) - else - options.max = getWidgetValue(options.max, 1) - end - return options -end - -local function setOptional(widget, options) - if type(options.changed) == "function" then - widget.changed = options.changed - end - if type(options.alpha) == "number" then - widget.alpha = options.alpha - end - if type(options.fontSize) == "number" then - widget.fontSize = options.fontSize - end - if type(options.unit) == "number" then - widget.unit = options.unit - end - if type(options.showLabel) == "boolean" then - widget.showLabel = options.showLabel - end - if type(options.persistent) == "boolean" then - widget.persistent = options.persistent - end - if type(options.enabled) == "boolean" then - widget.enabled = options.enabled - end - if type(options.showPopupDisplay) == "boolean" then - widget.showPopupDisplay = options.showPopupDisplay - end - if type(options.editable) == "boolean" then - widget.editable = options.editable - end - if type(options.backgroundColour) == "string" then - widget.backgroundColour = options.backgroundColour - end - if type(options.fillStyle) == "string" then - widget.fillStyle = options.fillStyle - end - if type(options.sliderColour) == "string" then - widget.sliderColour = options.sliderColour - end -end - -local function setPanel(panel) - widgetDefaults.panel = panel -end - -local function getPanel(options) - return widgetDefaults.panel -end - -local widgets = { - channels = function() - local channels = {"Omni"} - for j=1,16 do - table.insert(channels, "" .. j) - end - return channels - end, - getColours = function() return widgetColours end, - setColours = setColours, - setPanel = setPanel, - getPanel = getPanel, - setSection = setSection, - xOffset = xOffset, - yOffset = yOffset, - xSpacing = xSpacing, - ySpacing = ySpacing, - widthDefault = widthDefault, - heightDefault = heightDefault, - posSide = posSide, - posUnder = posUnder, - xOffset = function(val) widgetDefaults.xOffset = val end, - yOffset = function(val) widgetDefaults.yOffset = val end, - xSpacing = function(val) widgetDefaults.xSpacing = val end, - ySpacing = function(val) widgetDefaults.ySpacing = val end, - posSide = function(widget) return widget.x + widget.width + widgetDefaults.xSpacing end, - posUnder = function(widget) return widget.y + widget.height + widgetDefaults.ySpacing end, - width = function(val) widgetDefaults.width = val end, - height = function(val) widgetDefaults.height = val end, - col = function(i) incrementCol(i) end, - row = function(i) incrementRow(i) end, - panel = function(options) - -- The first time, we use the default panel - local create = panelNameIndex > 1 - if create == false then - options.name = widgetDefaults.panel.name - end - options = getWidgetOptions(options, nil, nil, true) - if create then - widgetDefaults.panel = Panel(options.name) - --print("Created panel", options.name) - end - widgetDefaults.panel.backgroundColour = widgetColours.backgroundColour - widgetDefaults.panel.bounds = getWidgetBounds(options, false) - setOptional(widgetDefaults.panel, options) - return widgetDefaults.panel - end, - button = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:OnOffButton(options.name, (options.default == true)) - widget.backgroundColourOff = widgetColours.backgroundColourOff - widget.backgroundColourOn = widgetColours.backgroundColourOn - widget.textColourOff = widgetColours.textColourOff - widget.textColourOn = widgetColours.textColourOn - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - label = function(displayName, options) - options = getWidgetOptions(options, displayName) - local widget = widgetDefaults.panel:Label("Label") - widget.text = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.labelBackgoundColour - widget.textColour = widgetColours.labelTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - menu = function(displayName, default, items, options) - if type(default) == "table" then - options = items - items = default - default = nil - end - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:Menu(options.name, items) - widget.selected = options.default - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.menuBackgroundColour - widget.textColour = widgetColours.menuTextColour - widget.arrowColour = widgetColours.menuArrowColour - widget.outlineColour = widgetColours.menuOutlineColour - setOptional(widget, options) - if widget.showLabel == true then - options.height = getWidgetValue(options.height, widgetDefaults.menuHeight) - end - widget.bounds = getWidgetBounds(options, true) - return widget - end, - numBox = function(displayName, default, options) - options = getWidgetOptions(options, displayName, default) - local widget = widgetDefaults.panel:NumBox(options.name, options.default, options.min, options.max, options.integer) - widget.displayName = options.displayName - widget.tooltip = options.tooltip - widget.backgroundColour = widgetColours.widgetBackgroundColour - widget.textColour = widgetColours.widgetTextColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, - table = function(size, default, options) - options = getWidgetOptions(options, nil, default) - local widget = widgetDefaults.panel:Table(options.name, size, options.default, options.min, options.max, options.integer) - widget.fillStyle = "solid" - widget.backgroundColour = widgetColours.tableBackgroundColour - widget.sliderColour = widgetColours.sliderColour - widget.bounds = getWidgetBounds(options, true) - setOptional(widget, options) - return widget - end, -} - -------------------------------------------------------------------------------- -- Common Resolutions -------------------------------------------------------------------------------- diff --git a/compiled/util/sieveCompiled.lua b/compiled/util/sieveCompiled.lua index 39d4352..5c42c08 100644 --- a/compiled/util/sieveCompiled.lua +++ b/compiled/util/sieveCompiled.lua @@ -238,7 +238,7 @@ sieveButton.x = panel.width - 40 -------------------------------------------------------------------------------- function onNote(e) - if e.note <= noteMin.value or e.note >= noteMax.value or gem.getRandomBoolean(sieveProbability.value) then + if e.note < noteMin.value or e.note > noteMax.value or gem.getRandomBoolean(sieveProbability.value) then print("Passing through", e.note) sieveButton.backgroundColourOff = "green" postEvent(e) diff --git a/generators/generativeStrategySequencer.lua b/generators/generativeStrategySequencer.lua index 98359ab..b952e3c 100644 --- a/generators/generativeStrategySequencer.lua +++ b/generators/generativeStrategySequencer.lua @@ -899,7 +899,7 @@ end minResolution:changed() storeButton.changed = function(self) - table.insert(storedFragments, getFragmentState()) + table.insert(storedFragments, rythmicFragments.getFragmentState()) recallButton.enabled = true loadFragmentMenu.enabled = true loadFragmentMenu:addItem("State " .. #storedFragments) @@ -1106,7 +1106,7 @@ end function recall() -- Find the state we are to recall - setFragmentState(storedFragments[recallStoredState]) + rythmicFragments.setFragmentState(storedFragments[recallStoredState]) --print("Recalled fragments from stored state", recallStoredState) recallStoredState = nil end diff --git a/modular/pulseTrigger.lua b/modular/pulseTrigger.lua index 0b8a502..c5cdd01 100644 --- a/modular/pulseTrigger.lua +++ b/modular/pulseTrigger.lua @@ -25,7 +25,7 @@ local function pulse() local note = 0 while isPlaying do local duration = resolutions.getResolution(resolution) - playNote(note, velocity, beat2ms(resolutions.getPlayDuration(duration, gate))) + playNote(note, velocity, beat2ms(resolutions.getPlayDuration(duration, gate)), nil, channel) waitBeat(duration) end end diff --git a/modular/rythmicFragmentsTrigger.lua b/modular/rythmicFragmentsTrigger.lua index 4af4a30..845bd8a 100644 --- a/modular/rythmicFragmentsTrigger.lua +++ b/modular/rythmicFragmentsTrigger.lua @@ -36,7 +36,6 @@ local colours = { textColourOn = textColourOn, } ---setKeyColour(24, "FF0000") setBackgroundColour(backgroundColour) -------------------------------------------------------------------------------- @@ -45,15 +44,11 @@ setBackgroundColour(backgroundColour) local isPlaying = false local playIndex = 1 -local evolveFragmentProbability = 0 -local randomizeCurrentResolutionProbability = 0 -local adjustBias = 50 local channel = 1 ---local seqVelTable ---local velocityRandomization -local seqGateTable -local gateRandomization +--local seqGateTable +--local gateRandomization local numVoices = 1 +local maxVoices = 4 local playingVoices = {} local playingIndex = {} local roundCounterPerVoice = {} @@ -62,16 +57,28 @@ local beatResolution = 1 local recallStoredState = nil -- Holds the index of the stored fragment state to recall local storedFragments = {} -- Holds stored fragment states local partOrder = {} -- Holds the playing order of the parts +local partOrderButton +local evolveButton +local evolveFragmentProbability +local randomizeCurrentResolutionProbability +local adjustBias +local fragmentSlots = {} -------------------------------------------------------------------------------- -- Sequencer Functions -------------------------------------------------------------------------------- local function randomizeGate(gate) + if type(seqGateTable) == "nil" then + return gate + end return gem.randomizeValue(gate, seqGateTable.min, seqGateTable.max, gateRandomization.value) end local function getGate(pos) + if type(seqGateTable) == "nil" then + return 100 + end return seqGateTable:getValue(pos), gem.inc(pos, 1, seqGateTable.length) end @@ -107,9 +114,9 @@ local function play(voice, uniqueId, partDuration) local reverseFragment = false local fragmentRepeatCount = 0 --local velocityPos = 1 - local velocity = 64--seqVelTable:getValue(velocityPos) + local velocity = 64 local gatePos = 1 - local gate = seqGateTable:getValue(gatePos) + local gate = nil -- Start loop while playingIndex[voice] == uniqueId do roundCounterPerVoice[voice] = roundCounterPerVoice[voice] + 1 @@ -117,7 +124,7 @@ local function play(voice, uniqueId, partDuration) --velocity, velocityPos = getVelocity(velocityPos) gate, gatePos = getGate(gatePos) - -- TODO Param? + -- TODO Param for source per voice? -- Default is multivoice uses the fragment that corresponds to the voice local sources = nil if numVoices > 1 then @@ -174,6 +181,13 @@ local function play(voice, uniqueId, partDuration) end end +local function recall() + -- Find the state we are to recall + rythmicFragments.setFragmentState(storedFragments[recallStoredState]) + --print("Recalled fragments from stored state", recallStoredState) + recallStoredState = nil +end + local function playVoices(partDuration) for voice=1,numVoices do if playingVoices[voice] == false then @@ -188,6 +202,27 @@ local function playVoices(partDuration) end end +-- Parse the part order input +-- Format: separated by comma (use e instead of x to activate evolve). Example: 1x16,2e8,3 +-- Set the part to zero "0" to use the current state instead of loading a part +local function setPartOrder(partOrderText) + partOrder = {} -- Reset + for s in string.gmatch(partOrderText, "[^,]+") do + local evolve = type(string.find(s, "e", 1, true)) == "number" -- Check if "e" is given for evolve + local part = tonumber(string.sub(s, 1, 1)) -- Parts are 1-8, so we get the first pos in the string + local repeats = tonumber(string.sub(s, 3)) -- Get repeats from the third pos to the end - if any is set + if type(repeats) ~= "number" then + repeats = 1 + end + if type(part) == "number" then + --print("setPartOrder part, repeats, evolve", part, repeats, evolve) + table.insert(partOrder, {part=part,repeats=repeats,evolve=evolve}) + end + end + --print("#partOrder", #partOrder) + return partOrder +end + local function sequenceRunner() local previous = nil -- Previous resolution when using evolve local partOrderPos = 1 -- Position in the part order @@ -204,7 +239,7 @@ local function sequenceRunner() while isPlaying do print("Playing beat", beatCounter) if beatCounter == 1 then - --[[ if partOrderButton.value and #partOrder > 0 then + if partOrderButton.value and #partOrder > 0 then if partOrderRepeatCounter == 0 then -- Start new part partInfo = partOrder[partOrderPos] @@ -216,6 +251,7 @@ local function sequenceRunner() remainingDuration = partDuration -- If slot is already selected, deactivate so we can select it again if slotIndex > 0 then + print("slotIndex", slotIndex, type(fragmentSlots)) if fragmentSlots[slotIndex].value == true then fragmentSlots[slotIndex]:setValue(false) end @@ -227,13 +263,13 @@ local function sequenceRunner() partOrderRepeatCounter = partOrderRepeatCounter - 1 -- Decrement repeat counter --print("Decrementing partOrderRepeatCounter", partOrderRepeatCounter) - end ]] + end - --[[ if type(recallStoredState) == "number" then - --initVoices() + if type(recallStoredState) == "number" then + initVoices() recall() evolveButton:setValue(startEvolve) - end ]] + end --print("beatCounter, remainingDuration, partDuration", beatCounter, remainingDuration, partDuration) if type(partDuration) == "nil" or remainingDuration == partDuration or remainingDuration == 0 then @@ -251,9 +287,11 @@ local function sequenceRunner() beatCounter = gem.inc(beatCounter) -- Increment counter if beatCounter > beatBase then beatCounter = 1 -- Reset counter - --[[ if evolveButton.value and gem.getRandomBoolean(evolveFragmentProbability.value) then + print("type(evolveFragmentProbability)", type(evolveFragmentProbability)) + print("type(evolveButton)", type(evolveButton)) + if evolveButton.value and gem.getRandomBoolean(evolveFragmentProbability.value) then previous = rythmicFragments.evolveFragments(previous, randomizeCurrentResolutionProbability.value, adjustBias.value) - end ]] + end end end end @@ -289,7 +327,7 @@ rythmPanel.backgroundColour = "404040" rythmPanel.x = sequencerPanel.x rythmPanel.y = sequencerPanel.y + sequencerPanel.height + 0 rythmPanel.width = sequencerPanel.width -rythmPanel.height = 264 +rythmPanel.height = (75 - maxVoices) * maxVoices -- TODO Adjust to fit other maxVoices settings -------------------------------------------------------------------------------- -- Sequencer Options @@ -305,7 +343,7 @@ sequencerLabel.fontSize = 22 sequencerLabel.position = {0,0} sequencerLabel.size = {sequencerPanel.width,30} -local numVoicesInput = sequencerPanel:NumBox("NumVoices", numVoices, 1, 4, true) +local numVoicesInput = sequencerPanel:NumBox("NumVoices", numVoices, 1, maxVoices, true) numVoicesInput.displayName = "Voices" numVoicesInput.tooltip = "Number of voices" numVoicesInput.size = {90,22} @@ -363,9 +401,325 @@ end -- Rythm Panel -------------------------------------------------------------------------------- -paramsPerFragment = rythmicFragments.getParamsPerFragment(rythmPanel, nil, colours, 4, 18, 12) +paramsPerFragment = rythmicFragments.getParamsPerFragment(rythmPanel, nil, colours, maxVoices, 18, 12) + +--[[ local templates = { + "Action...", + "Clear all fragment settings", + "Clear fragment inputs", + "Randomize all fragment settings", + "Randomize fragment inputs", + "Randomize fragments (single)", + "Randomize fragments (slow)", + "Randomize fragments (extended)", +} +local templateMenu = rythmPanel:Menu("Templates", templates) +templateMenu.tooltip = "Randomize fragments - NOTE: Will change current settings!" +templateMenu.showLabel = false +templateMenu.height = 18 +templateMenu.width = 100 +templateMenu.x = 685 - templateMenu.width +templateMenu.y = rythmLabel.y +templateMenu.backgroundColour = menuBackgroundColour +templateMenu.textColour = widgetTextColour +templateMenu.arrowColour = menuArrowColour +templateMenu.outlineColour = menuOutlineColour +templateMenu.changed = function(self) + if self.value == 1 then + return + end + for _,v in ipairs(paramsPerFragment) do + if self.selectedText == "Clear fragment inputs" then + v.fragmentInput.text = "" + elseif self.selectedText == "Clear all fragment settings" then + v.fragmentInput.text = "" + v.fragmentPlayProbability.value = v.fragmentPlayProbability.default + v.fragmentActive.value = v.fragmentActive.default + v.fragmentRepeatProbability.value = v.fragmentRepeatProbability.default + v.fragmentRepeatProbabilityDecay.value = v.fragmentRepeatProbabilityDecay.default + v.fragmentMinRepeats.value = v.fragmentMinRepeats.default + v.reverseFragmentProbability.value = v.reverseFragmentProbability.default + v.randomizeFragmentProbability.value = v.randomizeFragmentProbability.default + v.restProbability.value = v.restProbability.default + elseif self.selectedText == "Randomize all fragment settings" then + v.fragmentInput.text = getRandomFragment(1) + v.fragmentPlayProbability.value = gem.getRandom(100) + v.fragmentActive.value = true + v.fragmentRepeatProbability.value = gem.getRandom(100) + v.fragmentRepeatProbabilityDecay.value = gem.getRandom(100) + v.fragmentMinRepeats.value = gem.getRandom(100) + v.reverseFragmentProbability.value = gem.getRandom(100) + v.randomizeFragmentProbability.value = gem.getRandom(100) + v.restProbability.value = gem.getRandom(100) + elseif self.selectedText == "Randomize fragment inputs" then + v.fragmentInput.text = getRandomFragment(1) + elseif self.selectedText == "Randomize fragments (single)" then + v.fragmentInput.text = getRandomFragment(2) + elseif self.selectedText == "Randomize fragments (extended)" then + v.fragmentInput.text = getRandomFragment(3) + elseif self.selectedText == "Randomize fragments (slow)" then + v.fragmentInput.text = getRandomFragment(4) + end + end + -- Must be last + self:setValue(1, false) +end ]] + +--- Structure - Store/recall parts, set playing order etc. --- + +local loadFragmentMenu = rythmPanel:Menu("LoadFragmentMenu", {"Load..."}) +loadFragmentMenu.enabled = false + +local storeButton = rythmPanel:Button("StoreButton") +storeButton.displayName = "Store" +storeButton.tooltip = "Store the current state of the fragments" +storeButton.width = 75 +storeButton.height = 20 +storeButton.x = 15 +storeButton.y = 220 + +local slotSpacing = 3 +local unusedSlotDefaultText = "Unused" +local actions = {"Save..."} +local slotToStoredIndex = {} -- Holds the index of the stored fragment for each slot +for i=1,8 do + local fragmentSlot = rythmPanel:OnOffButton("StoreFragmentSlot" .. i) + fragmentSlot.backgroundColourOff = backgroundColourOff + fragmentSlot.backgroundColourOn = backgroundColourOn + fragmentSlot.textColourOff = textColourOff + fragmentSlot.textColourOn = textColourOn + fragmentSlot.displayName = "" .. i + fragmentSlot.enabled = false + fragmentSlot.tooltip = unusedSlotDefaultText + fragmentSlot.width = 20 + fragmentSlot.height = storeButton.height + fragmentSlot.x = storeButton.x + storeButton.width + ((i-1) * (fragmentSlot.width + slotSpacing)) + 10 + fragmentSlot.y = storeButton.y + fragmentSlot.changed = function(self) + if self.value then + local storedIndex = slotToStoredIndex[i] + if type(storedFragments[storedIndex]) == "table" then + recallStoredState = storedIndex + --print("Set part/recallStoredState", i, recallStoredState) + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end + end + end + for j,v in ipairs(fragmentSlots) do + if j ~= i then + v:setValue(false, false) + end + end + end + table.insert(fragmentSlots, fragmentSlot) + table.insert(slotToStoredIndex, nil) + table.insert(actions, "Save to " .. i) +end + +local slotActions = rythmPanel:Menu("SlotActions", actions) +slotActions.tooltip = "Save current fragment state to the selected slot" +slotActions.showLabel = false +slotActions.height = storeButton.height +slotActions.width = 90 +slotActions.x = storeButton.x + storeButton.width + ((fragmentSlots[1].width + slotSpacing) * #fragmentSlots) + 15 +slotActions.y = storeButton.y +slotActions.backgroundColour = menuBackgroundColour +slotActions.textColour = widgetTextColour +slotActions.arrowColour = menuArrowColour +slotActions.outlineColour = menuOutlineColour +slotActions.changed = function(self) + -- 1 is the menu label... + if self.value == 1 then + return + end + + local index = self.value - 1 + + -- Save current fragment state + -- TODO Add options to remove? + if index <= #fragmentSlots then + storeButton:changed() -- Store the current state + slotToStoredIndex[index] = #storedFragments -- Set the most recent stored fragment to this slot + fragmentSlots[index].tooltip = "Part " .. index .. " - Stored state " .. slotToStoredIndex[index] + fragmentSlots[index].enabled = true + end + + -- Must be last + self:setValue(1, false) +end + +loadFragmentMenu.tooltip = "Load a stored fragment state" +loadFragmentMenu.showLabel = false +loadFragmentMenu.height = storeButton.height +loadFragmentMenu.width = slotActions.width +loadFragmentMenu.x = slotActions.x + slotActions.width + 10 +loadFragmentMenu.y = slotActions.y +loadFragmentMenu.backgroundColour = menuBackgroundColour +loadFragmentMenu.textColour = widgetTextColour +loadFragmentMenu.arrowColour = menuArrowColour +loadFragmentMenu.outlineColour = menuOutlineColour +loadFragmentMenu.changed = function(self) + -- 1 is the menu label... + if self.value == 1 then + return + end -seqGateTable = rythmPanel:Table("Velocity", 8, 90, 0, 100, true) + local index = self.value - 1 + + if type(storedFragments[index]) == "table" then + recallStoredState = index + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end + end + + -- Must be last + self:setValue(1, false) +end + +partOrderButton = rythmPanel:OnOffButton("PartOrderLabel") +partOrderButton.displayName = "Part Order" +partOrderButton.tooltip = "Activate part order" +partOrderButton.width = 60 +partOrderButton.height = 20 +partOrderButton.backgroundColourOff = backgroundColourOff +partOrderButton.backgroundColourOn = backgroundColourOn +partOrderButton.textColourOff = textColourOff +partOrderButton.textColourOn = textColourOn +partOrderButton.x = loadFragmentMenu.x + loadFragmentMenu.width + 10 +partOrderButton.y = loadFragmentMenu.y + +local partOrderInput = rythmPanel:Label("PartOrderInput") +partOrderInput.text = "" +partOrderInput.tooltip = "Set the playing order of the parts (1-8 as stored in the slots). Format separated by comma (use e instead of x to activate evolve). Example: 1x16,2e8,3" +partOrderInput.editable = true +partOrderInput.backgroundColour = "black" +partOrderInput.backgroundColourWhenEditing = "white" +partOrderInput.textColour = "white" +partOrderInput.textColourWhenEditing = "black" +partOrderInput.x = partOrderButton.x + partOrderButton.width +partOrderInput.y = partOrderButton.y +partOrderInput.width = 156 +partOrderInput.height = 20 +partOrderInput.fontSize = 15 +partOrderInput.changed = function(self) + setPartOrder(self.text) +end + +--- Evolve --- + +local recallButton = rythmPanel:Button("RecallButton") +recallButton.displayName = "Recall" +recallButton.enabled = false +recallButton.tooltip = "Recall the last stored fragment state" +recallButton.width = storeButton.width +recallButton.height = storeButton.height +recallButton.x = storeButton.x +recallButton.y = storeButton.y + storeButton.height + 10 + +evolveButton = rythmPanel:OnOffButton("EvolveActive", false) +evolveButton.backgroundColourOff = backgroundColourOff +evolveButton.backgroundColourOn = backgroundColourOn +evolveButton.textColourOff = textColourOff +evolveButton.textColourOn = textColourOn +evolveButton.displayName = "Evolve" +evolveButton.tooltip = "Activate evolve" +evolveButton.width = recallButton.width +evolveButton.height = recallButton.height +evolveButton.x = recallButton.x + recallButton.width + 10 +evolveButton.y = recallButton.y + +evolveFragmentProbability = rythmPanel:NumBox("EvolveFragmentProbability", 50, 0, 100, true) +evolveFragmentProbability.unit = Unit.Percent +evolveFragmentProbability.textColour = widgetTextColour +evolveFragmentProbability.backgroundColour = widgetBackgroundColour +evolveFragmentProbability.displayName = "Amount" +evolveFragmentProbability.tooltip = "Set the probability that fragments will change over time, using the resolutions present in the fragments" +evolveFragmentProbability.width = 105 +evolveFragmentProbability.height = recallButton.height +evolveFragmentProbability.x = evolveButton.x + evolveButton.width + 10 +evolveFragmentProbability.y = evolveButton.y + +randomizeCurrentResolutionProbability = rythmPanel:NumBox("RandomizeCurrentResolutionProbability", 0, 0, 100, true) +randomizeCurrentResolutionProbability.unit = Unit.Percent +randomizeCurrentResolutionProbability.textColour = widgetTextColour +randomizeCurrentResolutionProbability.backgroundColour = widgetBackgroundColour +randomizeCurrentResolutionProbability.displayName = "Adjust" +randomizeCurrentResolutionProbability.tooltip = "Set the probability that evolve will adjust resolutions (double, half, dot/tri), based on the resolutions present in the fragments" +randomizeCurrentResolutionProbability.width = evolveFragmentProbability.width +randomizeCurrentResolutionProbability.height = evolveFragmentProbability.height +randomizeCurrentResolutionProbability.x = evolveFragmentProbability.x + evolveFragmentProbability.width + 10 +randomizeCurrentResolutionProbability.y = evolveFragmentProbability.y + +local biasLabel = rythmPanel:Label("BiasLabel") +biasLabel.text = "Bias slow > fast" +biasLabel.tooltip = "Adjust bias: <50=more slow resolutions, >50=more fast resolutions" +biasLabel.alpha = 0.5 +biasLabel.fontSize = 15 +biasLabel.width = 95 +biasLabel.height = randomizeCurrentResolutionProbability.height +biasLabel.x = randomizeCurrentResolutionProbability.x + randomizeCurrentResolutionProbability.width + 10 +biasLabel.y = randomizeCurrentResolutionProbability.y + +adjustBias = rythmPanel:Knob("Bias", 50, 0, 100, true) +adjustBias.showLabel = false +adjustBias.showValue = false +adjustBias.displayName = "Bias" +adjustBias.tooltip = biasLabel.tooltip +adjustBias.backgroundColour = widgetBackgroundColour +adjustBias.fillColour = knobFillColour +adjustBias.outlineColour = widgetTextColour +adjustBias.width = 20 +adjustBias.height = biasLabel.height +adjustBias.x = biasLabel.x + biasLabel.width +adjustBias.y = biasLabel.y + +local minResLabel = rythmPanel:Label("MinResolutionsLabel") +minResLabel.text = "Min resolution" +minResLabel.alpha = 0.5 +minResLabel.fontSize = 15 +minResLabel.width = biasLabel.width +minResLabel.height = adjustBias.height +minResLabel.x = adjustBias.x + adjustBias.width + 10 +minResLabel.y = adjustBias.y + +local minResolution = rythmPanel:Menu("MinResolution", resolutions.getResolutionNames()) +minResolution.displayName = minResLabel.text +minResolution.tooltip = "The highest allowed resolution for evolve adjustments" +minResolution.selected = 26 +minResolution.showLabel = false +minResolution.width = 69 +minResolution.height = adjustBias.height +minResolution.backgroundColour = widgetBackgroundColour +minResolution.textColour = widgetTextColour +minResolution.arrowColour = menuArrowColour +minResolution.outlineColour = menuOutlineColour +minResolution.x = minResLabel.x + minResLabel.width +minResolution.y = minResLabel.y +minResolution.changed = function(self) + rythmicFragments.setMaxResolutionIndex(self.value) +end +minResolution:changed() + +storeButton.changed = function(self) + table.insert(storedFragments, rythmicFragments.getFragmentState()) + recallButton.enabled = true + loadFragmentMenu.enabled = true + loadFragmentMenu:addItem("State " .. #storedFragments) +end + +recallButton.changed = function(self) + recallStoredState = #storedFragments + -- If sequencer is not playing, we can recall right now + if isPlaying == false then + recall() + end +end + +--[[ seqGateTable = rythmPanel:Table("Velocity", 8, 90, 0, 100, true) seqGateTable.unit = Unit.Percent seqGateTable.tooltip = "Set gate pattern. If a gate step is set to zero, that step is muted." seqGateTable.showPopupDisplay = true @@ -374,7 +728,7 @@ seqGateTable.sliderColour = sliderColour seqGateTable.width = rythmPanel.width - 140 seqGateTable.height = 45 seqGateTable.x = 10 -seqGateTable.y = 210 +seqGateTable.y = rythmPanel.height - 57 local gateTableLength = rythmPanel:NumBox("GateTableLength", 8, 1, 64, true) gateTableLength.displayName = "Gate Len" @@ -398,7 +752,7 @@ gateRandomization.textColour = menuTextColour gateRandomization.width = gateTableLength.width gateRandomization.height = gateTableLength.height gateRandomization.x = gateTableLength.x -gateRandomization.y = gateTableLength.y + gateTableLength.height + 1 +gateRandomization.y = gateTableLength.y + gateTableLength.height + 1 ]] -------------------------------------------------------------------------------- -- Handle events @@ -432,18 +786,56 @@ end function onSave() local fragmentInputData = {} + local fragmentSlotsData = {} for _,v in ipairs(paramsPerFragment) do table.insert(fragmentInputData, v.fragmentInput.text) end - return {fragmentInputData} + for _,v in ipairs(fragmentSlots) do + table.insert(fragmentSlotsData, v.tooltip) + end + + return {fragmentInputData, fragmentSlotsData, storedFragments, partOrderInput.text, slotToStoredIndex} end function onLoad(data) local fragmentInputData = data[1] + local fragmentSlotsData = data[2] + storedFragments = data[3] + partOrderInput.text = tostring(data[4]) + slotToStoredIndex = data[5] + + setPartOrder(partOrderInput.text) + + if type(storedFragments) == "nil" then + storedFragments = {} + end + + if type(fragmentSlotsData) == "nil" then + fragmentSlotsData = {} + end + + if type(slotToStoredIndex) == "nil" then + slotToStoredIndex = {} + for i=1,#fragmentSlots do + table.insert(slotToStoredIndex, nil) + end + end + + recallButton.enabled = #storedFragments > 0 + + for i=1,#storedFragments do + loadFragmentMenu:addItem("State " .. i) + end + loadFragmentMenu.enabled = #storedFragments > 0 for i,v in ipairs(fragmentInputData) do paramsPerFragment[i].fragmentInput.text = v end + + for i,v in ipairs(fragmentSlotsData) do + fragmentSlots[i].tooltip = v + fragmentSlots[i].enabled = type(slotToStoredIndex[i]) == "number" + end end diff --git a/modular/sequencerInput.lua b/modular/sequencerInput.lua index fbf8c84..e9d66ec 100644 --- a/modular/sequencerInput.lua +++ b/modular/sequencerInput.lua @@ -13,6 +13,7 @@ local tableLength = 8 local sequencerPos = 1 local octaveRange = 1 local bipolar = true +local pitchOffsetSwapProbability = 0 widgets.setSection({ width = 720, @@ -80,11 +81,11 @@ local sequencerTable = widgets.table(tableLength, 0, { }) widgets.setSection({ - width = 120, + width = 114, yOffset = widgets.posUnder(sequencerTable) + 5, }) -local noteInput = widgets.numBox("Root", baseNote, { +local noteInput = widgets.numBox("Root Note", baseNote, { unit = Unit.MidiKey, tooltip = "Set the root note", changed = function(self) baseNote = self.value end @@ -111,6 +112,10 @@ local function setRange() else sequencerTable:setRange(0, tableRange) end + for i=1,tableLength do + sequencerTable:setValue(i, math.max(sequencerTable.min, sequencerTable:getValue(i))) + sequencerTable:setValue(i, math.min(sequencerTable.max, sequencerTable:getValue(i))) + end end widgets.numBox("Octave Range", octaveRange, { @@ -132,12 +137,25 @@ widgets.button("Bipolar", bipolar, { end }) +widgets.numBox("Offset Rand", pitchOffsetSwapProbability, { + tooltip = "Probability that the pitch offset from another step will be used", + unit = Unit.Percent, + changed = function(self) pitchOffsetSwapProbability = self.value end +}) + -------------------------------------------------------------------------------- -- Handle Events -------------------------------------------------------------------------------- local function getNote() - return baseNote + sequencerTable:getValue(sequencerPos) + local pitchOffset = 0 + if gem.getRandomBoolean(pitchOffsetSwapProbability) then + randomPos = gem.getRandom(tableLength) + pitchOffset = sequencerTable:getValue(randomPos) + else + pitchOffset = sequencerTable:getValue(sequencerPos) + end + return baseNote + pitchOffset end function onNote(e) diff --git a/sequencers/stochasticDrumSequencer.lua b/sequencers/stochasticDrumSequencer.lua index 705e59b..8eebea1 100644 --- a/sequencers/stochasticDrumSequencer.lua +++ b/sequencers/stochasticDrumSequencer.lua @@ -498,7 +498,7 @@ for page=1,maxPages do local pitchRand = sequencerPanel:NumBox("PitchOffsetRandomization" .. i, 0, 0, 100, true) pitchRand.displayName = "Pitch" - pitchRand.tooltip = "Set probability pitch from another step will be used" + pitchRand.tooltip = "Probability that the pitch offset from another step will be used" pitchRand.visible = isVisible pitchRand.unit = Unit.Percent pitchRand.size = directionProbability.size diff --git a/util/sieve.lua b/util/sieve.lua index 7dd38a3..928a85c 100644 --- a/util/sieve.lua +++ b/util/sieve.lua @@ -67,7 +67,7 @@ sieveButton.x = panel.width - 40 -------------------------------------------------------------------------------- function onNote(e) - if e.note <= noteMin.value or e.note >= noteMax.value or gem.getRandomBoolean(sieveProbability.value) then + if e.note < noteMin.value or e.note > noteMax.value or gem.getRandomBoolean(sieveProbability.value) then print("Passing through", e.note) sieveButton.backgroundColourOff = "green" postEvent(e)