tags:

views:

529

answers:

3

I would like to make a simple VST plugin that does this :

  1. analyze an audio stream (volume, beat, etc...)
  2. has triggers on the analyzer's output (e.g. do something when volume > threshold)
  3. generate MIDI events based on the triggers

This is to be able to chain plugins, even if they are not designed for it. For example I could control the gain of a compressor with the envelope of an audio stream, simply by connecting the MIDI OUT of my plugin to the MIDI IN of the compressor's gain button.

The problem is I don't know how to do this. Is there support for direct MIDI connections like this in VSTs ? Or maybe I need some sort of "virtual midi device" for interconnects ?

+2  A: 

Your hunch here is probably correct; this task will be easier to accomplish by writing a virtual MIDI device instead of a VST plugin. It is possible to send MIDI events to a sequencer using the sendVstEventsToHost() call, but the problem is that the documentation never specifies how the host is required to react to these events. Many hosts simply ignore them, and I certainly can't think of one which allows easy routing from a plugin to a MIDI channel (maybe plogue bidule?).

You might be able to accomplish this with Audio Units with the kAudioUnitType_Generator plugin type... though I've never written such a plugin, my impression was that this is what you'd use to generate MIDI to the host. But again, the problem here is that I'm not sure how the host would allow you to route audio to the plugin and accept MIDI from it.

At any rate, your idea implemented as a plugin will be the most difficult to implement when you want to standardize its behavior for the most widely used sequencers. I think that a far easier way to accomplish what you want is to create a virtual MIDI device, as you'd thought of already, and then use rewire to route an input signal to your program.

Edit: Here's some resources on writing MIDI drivers for various systems:

Nik Reiman
Thanks for the clarifications. Any pointers on writing such a virtual midi device ? Googling "virtual midi" returns some cheesy sharewares from the 90's, and I can't find documentation on how to write such a driver.
Luper Rouch
+1  A: 

VST plugins do not support direct midi connections, they can only have midi in/out ports.

It is still possible to do it though, you just need a host that supports routing midi from one plugin to another. Modular hosts such as EnergyXT, Bidule, AudioMulch and Console excel here. They all allow audio and midi signals to be routed freely (except no feedback paths). But it also may be possible in hosts with more 'traditional' mixer style vst racks. (For example, AFAIK Reaper will forward any midi from one plugin to the next.)

A: 

If you want to build your plugin in .NET take a look at VST.NET

obiwanjacobi