VST Hosting: how to mux instruments?

SDK for VST 3 audio plug-in and host development.
newage_lightbulb
Posts: 3
Joined: Sun Jan 06, 2019 11:25 pm

VST Hosting: how to mux instruments?

Postby newage_lightbulb » Mon Jan 14, 2019 8:59 pm

Hello, I have written a very basic VST host that will play a MIDI file to a WAV. It currently renders one or all tracks with one instrument. I would like to be able to render multiple instruments but I'm not sure what the next step is.

Two ideas occur to me:
- I could setup my instruments as a chain, passing silence into the first instrument, the result of instrument 1 into instrument 2 (processReplacing), ..., to instrument N
- I could separately process each instrument and somehow mux the streams.

Both require a fair amount of work so I am hoping for a pointer or two before I dive in.

Thanks!

pongasoft
Posts: 66
Joined: Sun Mar 11, 2018 5:57 pm

Re: VST Hosting: how to mux instruments?

Postby pongasoft » Tue Jan 15, 2019 1:23 pm

When I started, it was very confusing to me how to handle more than one track/instrument (or "mux" if I understand how you call it), but in the end it turns out to be very simple. You simply add (mathematic sum) each instruments...

...and by "adding" it is literally adding (+) each sample with each other and write the result to the buffers provided

I do not know all the requirements of your design but sounds to me like solution 2 would be a lot easier to implement.

Also as a side note, you mention "processReplacing" which I believe is a VST2 concept. Steinberg officially ended VST2 back in October 2018 so I would suggest looking at VST3 instead.

Yan

newage_lightbulb
Posts: 3
Joined: Sun Jan 06, 2019 11:25 pm

Re: VST Hosting: how to mux instruments?

Postby newage_lightbulb » Tue Jan 15, 2019 3:40 pm

Hi Yan, thanks for replying.

Audio programming is pretty new to me so please excuse any dumb questions ... but regarding adding the samples I was worried about limits. Say if two instruments give a value of 1 on a frame, that would sum to two. Then I would clamp that value ... would that result in clipping?

I guess the only real way to know is to try it!

And regarding processReplacing, I thought that was the new function to call. But I'm kind of guessing my way through, if you can point to some documentation around this I would really appreciate it.

Thanks again!

pongasoft
Posts: 66
Joined: Sun Mar 11, 2018 5:57 pm

Re: VST Hosting: how to mux instruments?

Postby pongasoft » Wed Jan 16, 2019 1:45 pm

newage_lightbulb wrote:Hi Yan, thanks for replying.

Audio programming is pretty new to me so please excuse any dumb questions ... but regarding adding the samples I was worried about limits. Say if two instruments give a value of 1 on a frame, that would sum to two. Then I would clamp that value ... would that result in clipping?



I would not suggest clamping. The sum is the sum. I agree with you it seems that it is going to be reaching > 1 very quickly but remember that if you sum a bunch of instruments, what matters is the sum of ALL of them. For example, if you have a plugin that generates a sine wave varying between +2 and -2 and another plugin that generates a sine wave in opposite phase (varying between -2 and +2), each plugin is obviously going beyond +1, but the sum of those 2 plugins will be total silence!

If that becomes an issue, I would suggest adding gain knobs for your instruments so that the USER (not the software) can lower/raise each instrument according to what sounds "right" and not a hard mathematical formula (clamp).

newage_lightbulb wrote:And regarding processReplacing, I thought that was the new function to call. But I'm kind of guessing my way through, if you can point to some documentation around this I would really appreciate it.


The VST3 SDK (which can download from https://www.steinberg.net/en/company/developers.html) comes with bunch of example and as you can see here https://github.com/steinbergmedia/vst3_public_sdk/blob/master/samples/vst/again/source/againsimple.cpp#L203 the method you implement is

Code: Select all

 tresult PLUGIN_API AGainSimple::process (ProcessData& data)


I would suggest reading the documentation that comes with the SDK (index.html at the root).

Also, and this is personal promotion ;), I would suggest looking at Jamba (https://github.com/pongasoft/jamba) a framework I am developing to help in writing VST3 (as well as VST2 wrapper and Audio Unit wrapper) plugins. Especially when you start, you can create a fully working plugin with a simple command line (vs copy/paste/scratch your head to figure out what to change with the plain VST SDK).

Yan


Return to “VST 3 SDK”

Who is online

Users browsing this forum: No registered users and 1 guest