Skip to content
Snippets Groups Projects
Commit fc1ac6e7 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Introducing signal sources

parent d1e167af
No related branches found
No related tags found
No related merge requests found
...@@ -664,6 +664,60 @@ bool FVAPlugin::SetSoundBufferLoop(const std::string BufferID, const bool bLoop) ...@@ -664,6 +664,60 @@ bool FVAPlugin::SetSoundBufferLoop(const std::string BufferID, const bool bLoop)
} }
} }
std::string FVAPlugin::CreateSignalSourcePrototype(ESignalSource::Type SignalSourceClass)
{
if (!ShouldInteractWithServer())
return "-1";
std::string ClassName;
switch (SignalSourceClass)
{
case ESignalSource::JetEngine:
ClassName = "jet_engine";
break;
}
try
{
CVAStruct SignalSourceStruct;
SignalSourceStruct["class"] = ClassName;
return VAServer->CreateSignalSourcePrototypeFromParameters( SignalSourceStruct );
}
catch (CVAException& e)
{
ProcessException("FVAPluginModule::CreateSignalSourcePrototype()", FString(e.ToString().c_str()));
return "-1";
}
}
bool FVAPlugin::SetJetEngineRMP(std::string SignalSourceID, float fRPM)
{
if (!ShouldInteractWithServer())
{
return false;
}
if (SignalSourceID == "-1")
{
FVAUtils::LogStuff("[FVAPlugin::SetJetEngineRMP()]: SignalSourceID invalid (=-1)", true);
return false;
}
try
{
CVAStruct VAParams;
VAParams["rpm"] = fRPM;
VAServer->SetSignalSourceParameters(SignalSourceID, VAParams);
return true;
}
catch (CVAException& e)
{
ProcessException("FVAPluginModule::SetJetEngineRMP()", FString(e.ToString().c_str()));
return false;
}
}
// ****************************************************************** // // ****************************************************************** //
// ******* Sound Sources ******************************************** // // ******* Sound Sources ******************************************** //
......
...@@ -78,6 +78,11 @@ public: ...@@ -78,6 +78,11 @@ public:
static bool SetSoundBufferTime(std::string BufferID, float Time); static bool SetSoundBufferTime(std::string BufferID, float Time);
static bool SetSoundBufferLoop(std::string BufferID, bool bLoop); static bool SetSoundBufferLoop(std::string BufferID, bool bLoop);
// ******* Signal Sources ******* //
static std::string CreateSignalSourcePrototype(ESignalSource::Type SignalSourceClass);
static bool SetJetEngineRMP(std::string SignalSourceID, float fRPM);
// ******* Sound Sources ******* // // ******* Sound Sources ******* //
......
...@@ -34,6 +34,14 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe ...@@ -34,6 +34,14 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe
const std::string Name = "SoundSource"; const std::string Name = "SoundSource";
if (FVAPlugin::GetIsMaster()) if (FVAPlugin::GetIsMaster())
{
std::string sSignalID = "-1";
if ( ParentComponent->GetSignalSourceType() == ESignalSource::JetEngine )
{
sSignalID = FVAPlugin::CreateSignalSourcePrototype( ESignalSource::JetEngine );
//FVAPlugin::SetJetEngineRMP(sSignalID, ParentComponent->GetJetRPM());
}
else
{ {
ActiveBuffer = BufferManager.GetBufferByFileName(ParentComponent->GetSoundFile()); ActiveBuffer = BufferManager.GetBufferByFileName(ParentComponent->GetSoundFile());
...@@ -50,8 +58,10 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe ...@@ -50,8 +58,10 @@ FVASoundSource::FVASoundSource(UVASourceComponent* ParentComponent, TArray<AVARe
{ {
ActiveBuffer->SetSoundTimeOffset(SoundTimeOffset); ActiveBuffer->SetSoundTimeOffset(SoundTimeOffset);
} }
sSignalID = ActiveBuffer->GetID();
}
SoundSourceID = FVAPlugin::CreateNewSoundSource(ActiveBuffer->GetID(), Name, Position, Rotation, Power); SoundSourceID = FVAPlugin::CreateNewSoundSource(sSignalID, Name, Position, Rotation, Power);
if (SoundSourceID == -1) if (SoundSourceID == -1)
{ {
FVAUtils::LogStuff("[FVASoundSource::VASoundSource()]: Error initializing soundSource", FVAUtils::LogStuff("[FVASoundSource::VASoundSource()]: Error initializing soundSource",
......
...@@ -346,6 +346,11 @@ bool UVASourceComponent::GetHandleReflections() const ...@@ -346,6 +346,11 @@ bool UVASourceComponent::GetHandleReflections() const
return bHandleReflections; return bHandleReflections;
} }
ESignalSource::Type UVASourceComponent::GetSignalSourceType() const
{
return SignalSourceType;
}
// ****************************************************************** // // ****************************************************************** //
......
...@@ -16,6 +16,16 @@ namespace EPlayAction ...@@ -16,6 +16,16 @@ namespace EPlayAction
}; };
} }
UENUM(BlueprintType)
namespace ESignalSource
{
enum Type
{
AudioFile = 0,
JetEngine = 7
};
}
UENUM(BlueprintType) UENUM(BlueprintType)
namespace EConnectionSetting namespace EConnectionSetting
......
...@@ -25,30 +25,40 @@ protected: ...@@ -25,30 +25,40 @@ protected:
friend class AVAReceiverActor; friend class AVAReceiverActor;
// Name of Sound file. Folder are possible too: "folder/soundfile.wav"
UPROPERTY(EditAnywhere, meta = (DisplayName = "Sound Name", Category = "General Settings")) // Check if reflections by walls should be considered
FString SoundFile = "WelcomeToVA.wav"; UPROPERTY(EditAnywhere, meta = (DisplayName = "Use reflections?", Category = "General Settings"))
bool bHandleReflections = true;
// Sound power used for this source
UPROPERTY(EditAnywhere, meta = (DisplayName = "Sound Power", Category = "General Settings",
ClampMin = "0.0", ClampMax = "4.0", UIMin = "0.0", UIMax = "4.0"))
float SoundPower = 0.0316227749f;
// Select the type of the signal source
UPROPERTY(EditAnywhere, meta = (DisplayName = "Signal Type", Category = "Signal Source Settings"))
TEnumAsByte<ESignalSource::Type> SignalSourceType = ESignalSource::Type::AudioFile;
// Action of the sound source at the first tick // Action of the sound source at the first tick
UPROPERTY(EditAnywhere, meta = (DisplayName = "Action", Category = "General Settings")) UPROPERTY(EditAnywhere, meta = (DisplayName = "Action", Category = "Signal Source Settings|Audio File"))
TEnumAsByte<EPlayAction::Type> StartingPlayAction = EPlayAction::Type::Stop; TEnumAsByte<EPlayAction::Type> StartingPlayAction = EPlayAction::Type::Stop;
// Name of Sound file. Folder are possible too: "folder/soundfile.wav"
UPROPERTY(EditAnywhere, meta = (DisplayName = "Sound Name", Category = "Signal Source Settings|Audio File"))
FString SoundFile = "WelcomeToVA.wav";
// Sets Buffer to a specific time stamp when playing back at the first tick (see Action) // Sets Buffer to a specific time stamp when playing back at the first tick (see Action)
UPROPERTY(EditAnywhere, meta = (DisplayName = "Play from x [s]", Category = "General Settings")) UPROPERTY(EditAnywhere, meta = (DisplayName = "Play from x [s]", Category = "Signal Source Settings|Audio File"))
float StartingTime = 0.0f; float StartingTime = 0.0f;
// Check if the sound should be played back in a loop // Check if the sound should be played back in a loop
UPROPERTY(EditAnywhere, meta = (DisplayName = "Loop", Category = "General Settings")) UPROPERTY(EditAnywhere, meta = (DisplayName = "Loop", Category = "Signal Source Settings|Audio File"))
bool bLoop = false; bool bLoop = false;
// Check if reflections by walls should be considered // Set rotations per minute of the jet
UPROPERTY(EditAnywhere, meta = (DisplayName = "Use reflections?", Category = "General Settings")) UPROPERTY(EditAnywhere, meta = (DisplayName = "RPM", Category = "Signal Source Settings|Jet Engine"))
bool bHandleReflections = true; float JetRPM = 1000.0f;
// Check if reflections by walls should be considered
UPROPERTY(EditAnywhere, meta = (DisplayName = "Sound Power", Category = "General Settings",
ClampMin = "0.0", ClampMax = "4.0", UIMin = "0.0", UIMax = "4.0"))
float SoundPower = 0.0316227749f;
// Decide whether to use manual Transform (below) or use Transform / Movement of Actor // Decide whether to use manual Transform (below) or use Transform / Movement of Actor
UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position", UPROPERTY(EditAnywhere, meta = (DisplayName = "Position Settings", Category = "Position",
...@@ -155,6 +165,10 @@ public: ...@@ -155,6 +165,10 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool GetHandleReflections() const; bool GetHandleReflections() const;
// Gets the signal type used for this sound source
UFUNCTION(BlueprintCallable)
ESignalSource::Type GetSignalSourceType() const;
// *** Sound Pose *** // // *** Sound Pose *** //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment