AkSubmixInputComponent.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #include "AkSubmixInputComponent.generated.h"
  23. /*------------------------------------------------------------------------------------
  24. UAkSubmixInputComponent
  25. ------------------------------------------------------------------------------------*/
  26. UCLASS(ClassGroup = Audiokinetic, BlueprintType, hidecategories = (Transform, Rendering, Mobility, LOD, Component, Activation), meta = (BlueprintSpawnableComponent))
  27. class AKAUDIO_API UAkSubmixInputComponent
  28. : public UAkAudioInputComponent
  29. , public ISubmixBufferListener
  30. {
  31. GENERATED_BODY()
  32. public:
  33. UAkSubmixInputComponent(const class FObjectInitializer& ObjectInitializer);
  34. virtual void OnNewSubmixBuffer(const USoundSubmix* OwningSubmix, float* AudioData, int32 NumSamples, int32 NumChannels, const int32 SampleRate, double AudioClock) override;
  35. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SubmixInput")
  36. USoundSubmix* SubmixToRecord = nullptr;
  37. virtual int32 PostAssociatedAudioInputEvent();
  38. virtual void Stop();
  39. protected:
  40. /** The audio callback. This will be called continuously by the Wwise sound engine,
  41. * and is used to provide the sound engine with audio samples. If this function returns false, the audio
  42. * input event will be stopped and the functino will stop being called.
  43. */
  44. virtual bool FillSamplesBuffer(uint32 NumChannels, uint32 NumSamples, float** BufferToFill) override;
  45. /** This callback is used to provide the Wwise sound engine with the required audio format. */
  46. virtual void GetChannelConfig(AkAudioFormat& AudioFormat) override;
  47. private:
  48. int32 NumChannels;
  49. int32 SampleRate;
  50. int32 BufferLength;
  51. Audio::TCircularAudioBuffer<float> SampleBuffer;
  52. TArray<float> PoppedSamples;
  53. Audio::FMixerDevice* GetAudioMixerDevice();
  54. int32 PlayingID = AK_INVALID_PLAYING_ID;
  55. };