123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /*******************************************************************************
- The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
- Technology released in source code form as part of the game integration package.
- The content of this file may not be used without valid licenses to the
- AUDIOKINETIC Wwise Technology.
- Note that the use of the game engine is subject to the Unreal(R) Engine End User
- License Agreement at https://www.unrealengine.com/en-US/eula/unreal
-
- License Usage
-
- Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
- this file in accordance with the end user license agreement provided with the
- software or, alternatively, in accordance with the terms contained
- in a written agreement between you and Audiokinetic Inc.
- Copyright (c) 2023 Audiokinetic Inc.
- *******************************************************************************/
- #include "MovieSceneAkAudioRTPCSection.h"
- #include "AkAudioDevice.h"
- #include "AkCustomVersion.h"
- #include "MovieSceneAkAudioRTPCTemplate.h"
- #include "Channels/MovieSceneChannelProxy.h"
- #include "Channels/MovieSceneChannelEditorData.h"
- #include "MovieScene.h"
- UMovieSceneAkAudioRTPCSection::UMovieSceneAkAudioRTPCSection(const FObjectInitializer& Init)
- : Super(Init)
- {
- FMovieSceneChannelProxyData Channels;
- #if WITH_EDITOR
- FMovieSceneChannelMetaData Metadata;
- Metadata.SetIdentifiers("RTPC", NSLOCTEXT("MovieSceneAkAudioRTPCSectionEditorData", "RTPC", "RTPC"));
- Channels.Add(RTPCChannel, Metadata, TMovieSceneExternalValue<float>());
- #else
- Channels.Add(RTPCChannel);
- #endif
- // Populate the channel proxy - if any of our channels were ever reallocated, we'd need to repopulate the proxy,
- // but since ours are all value member types, we only need to populate in the constructor
- ChannelProxy = MakeShared<FMovieSceneChannelProxy>(MoveTemp(Channels));
- }
- #if !UE_4_26_OR_LATER
- FMovieSceneEvalTemplatePtr UMovieSceneAkAudioRTPCSection::GenerateTemplate() const
- {
- return FMovieSceneAkAudioRTPCTemplate(*this);
- }
- #endif
- float UMovieSceneAkAudioRTPCSection::GetStartTime() const
- {
- FFrameRate FrameRate = GetTypedOuter<UMovieScene>()->GetTickResolution();
- return (float)FrameRate.AsSeconds(GetRange().GetLowerBoundValue());
- }
- float UMovieSceneAkAudioRTPCSection::GetEndTime() const
- {
- FFrameRate FrameRate = GetTypedOuter<UMovieScene>()->GetTickResolution();
- return (float)FrameRate.AsSeconds(GetRange().GetUpperBoundValue());
- }
- void UMovieSceneAkAudioRTPCSection::PostLoad()
- {
- Super::PostLoad();
- const int32 AkVersion = GetLinkerCustomVersion(FAkCustomVersion::GUID);
- if (AkVersion < FAkCustomVersion::NewRTPCTrackDataContainer)
- {
- if (FloatCurve.GetDefaultValue() != MAX_flt)
- {
- RTPCChannel.SetDefault(FloatCurve.GetDefaultValue());
- }
- RTPCChannel.PreInfinityExtrap = FloatCurve.PreInfinityExtrap;
- RTPCChannel.PostInfinityExtrap = FloatCurve.PostInfinityExtrap;
- TArray<FFrameNumber> Times;
- TArray<FMovieSceneFloatValue> Values;
- Times.Reserve(FloatCurve.GetNumKeys());
- Values.Reserve(FloatCurve.GetNumKeys());
- const FFrameRate LegacyFrameRate = GetLegacyConversionFrameRate();
- const float Interval = LegacyFrameRate.AsInterval();
- int32 Index = 0;
- for (auto It = FloatCurve.GetKeyIterator(); It; ++It)
- {
- const FRichCurveKey& Key = *It;
- FFrameNumber KeyTime = UpgradeLegacyMovieSceneTime(nullptr, LegacyFrameRate, It->Time);
- FMovieSceneFloatValue NewValue;
- NewValue.Value = Key.Value;
- NewValue.InterpMode = Key.InterpMode;
- NewValue.TangentMode = Key.TangentMode;
- NewValue.Tangent.ArriveTangent = Key.ArriveTangent * Interval;
- NewValue.Tangent.LeaveTangent = Key.LeaveTangent * Interval;
- ConvertInsertAndSort<FMovieSceneFloatValue>(Index++, KeyTime, NewValue, Times, Values);
- }
- RTPCChannel.Set(Times, Values);
- return;
- }
- FloatChannelSerializationHelper.ToFloatChannel(RTPCChannel);
- }
- void UMovieSceneAkAudioRTPCSection::Serialize(FArchive& Ar)
- {
- FloatChannelSerializationHelper = RTPCChannel;
- Ar.UsingCustomVersion(FAkCustomVersion::GUID);
- Super::Serialize(Ar);
- }
- #if WITH_EDITOR
- void UMovieSceneAkAudioRTPCSection::PreEditChange(FProperty* PropertyAboutToChange)
- {
- PreviousName = Name;
- }
- void UMovieSceneAkAudioRTPCSection::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
- {
- const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
- if (PropertyName == GET_MEMBER_NAME_CHECKED(UMovieSceneAkAudioRTPCSection, Name))
- {
- if (!IsRTPCNameValid())
- {
- Name = PreviousName;
- }
- }
- Super::PostEditChangeProperty(PropertyChangedEvent);
- }
- bool UMovieSceneAkAudioRTPCSection::IsRTPCNameValid()
- {
- return !Name.IsEmpty();
- }
- #endif
|