-
Notifications
You must be signed in to change notification settings - Fork 1
template module simple
senso edited this page Jun 22, 2026
·
2 revisions
#example #template #simple #data #callback
Minimal starting template for new modules.
| Module Name | template simple |
| Type | mtSimple |
| Color | clDataModuleColor |
| Source | examples/TemplateModuleSimple/ |
The simplest possible working module. Converts a frequency input (Hz) to a period output (ms) using the formula period = 1000 / freq. This is the recommended starting point for new modules.
| # | Name | Type | I/O | Range | Scale | Default | Callback |
|---|---|---|---|---|---|---|---|
| 0 | freq |
ptDataFader |
Input | 0.1 – 20000 Hz | scLog |
50 | ctNormal |
| 1 | period |
ptDataFader |
Output (ReadOnly) | 0.05 – 10000 ms | scLog |
0.05 | None |
-
onCallBack: When the frequency input changes (identified byCallBackId), callscomputePeriod()which calculatesperiod = 1000 / freq(with a divide-by-zero guard). -
onProcess: Not used (DontProcess = TRUE).
-
Callback IDs: Uses named constants (
FDR_FREQ_CBID) — the recommended modern pattern -
Event binding: Binds
UsineEventClassmembers to parameters viasetEventClass() -
Read-only outputs: Output parameters marked
ReadOnly = TRUE - DontProcess: Skips audio processing when not needed
-
Logarithmic scale: Uses
scLogfor perceptually linear frequency/time controls
class TemplateModuleSimple : public UserModuleBase
{
private:
UsineEventClass fdrFreq;
UsineEventClass fdrPeriod;
void computePeriod();
public:
void onGetModuleInfo(TMasterInfo*, TModuleInfo*) override;
void onInitModule(TMasterInfo*, TModuleInfo*) override;
void onGetParamInfo(int, TParamInfo*) override;
void onCallBack(TUsineMessage*) override;
};
void TemplateModuleSimple::onCallBack(TUsineMessage* Message)
{
if (Message->wParam == FDR_FREQ_CBID)
computePeriod();
}
void TemplateModuleSimple::computePeriod()
{
float freq = fdrFreq.getData();
if (freq > 0.0f)
fdrPeriod.setData(1000.0f / freq);
}onGetModuleInfo · onInitModule · onGetParamInfo · onCallBack · onProcess
- TemplateModule — Full template with all callback stubs
- DataMultiply — Another simple data processing example