@@ -264,7 +264,7 @@ bool isNumChannelsComboValid(const uint16_t numInputs, const uint16_t numOutputs
264264// --------------------------------------------------------------------------------------------------------------------
265265
266266struct PropertyListener {
267- AudioUnitPropertyID prop;
267+ AudioUnitPropertyID prop;
268268 AudioUnitPropertyListenerProc proc;
269269 void * userData;
270270};
@@ -348,7 +348,8 @@ class PluginAU
348348 fUsingRenderListeners (false ),
349349 fParameterCount(fPlugin .getParameterCount()),
350350 fLastParameterValues(nullptr ),
351- fBypassParameterIndex(UINT32_MAX)
351+ fBypassParameterIndex(UINT32_MAX),
352+ fResetParameterIndex(UINT32_MAX)
352353 #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
353354 , fMidiEventCount (0 )
354355 #endif
@@ -365,7 +366,7 @@ class PluginAU
365366 , fStateCount (fPlugin .getStateCount())
366367 #endif
367368 {
368- if (fParameterCount != 0 )
369+ if (fParameterCount != 0 )
369370 {
370371 fLastParameterValues = new float [fParameterCount ];
371372 std::memset (fLastParameterValues , 0 , sizeof (float ) * fParameterCount );
@@ -374,8 +375,17 @@ class PluginAU
374375 {
375376 fLastParameterValues [i] = fPlugin .getParameterValue (i);
376377
377- if (fPlugin .getParameterDesignation (i) == kParameterDesignationBypass )
378+ switch (fPlugin .getParameterDesignation (i))
379+ {
380+ case kParameterDesignationNull :
381+ break ;
382+ case kParameterDesignationBypass :
378383 fBypassParameterIndex = i;
384+ break ;
385+ case kParameterDesignationReset :
386+ fResetParameterIndex = i;
387+ break ;
388+ }
379389 }
380390 }
381391
@@ -923,13 +933,13 @@ class PluginAU
923933 case kAudioUnitProperty_FastDispatch:
924934 switch (inElement)
925935 {
926- case kAudioUnitGetParameterSelect:
936+ case kAudioUnitGetParameterSelect:
927937 *static_cast<AudioUnitGetParameterProc*>(outData) = FastDispatchGetParameter;
928938 return noErr;
929- case kAudioUnitSetParameterSelect:
939+ case kAudioUnitSetParameterSelect:
930940 *static_cast<AudioUnitSetParameterProc*>(outData) = FastDispatchSetParameter;
931941 return noErr;
932- case kAudioUnitRenderSelect:
942+ case kAudioUnitRenderSelect:
933943 *static_cast<AudioUnitRenderProc*>(outData) = FastDispatchRender;
934944 return noErr;
935945 }
@@ -1458,7 +1468,7 @@ class PluginAU
14581468 const float value = bypass ? 1 .f : 0 .f ;
14591469 fLastParameterValues [fBypassParameterIndex ] = value;
14601470 fPlugin .setParameterValue (fBypassParameterIndex , value);
1461- notifyPropertyListeners (inProp, inScope, inElement);
1471+ notifyPropertyListeners (inProp, inScope, inElement);
14621472 }
14631473 }
14641474 return noErr;
@@ -1480,12 +1490,12 @@ class PluginAU
14801490 #if DISTRHO_PLUGIN_WANT_TIMEPOS
14811491 {
14821492 const UInt32 usableDataSize = std::min (inDataSize, static_cast <UInt32>(sizeof (HostCallbackInfo)));
1483- const bool changed = std::memcmp (&fHostCallbackInfo , inData, usableDataSize) != 0 ;
1493+ const bool changed = std::memcmp (&fHostCallbackInfo , inData, usableDataSize) != 0 ;
14841494
1485- std::memcpy (&fHostCallbackInfo , inData, usableDataSize);
1495+ std::memcpy (&fHostCallbackInfo , inData, usableDataSize);
14861496
14871497 if (sizeof (HostCallbackInfo) > usableDataSize)
1488- std::memset (&fHostCallbackInfo + usableDataSize, 0 , sizeof (HostCallbackInfo) - usableDataSize);
1498+ std::memset (&fHostCallbackInfo + usableDataSize, 0 , sizeof (HostCallbackInfo) - usableDataSize);
14891499
14901500 if (changed)
14911501 notifyPropertyListeners (inProp, inScope, inElement);
@@ -1612,7 +1622,7 @@ class PluginAU
16121622 AUEventListenerNotify (NULL , NULL , &event);
16131623
16141624 if (fBypassParameterIndex == inElement)
1615- notifyPropertyListeners (kAudioUnitProperty_BypassEffect , kAudioUnitScope_Global , 0 );
1625+ notifyPropertyListeners (kAudioUnitProperty_BypassEffect , kAudioUnitScope_Global , 0 );
16161626 }
16171627 return noErr;
16181628
@@ -1821,7 +1831,12 @@ class PluginAU
18211831 DISTRHO_SAFE_ASSERT_UINT_RETURN (scope == kAudioUnitScope_Global || scope == kAudioUnitScope_Input || scope == kAudioUnitScope_Output , scope, kAudioUnitErr_InvalidScope );
18221832 DISTRHO_SAFE_ASSERT_UINT_RETURN (elem == 0 , elem, kAudioUnitErr_InvalidElement );
18231833
1824- if (fPlugin .isActive ())
1834+ if (fResetParameterIndex != UINT32_MAX)
1835+ {
1836+ fPlugin .setParameterValue (fResetParameterIndex , 1 .f );
1837+ fPlugin .setParameterValue (fResetParameterIndex , 0 .f );
1838+ }
1839+ else if (fPlugin .isActive ())
18251840 {
18261841 fPlugin .deactivate ();
18271842 fPlugin .activate ();
@@ -2180,6 +2195,7 @@ class PluginAU
21802195 const uint32_t fParameterCount ;
21812196 float * fLastParameterValues ;
21822197 uint32_t fBypassParameterIndex ;
2198+ uint32_t fResetParameterIndex ;
21832199
21842200 #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
21852201 uint32_t fMidiEventCount ;
@@ -2220,7 +2236,7 @@ class PluginAU
22202236 const PropertyListener& pl (*it);
22212237
22222238 if (pl.prop == prop)
2223- pl.proc (pl.userData , fComponent , prop, scope, elem);
2239+ pl.proc (pl.userData , fComponent , prop, scope, elem);
22242240 }
22252241 }
22262242
@@ -2845,7 +2861,7 @@ class PluginAU
28452861// --------------------------------------------------------------------------------------------------------------------
28462862
28472863struct AudioComponentPlugInInstance {
2848- AudioComponentPlugInInterface acpi;
2864+ AudioComponentPlugInInterface acpi;
28492865 PluginAU* plugin;
28502866
28512867 AudioComponentPlugInInstance () noexcept
@@ -2854,25 +2870,25 @@ struct AudioComponentPlugInInstance {
28542870 {
28552871 std::memset (&acpi, 0 , sizeof (acpi));
28562872 acpi.Open = Open;
2857- acpi.Close = Close;
2858- acpi.Lookup = Lookup;
2859- acpi.reserved = nullptr ;
2873+ acpi.Close = Close;
2874+ acpi.Lookup = Lookup;
2875+ acpi.reserved = nullptr ;
28602876 }
28612877
28622878 ~AudioComponentPlugInInstance ()
28632879 {
28642880 delete plugin;
28652881 }
28662882
2867- static OSStatus Open (void * const self, const AudioUnit component)
2883+ static OSStatus Open (void * const self, const AudioUnit component)
28682884 {
28692885 d_debug (" AudioComponentPlugInInstance::Open(%p)" , self);
28702886
28712887 static_cast <AudioComponentPlugInInstance*>(self)->plugin = new PluginAU (component);
28722888 return noErr;
28732889 }
28742890
2875- static OSStatus Close (void * const self)
2891+ static OSStatus Close (void * const self)
28762892 {
28772893 d_debug (" AudioComponentPlugInInstance::Close(%p)" , self);
28782894
@@ -2964,15 +2980,15 @@ struct AudioComponentPlugInInstance {
29642980 d_debug (" AudioComponentPlugInInstance::GetPropertyInfo(%p, %d:%x:%s, %d:%s, %d, ...)" ,
29652981 self, inProp, inProp, AudioUnitPropertyID2Str (inProp), inScope, AudioUnitScope2Str (inScope), inElement);
29662982
2967- UInt32 dataSize = 0 ;
2968- Boolean writable = false ;
2983+ UInt32 dataSize = 0 ;
2984+ Boolean writable = false ;
29692985 const OSStatus res = self->plugin ->auGetPropertyInfo (inProp, inScope, inElement, dataSize, writable);
29702986
2971- if (outDataSize != nullptr )
2972- *outDataSize = dataSize;
2987+ if (outDataSize != nullptr )
2988+ *outDataSize = dataSize;
29732989
2974- if (outWritable != nullptr )
2975- *outWritable = writable;
2990+ if (outWritable != nullptr )
2991+ *outWritable = writable;
29762992
29772993 return res;
29782994 }
@@ -3016,24 +3032,24 @@ struct AudioComponentPlugInInstance {
30163032 if (res != noErr)
30173033 return res;
30183034
3019- void * outBuffer;
3035+ void * outBuffer;
30203036 uint8_t * tmpBuffer;
30213037 if (inDataSize < outDataSize)
3022- {
3023- tmpBuffer = new uint8_t [outDataSize];
3024- outBuffer = tmpBuffer;
3025- }
3038+ {
3039+ tmpBuffer = new uint8_t [outDataSize];
3040+ outBuffer = tmpBuffer;
3041+ }
30263042 else
30273043 {
3028- tmpBuffer = nullptr ;
3029- outBuffer = outData;
3030- }
3044+ tmpBuffer = nullptr ;
3045+ outBuffer = outData;
3046+ }
30313047
30323048 res = self->plugin ->auGetProperty (inProp, inScope, inElement, outBuffer);
30333049
3034- if (res != noErr)
3050+ if (res != noErr)
30353051 {
3036- *ioDataSize = 0 ;
3052+ *ioDataSize = 0 ;
30373053 return res;
30383054 }
30393055
0 commit comments