Saturday 11 May 2013

A Simple Gain Plug-In

For purposes of demonstration let's make a simple gain plug-in. Before we write any code let's lay out the information that the host will need to know about the plug-in:

Parameter Information:

How many parameters does the plug-in have?

One (the gain).

What are the parameters called?

Let's call it 'Gain'.

What are the parameter's values?

We need to tell the host the current gain setting of the plug-in.

Actions To Complete:

We also need to plan what our plug-in will do when the host asks it to do things:
Set this parameter to this value.
We will take the new value and store it somewhere for use in our processing.

Process this audio.

We will take the audio and apply the gain defined by our gain parameter.

What does the plug-in look like?

Tell the host it will need to construct its own interface for our plug-in.

Making a Project in The Introjucer:

The Introjucer is very handy when it come to getting started with a new plug-in. When we create a new Audio Plug-In project we will be given some template code to work from. This has default answers for everything a host might ask of our plug-in. This then leaves us to change the ones we want to use in our plug-in. 

Open The Introjucer and create a new project (File - New Project). Call it what ever you wish, I'm going to call mine 'GainPlugin'. Then, in the project type menu, select 'Audio Plug-In'. Save this project where you want and you are ready to start looking at some source code.

When you have created your project you will be given the Project Settings editor screen. This is a series of setting to do with our plug-in which we can edit using The Introjucer's GUI. If you mouse over them you should get a description of what they do at the bottom of the window. If you were making a plug-in for release you would need to edit some of these fields, they give information about the plug-in company and the unique id of the plug-in. For now we wont worry about any of this.

Click on the 'Files' tab on the top left. You should now see four source code files. 'PluginProcessor.cpp', 'PluginProcessor.h', 'PluginEditor.cpp' and 'PluginEditor.h'. These contain the source code for our plug-in. The first two describe the operation of the plug-in, what the parameters are and the audio processing. The second two describe a custom GUI. As we are not bothering with a custom GUI for now we will ignore this second pair of files.

A discussion of why there are two files for each job is beyond the scope of this blog. The '.h' file is a header file while the '.cpp' file is the main C++ source code. If you want to know more you will have to read some C++ programming literature.

In the next post we will open up one of these files and start to edit it.

Have a nice day now!
Sean

No comments:

Post a Comment