This script is about a basic code generation of a CLAM plugin. In some point I think this is some kind of meta-programming or perhaps the term “automatic programming” fits better. The basic idea is to specify some basic features of the planned new processing in a plain text and then, generate some code with the script, saving in this way many of the often repetitive and mechanical work needed to set-up a new processing from scratch. Main intention is to allow concentrate in the Do() function or plugin details quickly.
As an example, I will reproduce here how I worked with me some time ago:
One day, in the irc #clam channel:
“[11:51] <groton> Consul, do you know if there is any trigger-like processing unit, list when the volume gets louder than a threshold or something like that”
I’m not Consul in the irc (I’m hordia), but next day at my console…
In words, this means a Processing template named “ThresholdTriggerTemplate” using “Processing” as a base class and with one input of “AudioInPort” type named “Audio Input”, with one in control in the 0..1 range named “Threshold” and one out control named “Trigger”. Of course, you can add as many inputs/outputs of ports or controls as you want.
This script creates the template:
And this one the processing plugin:
Again in words, this means create a new processing called “ThresholdTrigger” based on the “ThresholdTriggerTemplate” filling the copyright with my name plus the current year and the license with the GPL text.
A final edit just typing the required code for the Do() function:
bool result = Do( mAudioInput.GetAudio() );
bool Do(const Audio& in)
int size = in.GetSize();
const DataArray& inb = in.GetBuffer();
TData threshold = mThreshold.GetLastValue();
bool trigger = 0;
for (int i=0;i<size ;i++)
trigger = 1;
At this point, just remains add the basic SConstruct file for a CLAM plugin, compile it with the corresponding clam_prefix and install it:
And ready to use…
This example it’s very simple and has a poor implementation but was just to show the idea of how those scripts can save a lot of work.
Update: I made a frontend for these scripts: ProcessingCodeGenerator