Close

C# VST host (DAW)

A project log for VSTiBox

VSTiBox is a synthesizer for hosting VST software synths.

jan-bertJan Bert 09/07/2018 at 17:150 Comments

For quick prototyping C# is a great language. For highly optimized real-time audio processing C++ is the better choice. Nevertheless I wanted C# as the language for my custom VST host (often called DAW) because of the relatively quick development time and the large number of libraries that I could use. C# offers support for unmanaged code with which you can still use pointers to process audio in a relatively efficient way. 

VST plugins

I used VST.NET (https://github.com/obiwanjacobi/vst.net) to load the VST plugins, write midi messages to it and get the audio buffer. The guy who wrote this stuff has put some serious time and development effort in it for which I am very grateful. The only downside is that plugin processing runs from a single dispatched thread. That means that all simultaneous VST's that run in my host are processed from that single thread. I think that the bigger VST's handle their own threading and this is not a problem, but when you are using VST's that only run on the thread from  which they are called, this is a serious downside. This problem is discussed in the forums and no solution exists. 

I will keep my eye open for other VST host libraries written in C++, and am probably going to rewrite the whole audio processing in pure C++ and keep the GUI layer in C#. Nevertheless I am very pleased with the current performance of my software. I am able to run four heavy plugins simultaneously at a buffer size of 128 samples. Often I can use some more medium weight plugins and use all 8 channels. Effect plugins are also supported. I tested it briefly and it is basically working, but I consider it to be still under development.  

ASIO

For Asio handling I tested both BlueWave.Interop.Asio (https://www.codeproject.com/Articles/24536/Low-Latency-Audio-using-ASIO-Drivers-in-NET?msg=4526889) and NAudio. Both work fine, but the BlueWave performed better to my opinion. I say this with care because it could very well be the same code base. I haven't looked into the code behind the NAudio asio handling. The BlueWave project had a small bug with did not terminate the ASIO driver correctly at shutdown. This resulted in having to reboot every single time after shutting down a debug session in order to get the audio to work again. After I got tired of doing so, I decided to fix the bug. The updated source is on my github. 

MIDI

For MIDI input from my Nord and an Arturia Beatstep, I tried to use midi-dot-net (https://code.google.com/archive/p/midi-dot-net/). Unfortunately the Juli@ does not support kernel32 winmm.dll midi! The only way I could get MIDI in and output was to use DirectMusic midi. For that I used DirectMidi.net (http://directmidinet.sourceforge.net). 

UI controls

Most of the UI controls I have written myself. The ringslider above the physical encoder was one that was very specific. Also the scroll-list operated by the main menu encoder I build myself.  

Hardware monitor

To monitor the CPU temperature I used OpenHardwareMonitor (https://openhardwaremonitor.org) which continuously displays the temperature in the main screen. When installing the CPU cooler I damaged the bearings and decided to just remove the power from the CPU cooler. Amazingly it always runs cool. Possibly beacuse of the airflow through the case. But because of this I wanted to see the CPU temperature at the main screen. 

PDF Viewer

Sheet music in PDF format can be added to a song (bank). I use PDFViewer from https://www.codeproject.com/Articles/37458/PDF-Viewer-Control-Without-Acrobat-Reader-Installe to to display it.

Smooth instrument transition

I personally find this the most interesting part to write, because I came up with a unique musical feature that I haven't found in other DAW software for live usage. When a channel is enabled, the button is illuminated blue. When the button is pressed the state of the channel goes to 'pending disable' . The sound does not directly go away but keeps on going as long as the keys or sustain pedal remain pressed. New keys will not play on the 'pending disabled' channel. Once all the active keys are released the channel state goes to 'Disabled'. In this way you can very fluently change between different sounds. I recently found out that the latest Nord Stage3 also has this feature, but hey it cannot run VST's :)

Other features

I'll just name a few other interesting features I implemented:

Discussions