Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "CoreMinimal.h"
- #include "Sound/SoundEffectSource.h"
- #include "MiVOIPSoundEffectSource.generated.h"
- // ========================================================================
- // FMiVOIPSoundEffectSourceSettings
- // This is the source effect's setting struct.
- // ========================================================================
- USTRUCT(BlueprintType)
- struct FMiVOIPSoundEffectSourceSettings
- {
- GENERATED_USTRUCT_BODY()
- // Volume attenuation in dB.
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SourceEffect|Preset", meta = (ClampMin = "-96.0", UIMin = "-96.0", UIMax = "10.0"))
- float VolumeAttenuationDb;
- FMiVOIPSoundEffectSourceSettings()
- : VolumeAttenuationDb(0.0f)
- {}
- };
- // ========================================================================
- // FMiVOIPSoundEffectSource
- // This is the instance of the source effect. Performs DSP calculations.
- // ========================================================================
- class FMiVOIPSoundEffectSource : public FSoundEffectSource
- {
- public:
- // Called on an audio effect at initialization on main thread before audio processing begins.
- virtual void Init(const FSoundEffectSourceInitData& InInitData) override;
- // Called when an audio effect preset is changed
- virtual void OnPresetChanged() override;
- // Process the input block of audio. Called on audio thread.
- virtual void ProcessAudio(const FSoundEffectSourceInputData& InData, float* OutAudioBufferData) override;
- protected:
- // Attenuation of sound in linear units
- float VolumeScale;
- int32 NumChannels;
- };
- // ========================================================================
- // UMiVOIPSoundEffectSourcePreset
- // This code exposes your preset settings and effect class to the editor.
- // And allows for a handle to setting/updating effect settings dynamically.
- // ========================================================================
- UCLASS(MinimalAPI, ClassGroup = AudioSourceEffect, meta = (BlueprintSpawnableComponent))
- class UMiVOIPSoundEffectSourcePreset : public USoundEffectSourcePreset
- {
- GENERATED_BODY()
- public:
- // Macro which declares and implements useful functions.
- EFFECT_PRESET_METHODS(MiVOIPSoundEffectSource)
- // Allows you to customize the color of the preset in the editor.
- virtual FColor GetPresetColor() const override { return FColor(196.0f, 185.0f, 121.0f); }
- // Change settings of your effect from blueprints. Will broadcast changes to active instances.
- UFUNCTION(BlueprintCallable, Category = "Audio|Effects")
- void SetSettings(const FMiVOIPSoundEffectSourceSettings& InSettings);
- // The copy of the settings struct. Can't be written to in BP, but can be read.
- // Note that the value read in BP is the serialized settings, will not reflect dynamic changes made in BP.
- UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Audio|Effects")
- FMiVOIPSoundEffectSourceSettings Settings;
- };
Advertisement
Add Comment
Please, Sign In to add comment