6

I want to create a VST instrument that has 16 MIDI inputs and at least 16 audio outputs. Similar to how kontakt or halion do this.

Any ideas?

Gustavo Mori
  • 8,319
  • 3
  • 38
  • 52
  • 1
    But you do have some experience with vst programming already? I find it surprising that 16 channels should be more diffult to implement than 2 ones, this is not the case when building vst plugins with software like SynthMaker (which is the only way I have done it so far). There, you can just add an arbitrary amount of inputs and outputs. – leftaroundabout May 26 '11 at 16:41
  • Some experience, I have used synth maker before to. But my new project needs to be in C++. – Daniel Rodrigues May 26 '11 at 17:09
  • 2
    Another thing: do you really need 16 MIDI inputs, or just 16 MIDI _channels_ (which is the number offered by any MIDI connection)? – leftaroundabout May 26 '11 at 17:56
  • 16 Midi channels I guess. I want to be able to control 16 different sounds from one vst and I want each of those channels to have at least 1 audio output. – Daniel Rodrigues May 26 '11 at 18:17

1 Answers1

4

As @leftaroundabout noted, it's unlikely that you need 16 inputs and outputs, especially for an instrument. However, having 16 MIDI inputs and 16 audio outputs is very common for drum machines and other multitracked instruments where the user might want to process each voice individually. Audio inputs in general are not particularly useful for instruments as a whole.

That said, you simply instantiate your plugin like so:

MyPlugin::MyPlugin(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, 0, kNumParameters) {
  if(audioMaster) {
    setNumInputs(0);
    setNumOutputs(16);
  }
  // other constructor stuff ...
}

That's your starting point. However, since the vast majority of plugins are stereo only, there is a bunch of other work you will need to do to get the host to deliver you 16 output channels (assuming it supports it). You will likely need to call getSpeakerArrangement() and setSpeakerArrangement() at some point, and also override getOutputProperties().

As for the MIDI channels, the host should not treat them any differently than normal. You will be delivered regular MIDI events, in the form of VstMidiEvents which will contain regular MIDI data (ie, for all 16 channels if the user so chooses). This is the easy part -- it's getting the outputs set up that's the trick.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
  • I assume you know how Kontakt works. How do I setup my vst so that each midi channel can be sent to a different channel inside of the vst? – Daniel Rodrigues May 26 '11 at 18:55
  • 2
    All midi events are sent together. Manually separate the incoming midi events according to channel number. – Shannon Matthews May 27 '11 at 00:35
  • 1
    What @Shannon said. ;) Basically, you grab the lower nibble from the status byte to get the channel and send it to the respective voice. How you handle the 16 channels is part of the internal design of your plugin and has nothing to do with the the VST framework as a whole. – Nik Reiman May 27 '11 at 07:04
  • @Nik, do you know if there is any example code available. I would like to see what that might look like. – Daniel Rodrigues May 27 '11 at 12:39
  • @Daniel, look here: http://www.gweep.net/~prefect/eng/reference/protocol/midispec.html And here: http://www.srm.com/qtma/davidsmidispec.html – Brad May 27 '11 at 13:06
  • So, I got the basics down. Not I'm wondering how can assign each midi channel to an audio output. (Midi Ch. 1 - Audio Ch. 1, Midi Ch. 2 - Audio Ch. 2, etc.) Any thoughts? – Daniel Rodrigues Jun 03 '11 at 17:08