Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Voice/MiVOIPSoundEffectSource.h"
- // Useful header for various DSP-related utility functions.
- #include "DSP/Dsp.h"
- void FMiVOIPSoundEffectSource::Init(const FSoundEffectSourceInitData& InInitData)
- {
- // Use InitData to setup DSP effects that depend on sample rate, etc.
- bIsActive = true;
- VolumeScale = 5.0f; // 5.0 is a magic number that just sounds right. May be adjusted per player feedback
- NumChannels = InInitData.NumSourceChannels;
- }
- void FMiVOIPSoundEffectSource::OnPresetChanged()
- {
- // Macro to retrieve the current settings value of the parent preset asset.
- GET_EFFECT_SETTINGS(MiVOIPSoundEffectSource);
- // Update the instance's variables based on the settings values.
- // Note that Settings variable was created by the GET_EFFECT_SETTINGS macro.
- VolumeScale = Audio::ConvertToLinear(Settings.VolumeAttenuationDb);
- }
- void FMiVOIPSoundEffectSource::ProcessAudio(const FSoundEffectSourceInputData& InData, float* OutAudioBufferData)
- {
- // Use the volume scale value to scale the input audio frame data.
- // Samples are in the range [-1.0,1.0]
- for (int32 Index = 0; Index < InData.NumSamples; ++Index)
- {
- OutAudioBufferData[Index] = FMath::Clamp(VolumeScale * InData.InputSourceEffectBufferPtr[Index], -1.f, 1.f);
- }
- }
- void UMiVOIPSoundEffectSourcePreset::SetSettings(const FMiVOIPSoundEffectSourceSettings& InSettings)
- {
- // Performs necessary broadcast to effect instances
- UpdateSettings(InSettings);
- }
Advertisement
Add Comment
Please, Sign In to add comment