Guest User

Untitled

a guest
Nov 22nd, 2026
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | Source Code | 0 0
  1. #pragma once
  2.  
  3. #include "CoreMinimal.h"
  4. #include "Net/VoiceConfig.h"
  5. #include "MiVOIPTalker.generated.h"
  6.  
  7. class APlayerController;
  8. class APlayerState;
  9.  
  10. /** Determines how player voice is broadcast to other players */
  11. UENUM(BlueprintType)
  12. enum class EMiVoiceChatMode : uint8
  13. {
  14.     PushToTalk,
  15.     OpenMic,
  16. };
  17.  
  18. /**
  19.  * Voice Over IP talker component with enhanced functionality:
  20.  *
  21.  *  - Defaults to a source effect chain with a preset that increases received voice sample amplitudes
  22.  *    to work around the issue of other players sounding quiet
  23.  *  - Uses the gameplay message system to broadcast start and stop talking events
  24.  *  - Updates push-to-talk and mic volume on player setting changes
  25.  */
  26. UCLASS()
  27. class UMiVOIPTalker : public UVOIPTalker
  28. {
  29.     GENERATED_BODY()
  30.    
  31. public:
  32.     UMiVOIPTalker(const FObjectInitializer& ObjectInitializer);
  33.  
  34.     //~ Begin UActorComponent
  35.     virtual void BeginPlay() override;
  36.     virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
  37.     //~ End UActorComponent
  38.  
  39.     //~ Begin UVOIPTalker
  40.     virtual void OnTalkingBegin(UAudioComponent* AudioComponent) override;
  41.     virtual void OnTalkingEnd() override;
  42.     //~ End UVOIPTalker
  43.  
  44. protected:
  45.     void BindEvents();
  46.     void UnbindEvents();
  47.  
  48.     void HandleLocalPlayerTalkingStateChanged(FUniqueNetIdRef TalkerId, bool bIsTalking);
  49.     void HandleLocalGameSettingsChanged();
  50.  
  51.     void OnLocalTalkingBegin();
  52.     void OnLocalTalkingEnd();
  53.  
  54.     void UpdateLocalPlayerForPushToTalk();
  55.     void UpdateLocalPlayerMicSettings();
  56.  
  57.     /** Returns the player controller for this talker, or null if none or the controller is not on this game instance */
  58.     APlayerController* GetPlayerController() const;
  59.     /** Returns the player state for this talker, or null if it could not be determined */
  60.     APlayerState* GetPlayerState() const;
  61.  
  62.     float DefaultMicNoiseGateThreshold = 0.01f;
  63.     float DefaultSilenceDetectionThreshold = 0.01f;
  64.  
  65.     FDelegateHandle LocalPlayerTalkingStateChangedDelegateHandle;
  66.     FDelegateHandle LocalGameSettingsChangedDelegateHandle;
  67. };
  68.  
Advertisement
Add Comment
Please, Sign In to add comment