-
Notifications
You must be signed in to change notification settings - Fork 0
/
OdinFmodAdapter.h
94 lines (65 loc) · 3.39 KB
/
OdinFmodAdapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "FMODAudioComponent.h"
#include "fmod_studio.hpp"
#include "Components/ActorComponent.h"
#include "OdinFmodAdapter.generated.h"
class OdinMediaSoundGenerator;
class UOdinPlaybackMedia;
UENUM(BlueprintType)
enum class EFmodDspPan3dRolloffType : uint8 {
FMOD_DSP_PAN_3D_ROLLOFF_LINEARSQUARED UMETA(DisplayName = "Linear Squared"),
FMOD_DSP_PAN_3D_ROLLOFF_LINEAR UMETA(DisplayName = "Linear"),
FMOD_DSP_PAN_3D_ROLLOFF_INVERSE UMETA(DisplayName = "Inverse"),
FMOD_DSP_PAN_3D_ROLLOFF_INVERSETAPERED UMETA(DisplayName = "Inverse Tapered"),
FMOD_DSP_PAN_3D_ROLLOFF_CUSTOM UMETA(DisplayName = "Custom")
};
UENUM(BlueprintType)
enum class EFmodDspPan3dExtentMode : uint8 {
FMOD_DSP_PAN_3D_EXTENT_MODE_AUTO UMETA(DisplayName = "Auto"),
FMOD_DSP_PAN_3D_EXTENT_MODE_USER UMETA(DisplayName = "User"),
FMOD_DSP_PAN_3D_EXTENT_MODE_OFF UMETA(DisplayName = "Off")
};
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class ODINTESTPROJECT_API UOdinFmodAdapter : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
void BeginPlay() override;
void DestroyComponent(bool bPromoteChildren) override;
UOdinFmodAdapter();
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable, Category = "Odin|Sound")
void AssignOdinMedia(UPARAM(ref) UOdinPlaybackMedia*& Media);
FMOD_RESULT dspreadcallback(FMOD_DSP_STATE* dsp_state, float* data, unsigned int datalen, int inchannels);
// Object Spatializer Parameters
UPROPERTY(EditAnywhere, BlueprintReadOnly)
EFmodDspPan3dRolloffType RolloffType = EFmodDspPan3dRolloffType::FMOD_DSP_PAN_3D_ROLLOFF_LINEARSQUARED;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.0", UIMin = "0.0"))
float MinimumDistance = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.0", UIMin = "0.0"))
float MaximumDistance = 20.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
EFmodDspPan3dExtentMode ExtentMode = EFmodDspPan3dExtentMode::FMOD_DSP_PAN_3D_EXTENT_MODE_AUTO;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.0", UIMin = "0.0"))
float SoundSize = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.0", ClampMax = "360.0", UIMin = "0.0", UIMax = "360.0"))
float MinimumExtent = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0.0", ClampMax = "1.0", UIMin = "0.0", UIMax = "1.0"))
float OutputGain = 0.0f;
UFUNCTION(BlueprintCallable, Category = "Odin|Sound")
void SetAttenuation(EFmodDspPan3dRolloffType InRolloffType, float InMinimumDistance, float InMaximumDistance, EFmodDspPan3dExtentMode InExtentMode, float InSoundSize, float InMinimumExtent, float InOutputGain);
static FMOD_RESULT OdinDSPReadCallback(FMOD_DSP_STATE* dsp_state, float* inbuffer, float* outbuffer, unsigned int length, int inchannels, int* outchannels);
FMOD::DSP* dsp_pan;
FMOD::DSP* mOdinDSP = nullptr;
protected:
UPROPERTY(BlueprintReadOnly, Category = "Odin|Sound")
UOdinPlaybackMedia* PlaybackMedia = nullptr;
TSharedPtr<OdinMediaSoundGenerator, ESPMode::ThreadSafe> SoundGenerator;
FMOD::ChannelGroup* group;
void Update3DPosition();
void UpdateAttenSettings();
FMOD_VECTOR ConvertUnrealToFmodVector(FVector in, float scale = 1.0f);
};