A dev tool to look inside a module and check stuff

To stdout: what happens in the stdout where your rack runs? Do you run with a terminal attached? If not you will indeed not see the stdout

To html: check your browser tabs?

But I could add a to rack log option I guess also

Yeah, I donā€™t run with a terminal. Clicking on HTML does not open any tabs in Firefox or Edge.

Ok must be failing to make the file

If you want to look itā€™s show html in lintbuddy.cpp. I bet it is giving a bad temp name on windows and canā€™t make the html or canā€™t browser open it.

Works great in mac, as does the stdout!

(Dump to rack log is a good idea too tho)

donā€™t know if this is still current, but of course you can reuse any code in my repos under gpl, feel free to ask if things are unclear in the code.

1 Like

Thanks!

I got it starting to work then realized in this case I can just reuse the scroll widget but I have another idea for a kind of sequencer where I will definitely use a bunch of that code.

One thing that always feels tedious is getting my ports, sliders, knobs, etc., aligned properly on the panel. I can usually just look inside my code and see the (x, y) coordinates of everything. But then I have to make a spreadsheet to verify that left and right margins are the same, that the horizontal spacing between things is consistent, etc.

I have read that some developers use formulas to calculate coordinates instead of hardcoding them. But for cases where I keep moving things around in my SVG background and adjusting numbers in the C++ code to match, it would be nice to get a report on the coordinates of everything in my module.

For example, take all controls and ports, sort them primarily by ascending y-coordinate (top to bottom), secondarily by x-coordinate (left to right). Then output as CSV text: each row could be (x, y, label). Anything I can load into Google Sheets to study would be pretty useful.

I would like to look at Ī”x between consecutive objects on the panel that all have the same y value, to make sure the horizontal spacing is the same. Then I could look at Ī”y going down the panel, for vertical spacing.

A more advanced version of this could try to do some symmetry analysis and point out coordinates that are not quite lined up right, but that may end up being an AI science project that never ends. Just throwing ideas out there for funā€¦

I donā€™t know if this helps, but when I spec coords to Marc and Paul then when controls are on a grid of rows and columns, I give the centre coords of the top left item (or sometimes bottom left) and give horizontal and vertical offsets for the centres of the other rows/columns. I believe they are coded that way too so items always remain aligned and thereā€™s no need for checking them individually.

yeah i do all our layout to formulae and then write a little layout manager that does the math. Iā€™m happy to share that code.

I actually donā€™t know if I get access to the widget, as opposed to the module, with the trick I used. If I do though that would be a good one. Dump the position and type of every widget on the screen.

Oooh hey yeah you can.

So I just pushed test which for the module tries to get the widget and if it does just recursively walks the tree printing position and mangled C++ classname.

Iā€™ll leave it as an exercise to the reader to add the constraint tests you want but Iā€™m happy to merge them if you do!

Yeah, I really should do something like thatā€¦ create a visual map, plan what I need, and then use formulas to calculate coordinates. OK, so thatā€™s my resolution for my next moduleā€¦ invest a little time coding some alignment formulas that reflect what Iā€™m trying to depict and just let them figure it out.

happy to walk you through how we did it in surge. we had 36 very very regular modules to make and ended up doing it almost all with just straight C++ data structures which drive a layout.

2 Likes

That is really cool! Itā€™s pretty wild that a VCV Rack module can do ā€œreflectionā€ (like we call it in programming languages like C#). The recursive part is cool, but I think the main thing I would need is a list of top-level objects, omitting info about whatā€™s inside them. (Maybe people developing the innards of compound controls would need that, though.)

What would be really cool is to tie the widget components to the module controls. Basically, if have this in my module:

configInput(AUDIO_LEFT_INPUT, "Left audio");

and I have this in my widget:

addInput(createInputCentered<SapphirePort>(mm2px(Vec( 7.50, 115.00)), module, Elastika::AUDIO_LEFT_INPUT));

then they are tied together by the enum value AUDIO_LEFT_INPUT. So it would be really cool to output something like

"x","y","id","name"
7.50,115.00,5,"Left audio"

where 5 is the numeric value of my enum value AUDIO_LEFT_INPUT. This is dirt-simple CSV format that I could pull directly into a spreadsheet and sort however I want, and add formulas or whatever to check things.

I know many developers here dislike Inkscape and SVG, but those of us who use SVG could benefit from cross-referencing the coordinates in the SVG text with this kind of CSV output.

is there a size limit on JSON data?

Or something else?

Yes, definitely! Iā€™d like to hear any strategies or ways of looking at things to simplify the process. Especially if it helps me through the part of the design where I keep changing my mind and moving things around!

no size limit but there was a bug earlier where i truncated the display. Are you up to date?

i also call the module dataToJSON method so if you donā€™t implement that then nothing comes. Do we want the entire json dump or just the module specific json? I figured ā€œrack doesnā€™t have a bugā€ so just dod the module bit :slight_smile:

Fairly up to dateā€¦ Although STDOUT and HTML donā€™t work on my Win (yet).

image

Actually thatā€™s fine for me. Thatā€™s what I need. But I could also use a complete JSON dump. Iā€™m curious how others would use this featureā€¦

Iā€™d be also happy to put values to a variable (like DEBUGSTRING) at certain steps of my code and watch it in LintBuddy.

1 Like

yeah stdout wonā€™t work on win unless you attach a terminal to rack

html - ugh i need to boot into windows to debug that and i donā€™t have a windows rack dev env. Anyone want to take a shot at ā€œwrite a file to a temp location in a way that works on windowsā€ in an ifdef for me with a windows env running? Its literally 30 lines of code. BaconPlugs/LintBuddy.cpp at 9e1944ebf2a9d5fe1245f00d25fe69c53e14ae82 Ā· baconpaul/BaconPlugs Ā· GitHub but I wonā€™t get a windows env running before thanksgiving looking at my schedule. (I have a windows env for regular dev but not for the rack pretend-its-unix stuff).

This is a somewhat different, but kinda brilliant, idea for a rack dev console. Basically have a module with a scrollable set of text. Have an API in your module where you attach and can send strings over.

I see a lot of ways to write that code, but itā€™s a bit of a different topology than ā€˜attach and probeā€™ and requires a library you can include in the ā€˜awayā€™ module too. Iā€™ll think about it though.

OK how do I reproduce that truncation then? Which module did you attach to and can I run it?

I saw the JSON limitation in case of

These are all sequencers with a pretty long array in their JSON.

1 Like