Minimzing duplication #745
Replies: 6 comments 17 replies
-
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the tip. I'd love to follow any/all best practices, but there doesn't seem to be much in the way of a document/outline for any of that. This is the Lexicon PCM 80 panel. The original supported the PCM 80 (1.10 OS) and the original 10 algorithms. Mine currently works with the PCM 80 and 81 and can read and edit all 42 algorithms (PCM 81 extras plus the Dual FX, Pitch FX and Vocal FX cards). I still need to add support for the original 1.0 OS of the PCM 80. As part of the reworking, I have cut the panel size down from 120 MB to 3.5 MB. There's still a lot of work to be done with it. I'm hoping to finish by March. I posted this excerpt thinking it might be interesting or useful to some folks showing that you can use text in the modulatorCustomIndex and then Lua can transform it into a table reference, a method call or anything else you might need. |
Beta Was this translation helpful? Give feedback.
-
|
Is this sending a 16 bit value? Can you show me the algorithm you use? local lowB, highB = un16(value)
local lb1, lb2 = unByte(lowB)
local hb1, hb2 = unByte(highB) |
Beta Was this translation helpful? Give feedback.
-
|
Oh I see so a MSB/LSB of a 16 bit number is sent lsb,msb,lsb,msb as 4 bit nibbles across 4 bytes sysex? |
Beta Was this translation helpful? Give feedback.
-
|
Yes, I understand how much hard work goes into producing software for these old units. There’s always the question of charging money for your hard work. But then you get into all sorts of software protection systems and registration and everything that goes with that, but Damien has been working on a solution to that. I’ve ended up just releasing everything for free, but recently I don’t show the source code-i.e..the .bpanelz files are not released. Still, coding 16 bit breakdown of sysex is probably, for a lot of people quite a challenge , so I might submit a Ctrlr method for doing that anyway. Maybe you might use it, because it could be faster than lua, but lua is still pretty quick. |
Beta Was this translation helpful? Give feedback.
-
|
I have created a build that handles 16 bit values - it's for people who might have trouble working out the algorithms; of course you were able to do that. I think you are on Mac? Anyway, there are releases for Windows,Linux and macOS To send a 16 bit lsb first you would do something like f0 q0 q1 q2 q3 f7 in the editor (no lua)
With lua CUSTINDEX="modulatorCustomIndex"
-- send
local data = panel:getModulatorValuesAsData(CUSTINDEX, CtrlrPanel.Encode16bitLsbFirst, 4, false)
panel:sendMidiMessageNow(CtrlrMidiMessage(string.format("%s %s %s",HEADER,data:toHexString(1),EOX)))
-- receive
local headerSize=MemoryBlock(HEADER):getSize()
panel:setModulatorValuesFromData(midi:getData(), CUSTINDEX, CtrlrPanel.Encode16bitLsbFirst,-headerSize, 4, false) |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I decided I wanted to revamp and extend an existing effects unit panel. As part of this task, I wanted to eliminate as much duplication and hard-coding as possible. Since the effects unit has between 10 and 42 different algorithms, simply creating a group per algorithm and duplicating the controls and such would (IMHO) become very unwieldy, so I came up with an approach to re-use a single control across each algorithm that references it. Hopefully someone else may find this approach useful or at maybe interesting.
Patch dumps will have a parameter in different offsets in the dump depending on the algorithm used. I decided to create a table of offsets for the parameters and a single Lua method to send the MIDI info back the the effects unit as you edit the values.
For example, take the reverb size parameter. Here is the offsets in the sysex dump for each algorithm. In algorithms that it is not used, I put a "-1".
sz = {[0]=16,16,17,-1,19,67,77,70,71,80,70,70,-1,71,73,78,78,-1,79,81,73,73,-1,74,76,74,74,-1,75,77, 81, 81,-1, 82,84,62,62,-1} -- Reverb Sizeduring the panel load, the size param is referenced as usual:
reverb_design_size = panel:getModulatorByName("reverb_design_size")When a dump is received, the data is parsed into tables that I need (type1Data, type1Flags, type2Data, ...) and various other things are captured like the algorithm used, device ID, and so on.
To assign the data from the dump to the parameters, a simple check can be done:
when a user edits a parameter, instead of using a hard-coded sysex string attached to the uiSlider, I call a function tied to the luaModulatorValueChange instead.
Note that I use the size table name as the modulatorCustomIndex
the sendMIDI() function is where the translation trick happens:
by using the array name as the index and then transforming it to a table lookup, the single reverb_size control can be used anywhere I need it. Also, since there's only 1 place where I send parameter edits back to the unit, once it is working, it works for all parameters and I can have parameters to control things like the revision of the device and even talk to more than one device using the devID parameter to distinguish multiples.
Beta Was this translation helpful? Give feedback.
All reactions