/**************************************************************************** * * Audio Framework * --------------- * **************************************************************************** * ModLAHLimiterExample.c **************************************************************************** * * Description: Multi-channel soft knee limiter with look ahead * * Copyright: DSP Concepts, Inc, 2007 - 2017 * 1800 Wyatt Drive, Suite 14 * Santa Clara, CA 95054 * ***************************************************************************/ /** * @addtogroup Modules * @{ */ /** * @file * @brief Multi-channel soft knee limiter with look ahead */ #define NOREDEF #include "Framework.h" #include "Errors.h" #include "VectorLib.h" #include "ModLAHLimiterExample.h" #ifdef __cplusplus extern "C" { #endif /* ---------------------------------------------------------------------- ** Audio module class object. This describes the audio module to the ** framework. It contains pointers to functions and number of ** variables. ** ------------------------------------------------------------------- */ CREATE_MODULE_CLASS(Class_awe_modLAHLimiterExample, (1 + 4)) AWE_MOD_SLOW_ANY_CONST const Class_awe_modLAHLimiterExample awe_modLAHLimiterExampleClass = { { { awe_modLAHLimiterExampleConstructor, CLASSID_LAHLIMITEREXAMPLE, }, awe_modLAHLimiterExampleProcess, // Processing function IOMatchUpModule_Bypass, // Bypass function 0, // Set function 0, // Get function 0, // Set State function ClassModule_PackArgCounts(1, 4), // (Public words, private words) {0x00000001, 0x00000000}, // Specifies which variables are floating-point }, #ifdef BUILD64 { offsetof(awe_modLAHLimiterExampleInstance, maxDelayTime), offsetof(awe_modLAHLimiterExampleInstance, max_abs), offsetof(awe_modLAHLimiterExampleInstance, core), offsetof(awe_modLAHLimiterExampleInstance, delay), offsetof(awe_modLAHLimiterExampleInstance, mult), } #endif }; /* ---------------------------------------------------------------------- ** Memory allocation function. This is required because the module ** requires additional memory outside of its instance structure. ** ------------------------------------------------------------------- */ AWE_MOD_SLOW_CODE ModInstanceDescriptor *awe_modLAHLimiterExampleConstructor(INT32 * FW_RESTRICT retVal, UINT32 nIO, WireInstance ** FW_RESTRICT pWires, size_t argCount, const Sample * FW_RESTRICT args) { // Create the module which holds the overall subsystem awe_modLAHLimiterExampleInstance *S = (awe_modLAHLimiterExampleInstance *) BaseClassModule_Constructor((ModClassModule *) &awe_modLAHLimiterExampleClass, retVal, ClassModule_PackFlags(1, 1, 2), pWires, argCount, args); if (S == NULL) { return 0; } AWE_UNUSED_VARIABLE(nIO); { WireInstance *max_absWires[2]; max_absWires[0] = pWires[0]; max_absWires[1] = pWires[2]; S->max_abs = (awe_modMaxAbsInstance *) ClassModule_Constructor(CLASSID_MAXABS, retVal, ClassModule_PackFlags(1, 1, 0), max_absWires, 0, (Sample *)NULL); if (S->max_abs == NULL) { // Error code is in *retVal return 0; } } { WireInstance *coreWires[2]; Sample coreArgs[12]; coreArgs[0].fVal = -20.0f; // core.threshold coreArgs[1].fVal = 0.0f; // core.gain coreArgs[2].fVal = 0.75f; // core.slope coreArgs[3].fVal = 2.0f; // core.kneeDepth coreArgs[4].fVal = 4.0f; // core.ratio coreArgs[5].fVal = 20.0f; // core.attackTime coreArgs[6].fVal = 100.0f; // core.decayTime coreArgs[7].fVal = 0.0f; // core.currentGain coreArgs[8].fVal = 0.5f; // core.sharpnessFactor coreArgs[9].fVal = 0.00104112434f; // core.attackCoeff coreArgs[10].fVal = 0.000208311627f; // core.decayCoeff coreArgs[11].fVal = 0.0f; // core.envState coreWires[0] = pWires[2]; coreWires[1] = pWires[3]; S->core = (awe_modAGCLimiterCoreInstance *) ClassModule_Constructor(CLASSID_AGCLIMITERCORE, retVal, ClassModule_PackFlags(1, 1, 0), coreWires, 12, (Sample *)coreArgs); if (S->core == NULL) { // Error code is in *retVal return 0; } } { WireInstance *delayWires[2]; Sample delayArgs[3]; delayArgs[0].fVal = S->maxDelayTime; // delay.maxDelayTime delayArgs[1].fVal = S->maxDelayTime; // delay.currentDelayTime delayArgs[2].iVal = 561; // delay.stateHeap delayWires[0] = pWires[0]; delayWires[1] = pWires[2]; S->delay = (awe_modDelayMsecInstance *) ClassModule_Constructor(CLASSID_DELAYMSEC, retVal, ClassModule_PackFlags(1, 1, 0), delayWires, 3, (Sample *)delayArgs); if (S->delay == NULL) { // Error code is in *retVal return 0; } } { WireInstance *multWires[3]; multWires[0] = pWires[3]; multWires[1] = pWires[2]; multWires[2] = pWires[1]; S->mult = (awe_modAGCMultiplierInstance *) ClassModule_Constructor(CLASSID_AGCMULTIPLIER, retVal, ClassModule_PackFlags(2, 1, 0), multWires, 0, (Sample *)NULL); if (S->mult == NULL) { // Error code is in *retVal return 0; } } return ((ModInstanceDescriptor *) S); } /* ---------------------------------------------------------------------- ** Real-time Processing function. ** ------------------------------------------------------------------- */ AWE_MOD_FAST_CODE void awe_modLAHLimiterExampleProcess(void *pInstance) { awe_modLAHLimiterExampleInstance *S = (awe_modLAHLimiterExampleInstance *) pInstance; ClassModule_ExecuteNP((ModuleInstanceDescriptor *)S->max_abs); ClassModule_ExecuteNP((ModuleInstanceDescriptor *)S->core); ClassModule_ExecuteNP((ModuleInstanceDescriptor *)S->delay); ClassModule_ExecuteNP((ModuleInstanceDescriptor *)S->mult); } #ifdef __cplusplus } #endif /** * @} * * End of file. */