[Clam-devel] generator script: example of use from an irc question
Hernán Ordiales
h at ordia.com.ar
Sun Mar 16 08:58:12 PDT 2008
Yesterday at the irc 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 at the irc (i'm hordia), but today at my console...
cd CLAM/scripts/TemplatedPluginsGenerator
vi ThresholdTrigger.template
Name:ThresholdTriggerTemplate
BaseClass:Processing
i:AudioInPort,Audio Input
ic:0,1,Threshold
oc:0,1,Trigger
:wq
./TemplateGenerator.py ThresholdTrigger.template
./TemplatedPluginsGenerator.py ThresholdTrigger
ThresholdTriggerTemplate "Hernán Ordiales" GPL 2008
cd CLAM/plugins/ThresholdTrigger
vi ThresholdTrigger.hxx
#include <cmath>
bool Do()
{
bool result = Do( mAudioInput.GetAudio() );
mAudioInput.Consume();
return result;
}
bool Do(const Audio& in)
{
int size = in.GetSize();
DataArray& inb = in.GetBuffer();
TData threshold = mThreshold.GetLastValue();
bool trigger = 0;
for (int i=0;i<size;i++)
{
if (std::fabs(inb[i])>threshold)
trigger = 1;
}
mTrigger.SendControl(trigger);
return true;
}
:wq
scons install
NetworkEditor
It's a very simple (and poor) implementation but was just to show the
idea of how those scripts can save a lot of work.
BTW, the scripts was improved, now you can also set the port name
(port type + port name) and the incontrol bounds in the input file.
cheers
--
Hernán
http://h.ordia.com.ar
GnuPG: 0xEE8A3FE9
More information about the clam-devel
mailing list