Details and comparison of miRack and VCV Rack multithreading implementation and performance

June 9, 2020

I implemented multitheading for miRack audio engine back in 2018 when it was a project targeting single-board computers because with slower CPUs it's essentially a requirement to be able to run any decently-sized patches. The implementation (available here and is used in miRack app with minor modifications) is based on idea of having arrays for module input and output values, and a lock-free concurrent work queue implementation by Cameron Desrochers.

For each rendering cycle, say 512 samples (steps), all rack modules are pushed into to a work queue, also with start and end steps to process (so initially that is 1 to 512), then worker threads are woken up. The worker threads dequeue modules from the work queue and check that values for the step being processed are present for all module inputs (for disconnected inputs this is always true). If all values are available, the module is processed and output values are saved straight in input arrays of modules connected to each output for the next step number. The process continues until the end step is reached or until any of the input values are not available, in which case the module is pushed back into the work queue (updating the start step if needed) and another module is pulled from the work queue. Once there is no more modules in the work queue, the workers pause, and the rendering cycle completes. This implementation ensures that workers don't wait unless they have to.

Until recently I never looked at the multithreading implementation that later appeared in VCV Rack (available here), but wanted to run some benchmarks at some point.

During normal opearation, VCV Rack implementation uses spinlocks only. For each step in a rendering cycle, workers process only that single step for each module. Once there are no more modules for a worker to pick up, it will spinwait until all workers have finished, then values are transferred from outputs to connected inputs, and the workers are woken up to process the next single step. This implementation causes the workers to wait a lot instead of possibly processing next steps for some modules.

Now to the benchmark. I used the current miRack code and the latest VCV Rack code. All graphics rendering was disabled, as well as audio output. For VCV Rack, updating port lights was also disabled - it involves a lot of computations that substantially affect the results while not being related to audio processing.

The audio engines were told to process 1024 samples (steps) as fast as they can, and it was repeated 1000 times for a single thread then for 2, 3, and 4 worker threads. The tests were performed on a CPU with 4 physical cores. The following patches (by VCV Rack Ideas were used):

1st Patch Results

ThreadsmiRack TimemiRack %VCV Rack TimeVCV Rack %Ideal %
14242ms100.00%6313ms100.00%100.00%
22236ms52.71%5179ms82.04%50.00%
31620ms38.19%4604ms72.93%33.33%
41341ms31.61%4312ms68.30%25.00%

2nd Patch Results

ThreadsmiRack TimemiRack %VCV Rack TimeVCV Rack %Ideal %
14904ms100.00%6203ms100.00%100.00%
23054ms62.28%4944ms79.70%50.00%
32575ms52.51%4578ms73.80%33.33%
42357ms48.06%4455ms71.82%25.00%

"%" column shows time difference to the single-threaded case, and "Ideal %" shows the best theoretically achievable improvement of N times for N threads.

Also I should note that initially it was about comparing multithreaded speed increase, not absolute values (at least because miRack and VCV Rack use different versions of some of the patch modules), but absolute values turned out to be quite interesting as well. As I mentioned above, port lights update code adds about another second to VCV Rack results.

·

miRack AU plugin is now available on macOS

June 8, 2020

miRack AU plugin is now available in Reaper, Logic Pro and GarageBand on macOS 10.15 (Catalina). Unfortunately, other DAWs don't seem to support it currently.

·

miRack AUv3 plugin is now available

May 29, 2020

The wait is over, miRack AUv3 plugin is now available in your favourite host app or DAW. Can be used as an instrument or effect, and supports parameter automation. Enjoy!

·

miRack is now available on macOS 10.15

May 27, 2020

Many users asked for a way to work on their miRack projects on desktop, too. Initially I was planning to support exporting to and opening patches made in VCV Rack, but that does not seem to be achievable at the moment. Therefore, miRack is now also available as a free macOS app.

It contains all the same modules, supports Core MIDI and Ableton Link, and can open patches directly from miRack iCloud folder.

Several things to mention:

  • Although miRack supports opening a patch (located on iCloud) on multiple devices at the same time, I noticed that the "patch changed remotely" notifications that are displayed when the patch is changed on another device are a bit too annoying at the moment. This will be fixed in the next update, until then I recommend closing the app before opening the same patch on another device.

  • Currently, external assets, like samples loaded into certain modules, are not saved inside patch file. Therefore, when opening a patch with such modules on macOS after iOS (or the other way round), you will need to re-open assets in the modules using them. Asset management will be improved in the near future to solve this problems.

  • In general, it received much less testing than the iOS app, please report any issues you notice.

As it is essentially the iOS miRack app built for desktop, it requires macOS 10.15 (Catalina) or later to work.

·

Patch management functionality overhaul in miRack 2.11

May 19, 2020

Another update while finishing the last bits for the upcoming AUv3 release.

APP FEATURES

  • This build overhauls patch management functionality. Instead of a system document browser and non-conditional autosaving, there's now a more desktop-like open/save/revert and duplicate/rename functionality.

    Don't worry, miRack still does auto-save your work, but the last manually saved patch version is also preserved and can be reverted to.

  • Support for custom patch templates. Just place a patch in Templates folder inside miRack documents folder and it will be displayed on the new Create Patch from Template screen.

BUG FIXES

  • Fixed a freeze when closing/saving patch on some of the newer iOS devices.

  • Fixed a crash when using miRack with Studiomux IAA host app.

  • Fixed trigger mode not preserved in Holonic Systems Gaps module (may also fix other rare cases of module parameters not being preserved).

  • Fixed mute and solo buttons not working in Squinky Labs Mixer-8 module.

·

Multi-touch, Ableton Link, new modules, and more in miRack 2.10

April 30, 2020

It's been a while since the last miRack update, that's because I was working on several big features - AUv3, multitouch, variable sample rate support, and also Metal rendering (this one is almost not noticeable for users users but is quite important going forward).

AUv3 is already being tested by the beta testers and is looking good, with last bits and pieces left to be done. In the meanwhile, here's an update with everything else. There will be another one with some more fixes, and then AUv3.

App Features

  • Multi-touch. Enable in Tools menu to operate multiple knobs or other module controls at the same time.

  • Ableton Link support. Enable in Tools menu and use Stellare Modular Link module to synchronize your patch with other Link-enabled apps, including IAA host apps.

  • Variable sample rate. Audio engine now works at hardware sample rate. Preferred sample rate can be set in Tools -> Settings.

  • Metal rendering. This should reduce CPU usage and battery consumption.

Modules

  • Updated Audible Instruments module pack. Added Percussive Synthesizer (based on Mutable Instruments Peaks) and Tidal Modulator 2 (based on Mutable Instruments Tides 2) modules.

  • Updated Befaco, Frozen Wasteland, Squinky and Holonic Systems module packs.

  • Added MI module pack - based on AS modules by Alfredo Santamaria (hakken.com.mx)

  • Added Valley Amalgam (signal masher and multipler) and Dexter (powerful FM wavetable oscillator in a single module).

  • Bogaudio spectre analyser modules are available again.

  • Submarine text display modules are available now.

Bug Fixes

  • Fixed some modules not showing under "Filter/VCF" tag.
·

miRack status update

March 9, 2020

It's been quiet recently with no app updates for quite some time (by miRack standards). This is because I need to implement a number of internal and UI changes required for the upcoming features. This required some research and experimentation to make sure everything I planned is possible and won't require significant API changes in the future, specifically so that I can release a stable SDK for plugin developers.

Everything went well, and although there's still stuff left to do, you can expect new modules and features soon - some have been discussed and promised before, and some I haven't mentioned yet.

·

miRack is now available on iPhone

January 9, 2020

IMPORTANT: If you've already purchased miRack on iPad, you will not be charged twice even though it may look as a separate purchase when viewing the app in the App Store on iPhone.

Surely creating complex patches is better done in miRack running on a big iPad Pro screen, and at first an iPhone version wasn't planned. However the recent addition of audio input support made it possible to use miRack to build modular audio effects running in the background. And finally the MIDI learn function added in the latest update allows to control a patch using external hardware or other apps, so that in many situations, the screen size is not important anymore. And of course some may want to use iPhone for patching for other reasons.

Therefore I'm happy to announce that miRack version 2.00 is available on the App Store and is a universal app now working on all devices running iOS 12 or later.

One other change in this update is a new 1-finger pan mode (enabled in the Tools menu and enabled by default on iPhone). It allows to pan the rack with just one finger which is more convenient when holding an iPhone.

·

miRack learning materials

December 20, 2019

Below I collected some links to tutorial videos that should help beginners to get started with miRack and modular synthesizers in general. This is just the first batch, the post will be updated.

Tutorials by Electronicsounds Audio

Very good quality beginner-friendly tutorials starting with miRack operation and basics of modular synthesis and moving to advanced topics. New videos added regularly, so the list here may be incomplete.

Playlist

Tutorials by SoundForMore

The same, great regularly updated tutorials, focusing on individual modules and features of miRack.

Playlist

Tracks by Ben Zangri

Many of these are not tutorials, but the patches are shown in videos and are simple enough to give an idea how to make generative music and/or use certain modules. See the playlist for more videos as only the ones with descriptive titles are included below.

Playlist

Tutorials by Omri Cohen

Omri specialises in creating VCV Rack tutorials (as well as hardware modular and music creation), so some of the modules shown in videos may not be available in miRack, but definitely see his channel for great modular synethesis content. Below are some of the tutorials explaining individual modules that can easily be followed in miRack.

·