AkSubmixInputComponent.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. AkSubmixInputComponent.h:
  17. =============================================================================*/
  18. #pragma once
  19. #include "AkInclude.h"
  20. #include "AudioDevice.h"
  21. #include "AkAudioInputComponent.h"
  22. #if UE_5_1_OR_LATER
  23. #include "ISubmixBufferListener.h"
  24. #endif
  25. #include "AkSubmixInputComponent.generated.h"
  26. /*------------------------------------------------------------------------------------
  27. UAkSubmixInputComponent
  28. ------------------------------------------------------------------------------------*/
  29. UCLASS(ClassGroup = Audiokinetic, BlueprintType, hidecategories = (Transform, Rendering, Mobility, LOD, Component, Activation), meta = (BlueprintSpawnableComponent))
  30. class AKAUDIO_API UAkSubmixInputComponent
  31. : public UAkAudioInputComponent
  32. , public ISubmixBufferListener
  33. {
  34. GENERATED_BODY()
  35. public:
  36. UAkSubmixInputComponent(const class FObjectInitializer& ObjectInitializer);
  37. virtual void OnNewSubmixBuffer(const USoundSubmix* OwningSubmix, float* AudioData, int32 NumSamples, int32 NumChannels, const int32 SampleRate, double AudioClock) override;
  38. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SubmixInput")
  39. USoundSubmix* SubmixToRecord = nullptr;
  40. virtual int32 PostAssociatedAudioInputEvent();
  41. virtual void Stop();
  42. protected:
  43. /** The audio callback. This will be called continuously by the Wwise sound engine,
  44. * and is used to provide the sound engine with audio samples. If this function returns false, the audio
  45. * input event will be stopped and the function will stop being called.
  46. */
  47. virtual bool FillSamplesBuffer(uint32 NumChannels, uint32 NumSamples, float** BufferToFill) override;
  48. /** This callback is used to provide the Wwise sound engine with the required audio format. */
  49. virtual void GetChannelConfig(AkAudioFormat& AudioFormat) override;
  50. private:
  51. int32 NumChannels;
  52. int32 SampleRate;
  53. int32 BufferLength;
  54. Audio::TCircularAudioBuffer<float> SampleBuffer;
  55. TArray<float> PoppedSamples;
  56. Audio::FMixerDevice* GetAudioMixerDevice();
  57. int32 PlayingID = AK_INVALID_PLAYING_ID;
  58. };