AkMixerPlatform.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #pragma once
  16. #include "AudioMixer.h"
  17. #include "WwiseUnrealDefines.h"
  18. class FAudioMixerInputComponent;
  19. class UAkAudioEvent;
  20. class FAkMixerPlatform : public Audio::IAudioMixerPlatformInterface
  21. {
  22. public:
  23. FAkMixerPlatform();
  24. ~FAkMixerPlatform();
  25. #if UE_5_0_OR_LATER
  26. virtual FString GetPlatformApi() const override { return TEXT("AkMixerPlatform"); }
  27. #else
  28. virtual Audio::EAudioMixerPlatformApi::Type GetPlatformApi() const override { return Audio::EAudioMixerPlatformApi::Other; }
  29. #endif
  30. virtual bool InitializeHardware() override;
  31. virtual bool TeardownHardware() override;
  32. virtual bool IsInitialized() const override;
  33. virtual bool GetNumOutputDevices(uint32& OutNumOutputDevices) override;
  34. virtual bool GetOutputDeviceInfo(const uint32 InDeviceIndex, Audio::FAudioPlatformDeviceInfo& OutInfo) override;
  35. virtual bool GetDefaultOutputDeviceIndex(uint32& OutDefaultDeviceIndex) const override;
  36. virtual bool OpenAudioStream(const Audio::FAudioMixerOpenStreamParams& Params) override;
  37. virtual bool CloseAudioStream() override;
  38. virtual bool StartAudioStream() override;
  39. virtual bool StopAudioStream() override;
  40. virtual Audio::FAudioPlatformDeviceInfo GetPlatformDeviceInfo() const override;
  41. virtual void SubmitBuffer(const uint8* Buffer) override;
  42. #if UE_5_0_OR_LATER
  43. virtual FName GetRuntimeFormat(const USoundWave* InSoundWave) const override;
  44. virtual ICompressedAudioInfo* CreateCompressedAudioInfo(const FName& InRuntimeFormat) const override;
  45. #else
  46. virtual FName GetRuntimeFormat(USoundWave* InSoundWave) override;
  47. virtual bool HasCompressedAudioInfoClass(USoundWave* InSoundWave) override;
  48. virtual ICompressedAudioInfo* CreateCompressedAudioInfo(USoundWave* InSoundWave) override;
  49. #endif
  50. virtual bool SupportsRealtimeDecompression() const { return true; }
  51. virtual FString GetDefaultDeviceName() override;
  52. FString GetDeviceId() const;
  53. virtual FAudioPlatformSettings GetPlatformSettings() const override;
  54. private:
  55. FAudioMixerInputComponent* AkAudioMixerInputComponent;
  56. bool bIsInitialized;
  57. bool bIsDeviceOpen;
  58. UAkAudioEvent* InputEvent;
  59. float** OutputBuffer;
  60. int OutputBufferByteLength;
  61. FCriticalSection OutputBufferMutex;
  62. FDelegateHandle AkAudioModuleInitHandle;
  63. void OnAkAudioModuleInit();
  64. void WriteSilence(uint32 NumChannels, uint32 NumSamples, float** OutBufferToFill);
  65. bool OnNextBuffer(uint32 NumChannels, uint32 NumSamples, float** OutBufferToFill);
  66. int32 GetAudioStreamChannelSize() { return sizeof(float); }
  67. private:
  68. static FName NAME_OGG;
  69. static FName NAME_OPUS;
  70. static FName NAME_ADPCM;
  71. };