How would I go about programmatically interacting with VST(i) Plugins to synthesize audio?

后端 未结 1 1245
不知归路
不知归路 2020-12-30 08:02

Take, for example, the VSTi Triforce, by Tweakbench. When loaded up in any VST host on the market, it allows the host to send a (presumably MIDI) signal to the VSTi. The V

相关标签:
1条回答
  • 2020-12-30 08:24

    Well, since you asked, the ideal language for a project like this is going to be C++. Although there are wrappers for higher-level languages such as Java & .NET for the VST SDK, I couldn't find one for Ruby (though I did find this rather cool project which lets you program VST plugins in Ruby). So you will be stuck doing some degree of C/C++ integration on your own.

    That said, you have basically two options here:

    1. Write a VST Host in C++, and launch it as a separate process from within Ruby.
    2. Integrate your Ruby code directly to the VST SDK, and load the plugin DLL's/Bundles directly from your code. This is probably the cleaner but harder way to accomplish your goal.

    I wrote up a VST host programming tutorial on my blog awhile back which you may find useful in either case. It details how you open and communicate with VST plugins on both Mac OSX and Windows. Once you have gotten your host to load up the plugins, you need to be able to either send MIDI events directly to the plugin, either by reading them from file or some type of communication between your Ruby code and the VST host (ie, a named pipe, socket, file, etc.). If you are unfamiliar with the MIDI protocol, check out these links:

    • The MIDI technical fanatic's brainwashing center (silly name, serious resource)
    • The Sonic Spot's MIDI file specification (in case you need to read MIDI files)

    As you might have already figured out, VST is fundamentally a block-based protocol. You request small blocks of audio data from the plugin, and you send along any MIDI events to the plugin right before it processes that respective block. Be sure not to ignore the MIDI delta field; this will ensure that the plugin starts processing the MIDI event directly on the desired sample. Otherwise, the plugin will sound a bit off-tempo, especially in the case of instruments.

    The VST SDK is also based around floating-point blocks, so any data you get back will contain individual samples in the range { -1.0 .. 1.0 }. Depending on your desired output format, you may need to convert these to some other format. Fortunately, there seems to be a Ruby binding for the audiofile library, so you may be able to send your output into that in order to generate a proper AIFF/WAV file.

    In all, it'll be a fair amount of work to get to your desired end goal, but it's not impossible by any means. Good luck!

    0 讨论(0)
提交回复
热议问题