예제 #1
0
void UAkGameplayStatics::PostEvent(class UAkAudioEvent* in_pAkEvent, class AActor* in_pActor, bool in_stopWhenAttachedToDestroyed, FString EventName)
{
	if (in_pAkEvent == NULL && EventName.IsEmpty())
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::PostEvent: No Event specified!"));
		return;
	}

	if ( in_pActor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::PostEvent: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	UWorld* CurrentWorld = in_pActor->GetWorld();
	if( CurrentWorld->AllowAudioPlayback() && AkAudioDevice )
	{
		if (in_pAkEvent != NULL)
		{
			AkAudioDevice->PostEvent(in_pAkEvent, in_pActor, 0, NULL, NULL, in_stopWhenAttachedToDestroyed);
		}
		else
		{
			AkAudioDevice->PostEvent(EventName, in_pActor, 0, NULL, NULL, in_stopWhenAttachedToDestroyed);
		}
	}
}
void UInterpTrackAkAudioEvent::UpdateTrack(float NewPosition, UInterpTrackInst* TrInst, bool bJump)
{
	if (Events.Num() <= 0)
	{
		//UE_LOG(LogMatinee, Warning,TEXT("No sounds for sound track %s"),*GetName());
		return;
	}

	UInterpTrackInstAkAudioEvent* EventInst = CastChecked<UInterpTrackInstAkAudioEvent>(TrInst);

	// Only play AkEvents if we are playing Matinee forwards, and 
	if(NewPosition > EventInst->LastUpdatePosition && !bJump)
	{
		// Find which sound we are starting in. -1 Means before first sound.
		int32 StartEventIdx = -1; 
		for( StartEventIdx = -1; StartEventIdx<Events.Num()-1 && Events[StartEventIdx+1].Time < EventInst->LastUpdatePosition; StartEventIdx++);

		// Find which sound we are ending in. -1 Means before first sound.
		int32 EndEventIdx = -1; 
		for( EndEventIdx = -1; EndEventIdx<Events.Num()-1 && Events[EndEventIdx+1].Time < NewPosition; EndEventIdx++);

		// If we have moved into a new sound, we should start playing it now.
		if(StartEventIdx != EndEventIdx)
		{
			FAkAudioEventTrackKey & AkEvenTrackKey = GetAkEventTrackKeyAtPosition(NewPosition);
			UAkAudioEvent* AkEvent = AkEvenTrackKey.AkAudioEvent;
			AActor* Actor = TrInst->GetGroupActor();

			FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
			if (AudioDevice)
			{
				if (AkEvent)
				{
					AudioDevice->PostEvent(AkEvent, Actor);
				}
				else
				{
					AudioDevice->PostEvent(AkEvenTrackKey.EventName, Actor);
				}
			}
		}
	}

	// Finally update the current position as the last one.
	EventInst->LastUpdatePosition = NewPosition;
}
예제 #3
0
void UAkGameplayStatics::PostEventByName(const FString& EventName, class AActor* in_pActor, bool in_stopWhenAttachedToDestroyed)
{
	if ( in_pActor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::PostEventByName: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	UWorld* CurrentWorld = in_pActor->GetWorld();
	if( CurrentWorld->AllowAudioPlayback() && AkAudioDevice )
	{
		AkAudioDevice->PostEvent(EventName, in_pActor, 0, NULL, NULL, in_stopWhenAttachedToDestroyed);
	}
}