Guest User

Untitled

a guest
Nov 22nd, 2026
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | Source Code | 0 0
  1. #include "Voice/MiVOIPSoundEffectSource.h"
  2.  
  3. // Useful header for various DSP-related utility functions.
  4. #include "DSP/Dsp.h"
  5.  
  6. void FMiVOIPSoundEffectSource::Init(const FSoundEffectSourceInitData& InInitData)
  7. {
  8. // Use InitData to setup DSP effects that depend on sample rate, etc.
  9. bIsActive = true;
  10. VolumeScale = 5.0f; // 5.0 is a magic number that just sounds right. May be adjusted per player feedback
  11. NumChannels = InInitData.NumSourceChannels;
  12. }
  13.  
  14. void FMiVOIPSoundEffectSource::OnPresetChanged()
  15. {
  16. // Macro to retrieve the current settings value of the parent preset asset.
  17. GET_EFFECT_SETTINGS(MiVOIPSoundEffectSource);
  18.  
  19. // Update the instance's variables based on the settings values.
  20. // Note that Settings variable was created by the GET_EFFECT_SETTINGS macro.
  21. VolumeScale = Audio::ConvertToLinear(Settings.VolumeAttenuationDb);
  22. }
  23.  
  24. void FMiVOIPSoundEffectSource::ProcessAudio(const FSoundEffectSourceInputData& InData, float* OutAudioBufferData)
  25. {
  26. // Use the volume scale value to scale the input audio frame data.
  27. // Samples are in the range [-1.0,1.0]
  28. for (int32 Index = 0; Index < InData.NumSamples; ++Index)
  29. {
  30. OutAudioBufferData[Index] = FMath::Clamp(VolumeScale * InData.InputSourceEffectBufferPtr[Index], -1.f, 1.f);
  31. }
  32. }
  33.  
  34. void UMiVOIPSoundEffectSourcePreset::SetSettings(const FMiVOIPSoundEffectSourceSettings& InSettings)
  35. {
  36. // Performs necessary broadcast to effect instances
  37. UpdateSettings(InSettings);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment