-- Version 0.9 --[[---------------------------------------------------------------- EnvelopeMaestro.hmm (0.9) This is the property container for a sequence of Envelope.hmm objects for the same controller. For the manipulation of the envelope, look at Envelope.hmm's documentation. @ControllerName The MIDI continuous controller (CC) whose value is changed by this envelope. There is a set of predefined controllers with standard names (from the MIDI standard), as well as the possibility to select the controller by number. The number in the second field is only relevant if 'Select by number' is chosen in the first field. @Controller The MIDI continuous controller (CC) whose value is changed by this envelope. This value is used if 'Select by number' is chosen in the first field. @ShowAs Text representation at the envelope points. If none is chosen, a suitable default is shown. Font StaffBold is used for the EnvelopeMaestro.hmm object, StaffLyric at the envelope points. @ShowLocation Defines whether the controller name is show above or below the envelope line. @Scale Scale of the controller name text. @MinValue Minimum controller value. @MaxValue Maximum controller value. @Bottom Range of staff positions that are mapped to the value range to determine the value. If an Envelope.hmm object is moved outside this range, the minimum or maximum value of the value range is used; a tiny dot behind the controller value is shown in this case. @Top Range of staff positions that are mapped to the value range to determine the value. If an Envelope.hmm object is moved outside this range, the minimum or maximum value of the value range is used; a tiny dot behind the controller value is shown in this case. @Pen Type of line drawn for this envelope. @PenWidth Thickness of line for this envelope. @PenOffset Vertical offset of line; this is maybe useful if two envelopes live in the same staff range of a staff - which is probably not that good an idea. --]]---------------------------------------------------------------- local userObjTypeName = ... local userObjSigName = nwc.toolbox.genSigName(userObjTypeName) local controllersByName = { 'Select by number', '0:Bank select', '1:Modulation', '2:Breath controller', '4:Foot controller', '5:Portamento time', '7:Volume', '8:Balance', '10:Stereo Pan', '11:Expression', '64:Hold 1', '65:Portamento on/off', '66:Sostenuto on/off', '67:Soft pedal on/off', '68:Legato foot switch', '69:Hold 2', '84:Portamento', '120:All sound off', '121:Reset all controllers', '122:Local on/off', '123:All notes off', '124:Omni mode off', '125:Omni mode on', '126:Mono mode', '127:Poly mode', '128:Pitch bend', } local showLocation = { 'above', 'below' } local _spec = { { id='ControllerName', label='C&ontroller', type='enum', default=controllersByName[7], list=controllersByName }, { id='Controller', label=false, type='int', default=-1, min=-1, max=128 }, { id='ShowAs', label='Show &as', type='text', default='', width=20 }, { id='ShowLocation', label='Show &where, scale', type='enum', default=showLocation[1], list=showLocation }, { id='Scale', label=false, type='int', default=100, min=20, max=500, step=5 }, { id='MinValue', label='Value &range', type='int', default=0, min=0, max=127 }, { id='MaxValue', label=false, type='int', default=127, min=0, max=127 }, { id='Bottom', label='Sta&ff range', type='float', default=0, min=-24, max=20, step=0.5 }, { id='Top', label=false, type='float', default=10, min=-20, max=24, step=0.5 }, { id='Pen', label='&Line type', type='enum', default=nwc.txt.DrawPenStyle[1], list=nwc.txt.DrawPenStyle }, { id='PenWidth', label='Line &thickness', type='float', default=0.5, min=0.1, max=4, step=0.1 }, { id='PenOffset', label='Line off&set', type='float', default=0, min=0, max=8, step=0.1 }, } local function getMaestroController(controllerName, controller) if controllerName ~= controllersByName[1] then return string.match(controllerName, '^%d+') + 0 else return controller end end local function getMaestroShowAs(showAs, controller) if showAs ~= '' then return showAs elseif controller == 0 then return 'BnkSel' elseif controller == 1 then return 'Modul' elseif controller == 2 then return 'Brth' elseif controller == 4 then return 'Foot' elseif controller == 5 then return 'Ptm.t' elseif controller == 6 then return 'D.MSB' elseif controller == 7 then return 'Vol' elseif controller == 8 then return 'Bal' elseif controller == 10 then return 'Pan' elseif controller == 11 then return 'Expr' elseif controller == 65 then return 'Ptm+-' elseif controller == 66 then return 'Sst+-' elseif controller == 67 then return 'Sft+-' elseif controller == 68 then return 'Legto' elseif controller == 69 then return 'Hld 2' elseif controller == 84 then return 'Ptm' elseif controller == 120 then return 'All-' elseif controller == 121 then return 'Reset' elseif controller == 122 then return 'Loc+-' elseif controller == 123 then return 'Notes-' elseif controller == 124 then return 'Omni-' elseif controller == 125 then return 'Omni+' elseif controller == 126 then return 'Mono' elseif controller == 127 then return 'Poly' elseif controller == 128 then return 'Pitch' else return 'CC' .. controller end end ----------------------------- CREATE ---------------------------- local function _audit(t) if t.Top <= t.Bottom then t.Top = t.Bottom + 1 end if t.MaxValue <= t.MinValue then t.MaxValue = t.MinValue + 1 end end local function _create(t) t.Class = 'StaffSig' --?? (10) Is this helpful? _audit(t) end ----------------------------- DRAWING --------------------------- local function _draw(t) nwcdraw.setFontClass('StaffBold') nwcdraw.alignText("bottom","left") nwcdraw.setFontSize(nwcdraw.getFontSize() * t.Scale / 100) local controller = getMaestroController(t.ControllerName, t.Controller) nwcdraw.text(getMaestroShowAs(t.ShowAs, controller) .. '[' .. controller .. ']') end return { create = _create, audit = _audit, spec = _spec, draw = _draw, }