IAkMixerPlugin.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. /// \file
  21. /// Software source plug-in and effect plug-in interfaces.
  22. #ifndef _IAK_MIXER_PLUGIN_H_
  23. #define _IAK_MIXER_PLUGIN_H_
  24. #include <AK/SoundEngine/Common/IAkPlugin.h>
  25. namespace AK
  26. {
  27. /// Software effect plug-in interface for panner/mixer effects (see \ref soundengine_plugins_effects).
  28. class IAkMixerEffectPlugin : public IAkPlugin
  29. {
  30. public:
  31. /// Software effect plug-in initialization. Prepares the effect for data processing, allocates memory and sets up the initial conditions.
  32. /// \aknote Memory allocation should be done through appropriate macros (see \ref fx_memory_alloc). \endaknote
  33. virtual AKRESULT Init(
  34. IAkPluginMemAlloc * in_pAllocator, ///< Interface to memory allocator to be used by the effect.
  35. IAkMixerPluginContext * in_pMixerPluginContext, ///< Interface to mixer plug-in's context.
  36. IAkPluginParam * in_pParams, ///< Interface to plug-in parameters.
  37. AkAudioFormat & in_rFormat ///< Audio data format of the requested output signal.
  38. ) = 0;
  39. /// This function is called whenever a new input is connected to the underlying mixing bus.
  40. virtual void OnInputConnected(
  41. IAkMixerInputContext * in_pInput ///< Input that is being connected.
  42. ) = 0;
  43. /// This function is called whenever a new input is disconnected to the underlying mixing bus.
  44. /// \aknote OnInputDisconnected() may be called between calls to ConsumeInput() and OnMixDone().\endaknote
  45. virtual void OnInputDisconnected(
  46. IAkMixerInputContext * in_pInput ///< Input that is being disconnected.
  47. ) = 0;
  48. /// This function is called whenever an input (voice or bus) needs to be mixed.
  49. /// During an audio frame, ConsumeInput() will be called for each input that need to be mixed.
  50. /// \aknote io_pInputBuffer->eState will be set as AK_NoMoreData the last time the given input is processed by ConsumeInput(). Otherwise it is set to AK_DataReady.
  51. /// Mixers cannot make an input remain alive by changing their state.\endaknote
  52. /// \aknote ConsumeInput() will not be called for frames during which a voice is not audible.\endaknote
  53. /// \sa
  54. /// - OnMixDone
  55. /// - OnEffectsProcessed
  56. virtual void ConsumeInput(
  57. IAkMixerInputContext * in_pInputContext, ///< Context for this input. Carries non-audio data.
  58. AkRamp in_baseVolume, ///< Base volume to apply to this input (prev corresponds to the beginning, next corresponds to the end of the buffer). This gain is agnostic of emitter-listener pair-specific contributions (such as distance level attenuation).
  59. AkRamp in_emitListVolume, ///< Emitter-listener pair-specific gain. When there are multiple emitter-listener pairs, this volume equals 1, and pair gains are applied directly on the channel volume matrix (accessible via IAkMixerInputContext::GetSpatializedVolumes()). For custom processing of emitter-listener pairs, one should query each pair volume using IAkMixerInputContext::Get3DPosition(), then AkEmitterListenerPair::GetGainForConnectionType().
  60. AkAudioBuffer * io_pInputBuffer, ///< Input audio buffer data structure. Plugins should avoid processing data in-place.
  61. AkAudioBuffer * io_pMixBuffer ///< Output audio buffer data structure. Stored until call to OnEffectsProcessed().
  62. ) = 0;
  63. /// This function is called once every audio frame, when all inputs have been mixed in
  64. /// with ConsumeInput(). It is the time when the plugin may perform final DSP/bookkeeping.
  65. /// After the bus buffer io_pMixBuffer has been pushed to the bus downstream (or the output device),
  66. /// it is cleared out for the next frame.
  67. /// \aknote io_pMixBuffer->eState is passed as AK_DataReady for the whole existence of the bus, until the last frame where it will be set to AK_NoMoreData.
  68. /// However, mixer plugins are capable of forcing the bus to remain alive for a longer time by changing io_pMixBuffer->eState back to AK_DataReady.
  69. /// You may do this in OnMixDone() or in OnEffectsProcessed(). The difference is that effects inserted on the bus will enter their "tail mode" if you
  70. /// wait until OnEffectsProcessed() to flip the state to AK_DataReady. This is usually undesirable, so handling this inside OnMixDone() is usually preferred.\endaknote
  71. /// \sa
  72. /// - ConsumeInput
  73. /// - OnEffectsProcessed
  74. virtual void OnMixDone(
  75. AkAudioBuffer * io_pMixBuffer ///< Output audio buffer data structure. Stored across calls to ConsumeInput().
  76. ) = 0;
  77. /// This function is called once every audio frame, after all insert effects on the bus have been processed,
  78. /// which occur after the post mix pass of OnMixDone().
  79. /// After the bus buffer io_pMixBuffer has been pushed to the bus downstream (or the output device),
  80. /// it is cleared out for the next frame.
  81. /// \aknote io_pMixBuffer->eState is passed as AK_DataReady for the whole existence of the bus, until the last frame where it will be set to AK_NoMoreData.
  82. /// However, mixer plugins are capable of forcing the bus to remain alive for a longer time by changing io_pMixBuffer->eState back to AK_DataReady.
  83. /// You may do this in OnMixDone(), in OnEffectsProcessed() or in OnFrameEnd(). The difference is that effects inserted on the bus will enter their "tail mode" if you
  84. /// wait until OnEffectsProcessed() or OnFrameEnd() to flip the state to AK_DataReady. This is usually undesirable, so handling this inside OnMixDone() is usually preferred.\endaknote
  85. /// \sa
  86. /// - OnMixDone
  87. /// - AK::AkMetering
  88. /// - AK::IAkMixerPluginContext::EnableMetering()
  89. virtual void OnEffectsProcessed(
  90. AkAudioBuffer * io_pMixBuffer ///< Output audio buffer data structure.
  91. ) = 0;
  92. /// This function is called once every audio frame, after all insert effects on the bus have been processed, and after metering has been processed (if applicable),
  93. /// which occur after OnEffectsProcessed().
  94. /// After the bus buffer io_pMixBuffer has been pushed to the bus downstream (or the output device), it is cleared out for the next frame.
  95. /// Mixer plugins may use this hook for processing the signal after it has been metered.
  96. /// \aknote io_pMixBuffer->eState is passed as AK_DataReady for the whole existence of the bus, until the last frame where it will be set to AK_NoMoreData.
  97. /// However, mixer plugins are capable of forcing the bus to remain alive for a longer time by changing io_pMixBuffer->eState back to AK_DataReady.
  98. /// You may do this in OnMixDone(), in OnEffectsProcessed() or in OnFrameEnd(). The difference is that effects inserted on the bus will enter their "tail mode" if you
  99. /// wait until OnEffectsProcessed() or OnFrameEnd() to flip the state to AK_DataReady. This is usually undesirable, so handling this inside OnMixDone() is usually preferred.\endaknote
  100. /// \aknote This function is called after metering gets computed on io_pMixBuffer. You may access the result in in_pMetering. Metering has to be enabled with AK::IAkMixerPluginContext::EnableMetering().
  101. /// It may also be enabled by the Wwise authoring tool when connected.\endaknote
  102. /// \sa
  103. /// - OnMixDone
  104. /// - AK::AkMetering
  105. /// - AK::IAkMixerPluginContext::EnableMetering()
  106. virtual void OnFrameEnd(
  107. AkAudioBuffer * io_pMixBuffer, ///< Output audio buffer data structure.
  108. AkMetering * in_pMetering ///< Struct containing metering data computed on io_pMixBuffer. May be NULL if metering is not enabled.
  109. ) = 0;
  110. };
  111. }
  112. #endif // _IAK_MIXER_PLUGIN_H_