You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Add metasound reset routine to external nodes
#jira UE-174363 #rb Rob.Gay #preflight 6400d71caa004233353024cb [CL 24488096 by phil popp in ue5-main branch]
This commit is contained in:
+6
@@ -50,6 +50,7 @@ namespace Metasound
|
||||
virtual FDataReferenceCollection GetInputs() const override;
|
||||
virtual FDataReferenceCollection GetOutputs() const override;
|
||||
void Execute();
|
||||
void Reset(const IOperator::FResetParams& InParams);
|
||||
|
||||
private: // members
|
||||
// input pins
|
||||
@@ -158,6 +159,11 @@ namespace Metasound
|
||||
}
|
||||
}
|
||||
|
||||
void FWaveInfoNodeOperator::Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
Execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class FWaveInfoNode : public FNodeFacade
|
||||
|
||||
+32
@@ -434,6 +434,38 @@ namespace Metasound
|
||||
UpdatePlaybackLocation();
|
||||
}
|
||||
|
||||
void Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
TriggerOnDone->Reset();
|
||||
TriggerOnNearlyDone->Reset();
|
||||
TriggerOnLooped->Reset();
|
||||
TriggerOnCuePoint->Reset();
|
||||
|
||||
*CuePointID = 0;
|
||||
*CuePointLabel = TEXT("");
|
||||
*LoopPercent = 0;
|
||||
*PlaybackLocation = 0;
|
||||
for (const FAudioBufferWriteRef& BufferRef : OutputAudioBuffers)
|
||||
{
|
||||
BufferRef->Zero();
|
||||
}
|
||||
|
||||
WaveProxyReader.Reset();
|
||||
ConvertDeinterleave.Reset();
|
||||
Resampler.Reset();
|
||||
|
||||
SortedCuePoints.Reset();
|
||||
for (Audio::TCircularAudioBuffer<float>& Buffer : SourceCircularBuffer)
|
||||
{
|
||||
Buffer.SetNum(0);
|
||||
}
|
||||
|
||||
SourceState = WavePlayerNodePrivate::FSourceBufferState();
|
||||
SampleRateFrameRatio = 1.f;
|
||||
bOnNearlyDoneTriggeredForWave = false;
|
||||
bIsPlaying = false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void ExecuteSubblocks()
|
||||
|
||||
+28
-17
@@ -134,23 +134,7 @@ namespace Metasound
|
||||
, OutWriteRef(TDataWriteReferenceFactory<float>::CreateAny(InParams.OperatorSettings))
|
||||
, SampleRate(InParams.OperatorSettings.GetSampleRate())
|
||||
{
|
||||
{
|
||||
using namespace WaveTable;
|
||||
FWaveTableSampler::FSettings Settings;
|
||||
Settings.Freq = 0.0f; // Sampler phase is manually progressed via this node
|
||||
Sampler = FWaveTableSampler(MoveTemp(Settings));
|
||||
}
|
||||
|
||||
{
|
||||
const float BlockRate = InParams.OperatorSettings.GetActualBlockRate();
|
||||
check(BlockRate > 0.0f && !FMath::IsNearlyZero(BlockRate));
|
||||
SecondsPerBlock = 1.0f / BlockRate;
|
||||
}
|
||||
|
||||
{
|
||||
BlockSize = InParams.OperatorSettings.GetNumFramesPerBlock();
|
||||
check(BlockSize > 0);
|
||||
}
|
||||
Reset(InParams);
|
||||
}
|
||||
|
||||
virtual ~FMetasoundWaveTableEnvelopeNodeOperator() = default;
|
||||
@@ -311,6 +295,33 @@ namespace Metasound
|
||||
*OutWriteRef = NextValue;
|
||||
}
|
||||
|
||||
void Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
{
|
||||
using namespace WaveTable;
|
||||
FWaveTableSampler::FSettings Settings;
|
||||
Settings.Freq = 0.0f; // Sampler phase is manually progressed via this node
|
||||
Sampler = FWaveTableSampler(MoveTemp(Settings));
|
||||
}
|
||||
|
||||
{
|
||||
const float BlockRate = InParams.OperatorSettings.GetActualBlockRate();
|
||||
check(BlockRate > 0.0f && !FMath::IsNearlyZero(BlockRate));
|
||||
SecondsPerBlock = 1.0f / BlockRate;
|
||||
}
|
||||
|
||||
{
|
||||
BlockSize = InParams.OperatorSettings.GetNumFramesPerBlock();
|
||||
check(BlockSize > 0);
|
||||
}
|
||||
|
||||
OnFinishedWriteRef->Reset();
|
||||
*OutWriteRef = 0.f;
|
||||
|
||||
Elapsed = -1.0f;
|
||||
bPaused = false;
|
||||
}
|
||||
|
||||
private:
|
||||
FWaveTableReadRef WaveTableReadRef;
|
||||
FTriggerReadRef PlayReadRef;
|
||||
|
||||
+11
-4
@@ -101,10 +101,7 @@ namespace Metasound
|
||||
, InterpModeReadRef(InInterpModeReadRef)
|
||||
, OutWriteRef(TDataWriteReferenceFactory<float>::CreateAny(InParams.OperatorSettings))
|
||||
{
|
||||
using namespace WaveTable;
|
||||
FWaveTableSampler::FSettings Settings;
|
||||
Settings.Freq = 0.0f; // Sampler phase is manually progressed via this node
|
||||
Sampler = FWaveTableSampler(MoveTemp(Settings));
|
||||
Reset(InParams);
|
||||
}
|
||||
|
||||
virtual ~FMetasoundWaveTableEvaluateNodeOperator() = default;
|
||||
@@ -161,6 +158,16 @@ namespace Metasound
|
||||
*OutWriteRef = NextValue;
|
||||
}
|
||||
|
||||
void Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
using namespace WaveTable;
|
||||
FWaveTableSampler::FSettings Settings;
|
||||
Settings.Freq = 0.0f; // Sampler phase is manually progressed via this node
|
||||
Sampler = FWaveTableSampler(MoveTemp(Settings));
|
||||
|
||||
*OutWriteRef = 0.f;
|
||||
}
|
||||
|
||||
private:
|
||||
FWaveTableReadRef WaveTableReadRef;
|
||||
FFloatReadRef InputReadRef;
|
||||
|
||||
+8
@@ -84,6 +84,7 @@ namespace Metasound
|
||||
, TableIndexReadRef(InTableIndexReadRef)
|
||||
, OutTable(TDataWriteReferenceFactory<WaveTable::FWaveTable>::CreateAny(InParams.OperatorSettings))
|
||||
{
|
||||
Reset(InParams);
|
||||
}
|
||||
|
||||
virtual ~FMetasoundWaveTableGetNodeOperator() = default;
|
||||
@@ -204,6 +205,13 @@ namespace Metasound
|
||||
LastTableIndex = NextTableIndex;
|
||||
}
|
||||
|
||||
void Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
LastTableIndex = -1.0f;
|
||||
OutTable->SetNum(0);
|
||||
OutTable->SetFinalValue(0.f);
|
||||
}
|
||||
|
||||
private:
|
||||
FWaveTableBankAssetReadRef WaveTableBankReadRef;
|
||||
FFloatReadRef TableIndexReadRef;
|
||||
|
||||
+17
@@ -210,6 +210,23 @@ namespace Metasound
|
||||
}
|
||||
}
|
||||
|
||||
void Reset(const IOperator::FResetParams& InParams)
|
||||
{
|
||||
const float BlockRate = InParams.OperatorSettings.GetActualBlockRate();
|
||||
if (BlockRate > 0.0f)
|
||||
{
|
||||
BlockPeriod = 1.0f / BlockRate;
|
||||
}
|
||||
|
||||
bPlaying = false;
|
||||
if (SyncBuffer.Num() > 0)
|
||||
{
|
||||
FMemory::Memset(SyncBuffer.GetData(), 0, sizeof(float) * SyncBuffer.Num());
|
||||
}
|
||||
Sampler = WaveTable::FWaveTableSampler{};
|
||||
OutBufferWriteRef->Zero();
|
||||
}
|
||||
|
||||
private:
|
||||
float BlockPeriod = 0.0f;
|
||||
bool bPlaying = false;
|
||||
|
||||
Reference in New Issue
Block a user