Develog One: Making Modules

Read the previous entry here: https://www.databroth.com/blog/devlog-zero-first-experiences-with-lua-and-plugdata

        It has been over half a year since my last “devlog” and about that long since I’ve touched anything code related at all. After some discussion with a plugin team about UI ideas, I decided I should try my hand at actually building it instead of trying to create an animation. While I didn’t manage to create my full concept, I did manage to make something that previously seemed out of my personal scope, and was able to showcase at least one small part of this idea. I was pleasantly surprised how much smoother things went this time around, it seems I didn’t forget everything I learned previously and I also got to learn quite a few new concepts.

The goal was to create a modular “node” style interface with a radial menu for adding new nodes/modules.
Funnily enough, the radial menu is probably the least interesting aspect of this experiment, as I mostly just mocked something up to “work” and spent most of my time on the modular UI
I learned so much while creating the modular UI, almost every aspect required understanding a new concept and working out the proper instructions for things to work right.

 

Keeping things as simple as possible was key, so I needed to first start by mocking up the menu and creating state changes for each operation.

First you click, then the menu pops up, then you select a menu item, and place it.

Placing the the item is where things get fun, this is where I learned about appending arrays. Each new item needs to be a new array index with its own set of values. For now these values are simply location and color which is set via the menu.

At this point, things were very unpleasant to look at as I was using solid white, black, red, green, and blue circles for everything. So I decided to polish things up with a decent color scheme, and use rounded rectangles for the “modules”

Cool, we can add modules, but what about deleting them? This seemed simple enough, click the module and delete from the array. But things are NEVER that simple. With out telling Lua which module to delete, it simply deletes the latest one added. Now I needed to specify the index for whichever module I was clicking to specify that it is the one to erase, I also made this a button on the module as I wanted to add controls.

Moving the modules was one of the trickier steps. at this point my code was very messy and I was loosing my mental map for the various array instructions. I got it to the point where I could move modules one space at a time. The condition to allow movement would be broken when the module was moved outside of it’s original position. I also managed to break things where moving any module moved all of them to the same spot. With enough troubleshooting, I eventually got things working, but this is something I’ll need to attempt again and build a deeper understanding for.

Especially when considering my last criteria before stopping this particular project: controls. I wanted each module to have adjustable controls. Importantly, these controls need to be unique per module instance without reset when moving a module. By far this took the most experimentation and problem solving. The confusion came from moving a control via mouse position, then having that control’s position change. because mouse input is set in coordinates, when moving a module, the coordinate info would not adjust accordingly.

I do not feel I came up with a real solution to this, and I believe the real solution is likely much simpler than I made it out to be, but this is something I plan to solve later. In the mean time I just ignored mouse position all together and used travel distance to move the controls. This was very simple, take the click coordinates and subtract them from the drag coordinates.


 

        At this point, I felt comfortable calling it quits. I managed to get something functional enough, albeit with some very obvious flaws once you start using it. I’d like to go back through and rework each of the actions on their own. I also need to learn about nesting arrays and figure out a better variable system. There’s just too many times I’m doing equations with various array indexes within a function. I also want to take things out of pd_lua sometime before my next build and either work with Lua or C++ in Juce. I’m hoping to build the plugin UIs that I envision and maybe one day get this modular system out of my head and into people’s hands. For now you’ll just have to trust that my idea is way cooler than what I was able to make here.

Previous
Previous

PARROT: FREE Delay Review

Next
Next

PUNCHBOX 2 Review