How would I make an audio plugin that controls volume?

Hopefully @bozmillar might catch this next time he signs on. Or anyone else here that writes code :smiley:

Does anyone know of a tutorial that would explain how to make a super basic VST or AU plugin? Like just something you could insert on a channel in Logic and cut and boost volume? Or something with one knob that can pan left to right?

I obviously don’t need the plugin, but was more interested in seeing a sample of the entire code. And I was curious what GUI middleware engine you would build something like this in.

Why bother. Blue Cat’s free suite incluydes what you want, there’s a one control gain plug in there, and a stereo version too I think.
https://www.bluecataudio.com/Products/Bundle_FreewarePack/

Thanks Midge. I don’t actually need it for audio purposes. I wanted to look at the data flow inside the code. So I’m mainly interested in seeing how the plugin itself retrieves audio from the DAW, process it, then returns it to the DAW and sends it back down the signal chain. Then I wanted to try making some super basic edits to it (like maybe just changing the speed a which the fader moves and changing the color of a knob), then exporting the plugin, re-installign it, then seeing if I can get it to run properly.

So basically I’m experimenting with scripting plugins. No intention of publishing any of them, but I’d like to understand more about how they are designed.

1 Like

I had completely forgotten that Blue Cat runs on Mac. Thanks for the reminder. lol

You’ll want to start with a plugin framework. That will do most of the tedious work for you, to support the platform—Mac OS and Windows, VST/AU/AAX. The most likely choices are JUCE or IPlug. There are other choices—you can even script a plugin in Reaper, if you just want to play with algorithms. But if you want to build a plugin for general distribution, supporting multiple plugin types and OS’s that’s want you’ll want.

In a nutshell, you’ll code the user interface details—create your controls, and use the plugin framework to draw them when needed, and get their current settings. Then there’s the audio thread—basically, it’s running normally and does nothing, you override it to do your processing. You’ll get a buffer (or buffers for stereo, etc.), and you’ll act on each sample. For a gain plugin, that means multiplying each value in the buffer by the gain indicated by your gain control.

“Etc.” :wink:

2 Likes

basically what earlevel said.

basically, on the part of the plugin that does the processing is a function that receives an array of samples. So your DAW will take 500 samples (or whatever size it wants to give you) and gives those samples to the plugin to process.

Each samples is a float or a double that ranges from -1 to +1. So if you want to apply gain, you just take your gain value (let’s say 6dB, which is 2x) and multiply each sample by that gain value.

so

process(*inBuffer, *outBuffer, bufferSize){
for(int i=0; i<bufferSize; i++){
outBuffer[i] = inBuffer[i] * 2;
}
}

1 Like