-
Notifications
You must be signed in to change notification settings - Fork 1
audio volume
senso edited this page Jun 22, 2026
·
2 revisions
#example #audio #query #threading #simple
Multi-channel audio gain control with mute.
| Module Name | audio volume |
| Type | mtSimple |
| Color | clAudioModuleColor |
| Source | examples/AudioVolume/ |
A multi-channel audio volume module with a gain fader and mute switch. Demonstrates the audio query system for dynamic channel counts and thread-safe parameter handling with std::atomic.
Dynamic parameter count based on audio query (N = number of channels):
| # | Name | Type | I/O | Details |
|---|---|---|---|---|
| 0..N-1 |
in 1, in 2, ... |
ptAudio |
Input | Audio inputs (separator: "audio in") |
| N..2N-1 |
out 1, out 2, ... |
ptAudio |
Output (ReadOnly) | Audio outputs (separator: "audio out") |
| 2N | gain |
ptGainFader |
Input | Volume fader in dB (separator: "Volume") |
| 2N+1 | mute |
ptLeftLed |
Input | Mute toggle LED |
-
Audio Query: On creation, Usine shows a popup asking the user how many channels. Uses
sdkGetAudioQueryTitle()andsdkGetAudioQueryChannelList(). -
onCallBack: ComputescoeffGain = dBtoCoeff(gain) * (1 - mute)and stores it in astd::atomic<float>for thread safety. -
onProcess: For each channel, copies input to output and multiplies by the gain coefficient.
- Audio query system for dynamic multi-channel support
-
std::atomic<float>for thread-safe parameter sharing betweenonCallBackandonProcess -
ptGainFaderparameter type with dB scaling -
ptLeftLedas a mute toggle -
CanBeSavedInPreset = FALSE— excluding module from preset system - Separator labels for parameter grouping
void onGetModuleInfo(TMasterInfo*, TModuleInfo* pModuleInfo) override
{
pModuleInfo->QueryListString = sdkGetAudioQueryTitle();
pModuleInfo->QueryListValues = sdkGetAudioQueryChannelList();
pModuleInfo->QueryListDefaultIdx = 1;
}
int onGetNumberOfParams(int QIdx1, int QIdx2) override
{
numOfAudioInsOuts = sdkGetAudioQueryToNbChannels(QIdx1);
return numOfAudioInsOuts * 2 + 2; // ins + outs + gain + mute
}onGetModuleInfo · onGetNumberOfParams · onAfterQuery · onInitModule · onGetParamInfo · onCallBack · onProcess