Prefabs by ldlework pre-release

Prefabs for VCV Rack

Hello all, I’m ldle.

I wanted to let you know about my first plugin Prefabs.

As you can see, it’s a floating-widget that gives you quick access to your VCV selections.

Code: https://github.com/dustinlacewell/vcv-prefabs

Releases: https://github.com/dustinlacewell/vcv-prefabs/releases

Highlights:

  • Persistent widget stays where you put it
  • Drag prefabs and modules directly to the patch
  • Access your own prefabs by tag, or the modules they use
  • Third-party prefab support (include prefabs in your own plugins, similar to presets)
  • Search

Additionally, I added the ability to access your normal module library:

  • Quickly access your favorite modules
  • Hold ctrl to access all modules
  • Right-click a module to toggle it as a favorite
  • Module previews
  • Search

I am hoping to get some early feedback before I publish to the library. I’m sure some decisions I made could be improved with such feedback.

Some possible feedback could be:

  • Suggestions on how to improve the organization of the widget menu
  • Documentation changes
  • Changes to how selections are expected to be organized on disk
  • Visual changes to the widget

Finally, I picked up C++ in order to make this so I am sure there are many bugs, memory leaks, segfaults, etc. I would appreciate any help understanding where those are and how to fix them.

If you’d like to contribute, I’m on the VCV Discord.

Thanks for taking a look!

Huge thanks to baconpaul, Surgo, Squinky Labs, JTB, alefnull, pgatt and more for answering all my questions and helping me with it all.

2.0.5 updates: 2/3/2023

  • New module look!
  • Shows total prefabs/patches/modules
  • Indicator light shows when data is being loaded
  • Unified prefab/patch handling should be much more performant

2.0.4 updates: 2/2/2023

  • Refreshing is now in a background thread which should keep the UI responsive
  • Added a browser replacement mode
  • Added extraPrefabSources and extraPatchSources to prefab.json settings.
  • Patches are now searched
  • Search results cleaned up

2.0.3 updates: 2/1/2023

  • Multiple Prefab modules are no longer a problem, they all share the single global widget.
  • All Prefab modules share a single set of settings. So changing it here changes it everywhere.
  • Once loaded the Prefabs Widget is now permanent and persists across patch loads.
  • Prefabs and patches with missing modules can’t be clicked and show tooltip with missing modules.
  • V1 patches now supported.
  • Some reliability fixes.

2.0.2 updates: 1/31/2023

  • Unorganized prefabs (those not in a sub-directory) now show in the “untagged” menu.
  • Toggling module favorites is less finicky.
  • Ctrl must be held when opening the widget to see the full module library. The previous behavior of being able to toggle it while the menu was open was janky and uncomfortable to maintain.
  • Module library and search results now sorted.
  • Select how modules are sorted in module library using settings context-menu.
  • Toggle which tags are shown in module library using settings context-menu.
35 Likes

That could really speed up workflow, looks great.

Closest I’ve seen to it before in the rack is Strip

but, this seems a simpler to learn templating solution with more of a hook into your library.

1 Like

First quick test on Mac Os Mojave looks ok

Congrats and thanks a lot !

1 Like

Hi looks good VCV - Google Drive for a lin-arm64 build. Note the README-... for how to. And a notification of a “core dump” (no dump?) segmentation fault on the closing rack, only the first time though.

And so to whiling away Airwin2Rack.

1 Like

Congrats on the beta launch!

1 Like

This looks great. One awesome thing that Stoermelder Strip and S++ (which works with and imports Rack selections) do though is preserve parameter mappings which Rack itself does not do for some reason (all mappings are lost on selection import).

Might be tricky to implement but would be great if Prefabs could maintain the mappings too like S++.

2 Likes

Work around found for lin-arm64 build

Screenshot 2023-01-31 12.57.57

OK, to test at last. :smiley:

2 Likes

Brilliant! Thanks for making this. Looks like a great timesaver.

1 Like

Looks very cool! Is it compatible with the standard VCV Rack “selections”? You get a big wet kiss if you implement scrollbars on those long lists, and the ability to scroll down them using only the keyboard.

Ah, just tried it. Works fine on macOS 10.12.6. And yes, it’s compatible with standard selections. Like others I did get a crash on close the first time, but not subsequent times:

[376.430 info adapters/standalone.cpp:269 main] Stopped window
[376.430 info adapters/standalone.cpp:280 main] Deleting context
[376.430 info src/context.cpp:19 ~Context] Deleting window
[376.490 info src/context.cpp:23 ~Context] Deleting patch manager
[376.490 info src/patch.cpp:254 saveAutosave] Saving autosave /Users/lab/Documents/Rack2/autosave/patch.json
[376.491 info src/context.cpp:27 ~Context] Deleting scene
[376.494 info src/rtaudio.cpp:147 closeStream] Stopping RtAudio Core Audio device 1
[376.543 info src/rtaudio.cpp:151 closeStream] Closing RtAudio Core Audio device 1
[376.547 fatal adapters/standalone.cpp:49 fatalSignalHandler] Fatal signal 11. Stack trace:
42: Rack(fatalSignalHandler(int)+27)
41: libsystem_platform.dylib(_sigtramp+26)
40: libsystem_c.dylib(__Bfree_D2A+63)
39: plugin.dylib(PrefabsWidget::~PrefabsWidget()+34)
38: libRack.dylib(rack::widget::Widget::clearChildren()+113)
37: libRack.dylib(rack::widget::Widget::~Widget()+38)
36: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
35: libRack.dylib(rack::widget::Widget::clearChildren()+113)
34: libRack.dylib(rack::widget::Widget::~Widget()+38)
33: libRack.dylib(rack::widget::FramebufferWidget::~FramebufferWidget()+14)
32: libRack.dylib(rack::widget::Widget::clearChildren()+113)
31: libRack.dylib(rack::widget::Widget::~Widget()+38)
30: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
29: libRack.dylib(rack::widget::Widget::clearChildren()+113)
28: libRack.dylib(rack::widget::Widget::~Widget()+38)
27: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
26: libRack.dylib(rack::widget::Widget::clearChildren()+113)
25: libRack.dylib(rack::widget::Widget::~Widget()+38)
24: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
23: libRack.dylib(rack::widget::Widget::clearChildren()+113)
22: libRack.dylib(rack::widget::Widget::~Widget()+38)
21: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
20: libRack.dylib(rack::widget::Widget::clearChildren()+113)
19: libRack.dylib(rack::widget::Widget::~Widget()+38)
18: libRack.dylib(rack::widget::Widget::~Widget()+14)
17: libRack.dylib(rack::widget::Widget::clearChildren()+113)
16: libRack.dylib(rack::widget::Widget::~Widget()+38)
15: libRack.dylib(rack::widget::Widget::~Widget()+14)
14: libRack.dylib(rack::widget::Widget::clearChildren()+113)
13: libRack.dylib(rack::widget::Widget::~Widget()+38)
12: libRack.dylib(rack::ui::ScrollWidget::~ScrollWidget()+41)
11: libRack.dylib(rack::widget::Widget::clearChildren()+113)
10: libRack.dylib(rack::widget::Widget::~Widget()+38)
9: libRack.dylib(rack::app::browser::Browser::~Browser()+14)
8: libRack.dylib(rack::widget::Widget::clearChildren()+113)
7: libRack.dylib(rack::widget::Widget::~Widget()+38)
6: libRack.dylib(rack::app::browser::ModelBox::~ModelBox()+14)
5: libRack.dylib(rack::widget::Widget::clearChildren()+113)
4: libRack.dylib(rack::widget::Widget::~Widget()+38)
3: libRack.dylib(rack::app::Scene::~Scene()+41)
2: libRack.dylib(rack::Context::~Context()+205)
1: Rack(main+3778)
0: libdyld.dylib(start+1)
1 Like

I’m not sure if this is C++17 related clean up code call entry points in the dynamic library link process. It seems to be CMake related?

I mean when building Rack

g++ -std=c++11 -Wsuggest-override  -Iinclude -Idep/include -fPIC -fno-gnu-unique -MMD -MP -g -O3 -funsafe-math-optimizations -fno-omit-frame-pointer -Wall -Wextra -Wno-unused-parameter -DARCH_ARM64 -march=armv8-a+fp+simd -DARCH_LIN  -o Rack adapters/standalone.cpp libRack.so -static-libstdc++ -static-libgcc -Wl,-rpath=.
./Rack -d

Definitely says the “loader” is c++11. I’m not sure what happens when the “loadee” is c++17. Extra stuff to deallocate closures?

1 Like

I got a segfault on closing

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007fff27133070 in libRack!_ZN4rack6widget6Widget13requestDeleteEv () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
(gdb) bt
#0  0x00007fff27133070 in libRack!_ZN4rack6widget6Widget13requestDeleteEv () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
#1  0x00007ffefc27d356 in PrefabsWidget::~PrefabsWidget (this=0x1ed53766bd0, __in_chrg=<optimized out>)
    at C:/_Projects/VCVRack/Rack-SDK-2/plugins/vcv-prefabs/src/widgets/PrefabsWidget.cpp:41
#2  PrefabsWidget::~PrefabsWidget (this=0x1ed53766bd0, __in_chrg=<optimized out>)
    at C:/_Projects/VCVRack/Rack-SDK-2/plugins/vcv-prefabs/src/widgets/PrefabsWidget.cpp:43
#3  0x00007fff27133765 in libRack!_ZN4rack6widget6Widget13clearChildrenEv () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
#4  0x00007fff271337b7 in libRack!_ZN4rack6widget6WidgetD2Ev () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
#5  0x00007fff27131486 in libRack!_ZN4rack6widget17FramebufferWidgetD0Ev () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
#6  0x00007fff27133765 in libRack!_ZN4rack6widget6Widget13clearChildrenEv () from C:\Program Files\VCV\Rack2 Pro\libRack.dll

[snipped]

Possible problem here:

Just got a setfault on adding module to empty rack:

Thread 1 received signal SIGSEGV, Segmentation fault.
std::_Rb_tree<Prefab, Prefab, std::_Identity<Prefab>, std::less<Prefab>, std::allocator<Prefab> >::_M_create_node<Prefab const&> (this=<optimized out>) at C:/msys64/mi
ngw64/include/c++/12.2.0/bits/stl_tree.h:612
612               _M_construct_node(__tmp, std::forward<_Args>(__args)...);
(gdb) bt
[snipped]
#33 PrefabSource::PrefabSource (this=0x18db3ff2c0) at C:/_Projects/VCVRack/Rack-SDK-2/plugins/vcv-prefabs/src/models/PrefabSource.hpp:15
#34 std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, PrefabSource>::pair (this=0x18db3ff258) at C:/msys64/mingw64/inclu
de/c++/12.2.0/bits/stl_pair.h:195
#35 PrefabStore::total (this=0xfffffffffffffff8, this@entry=0x19823f01628) at C:/_Projects/VCVRack/Rack-SDK-2/plugins/vcv-prefabs/src/models/PrefabStore.cpp:36
#36 0x00007ffefbeecef3 in PrefabsWidget::step (this=0x1982e2ee730) at C:/_Projects/VCVRack/Rack-SDK-2/plugins/vcv-prefabs/src/widgets/PrefabsWidget.cpp:57
#37 0x00007fff2701382f in libRack!_ZN4rack6widget6Widget4stepEv () from C:\Program Files\VCV\Rack2 Pro\libRack.dll
[snipped]

Local debug build using Rack v2.2.3 (Debug) on Windows 10.

Makes the unused variable equals mixed with an accidental stack jump sound like a panic? Likely not but one does wonder why warnings are ignored when appearing in other builds. Have you thought about just leaving the object destruction to process exit? OK, wouldn’t work for insert delete. Have you thought of using a non-pointer encapsulated object for IconWidget?

EDIT: It doesn’t appear that listy, and “->” to “.” with no “new” is less typing. Plus it disappears on the capsule destructor.

EDIT2: When I say I’ve done C/C++, I mean I’ve done C with function pointers with the pre-processor and lots of Java to reading thick books on oolang. Forgot more than half of it unless I’d revise it in a few days, but then I’d have to have reason to remember the pertinent for purpose.

Got this on to read https://www.amazon.co.uk/Python-programming-Beginners-Programming-Languages-ebook/dp/B09RTLW7DP went pip install jupyter though. :smiley:

Hey all, I just pushed up 2.0.2

  • Unorganized prefabs (those not in a sub-directory) now show in the “untagged” menu.
  • Toggling module favorites is less finicky.
  • Ctrl must be held when opening the widget to see the full module library. The previous behavior of being able to toggle it while the menu was open was janky and uncomfortable to maintain.
  • Module library and search results now sorted.
  • Select how modules are sorted in module library using settings context-menu.
  • Toggle which tags are shown in module library using settings context-menu.

Thank you for the feedback and bug information. I will begin looking into this.

2 Likes

Oh good catch steve. Looks like icon widget is never initiali3: and so will have random values

The answer is in the header to say *iconwidget{nullptr} so it is initialized

1 Like

Thank you Sir! :+1: :saluting_face:

PR posted: Crash fix by SteveRussell33 · Pull Request #1 · dustinlacewell/vcv-prefabs · GitHub

3 Likes

Merged. Nightly updated. Thanks!

3 Likes

type name(params); has always worked in a local context. But yes a missing //system.gc(-O3); comment on line 40.5. I leave all the best sarcasm to my own code.

EDIT: the origin starts here APP->scene->addChildBelow(iconWidget, APP->scene->browser); and removing it before deletion of iconWidget?

Hey all.

So I’ve been reading the Rack code, and it looks like Patches and Selections have the same JSON format.

So theoretically, I could make Prefabs:

  • Show your patches in the widget menu
  • Let you drag whole patches to the current rack

Is this something that would be useful / wanted?

4 Likes

Yes, absolutely!

2 Likes