Ejemplo n.º 1
1
void UAkGameplayStatics::SetRTPCValue( FName RTPC, float Value, int32 InterpolationTimeMs = 0, class AActor* Actor = NULL )
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice && RTPC.IsValid() )
	{
		AudioDevice->SetRTPCValue( *RTPC.ToString(), Value, InterpolationTimeMs, Actor );
	}
}
Ejemplo n.º 2
0
void UAkGameplayStatics::UnloadBankByName(const FString& BankName)
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		if(AudioDevice->GetAkBankManager() != NULL )
		{
			for ( TObjectIterator<UAkAudioBank> Iter; Iter; ++Iter )
			{
				if( Iter->GetName() == BankName )
				{
					Iter->Unload();
					return;
				}
			}

			
			// Bank not found in the assets, unload it by name anyway
			AudioDevice->UnloadBank(BankName);
		}
		else
		{
			AudioDevice->UnloadBank(BankName);
		}
	}
}
Ejemplo n.º 3
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);
		}
	}
}
Ejemplo n.º 4
0
void UAkGameplayStatics::LoadBankByName(const FString& BankName)
{
	
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		if(AudioDevice->GetAkBankManager() != NULL )
		{
			for ( TObjectIterator<UAkAudioBank> Iter; Iter; ++Iter )
			{
				if( Iter->GetName() == BankName )
				{
					Iter->Load();
					return;
				}
			}

			// Bank not found in the assets, load it by name anyway
			AkUInt32 bankID;
			AudioDevice->LoadBank(BankName, AK_DEFAULT_POOL_ID, bankID);
		}
		else
		{
			AkUInt32 bankID;
			AudioDevice->LoadBank(BankName, AK_DEFAULT_POOL_ID, bankID);
		}
	}
}
Ejemplo n.º 5
0
void UAkGameplayStatics::StopProfilerCapture()
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->StopProfilerCapture();
	}
}
Ejemplo n.º 6
0
void UAkGameplayStatics::LoadInitBank()
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->LoadInitBank();
	}
}
void FAssetTypeActions_AkAudioBank::LoadInitBank(TArray<TWeakObjectPtr<UAkAudioBank>> Objects)
{
	FAkAudioDevice* AudioDevice = FAkAudioDevice::Get();
	if ( AudioDevice )
	{
		AudioDevice->LoadInitBank();
	}
}
Ejemplo n.º 8
0
void UAkGameplayStatics::ClearBanks()
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->ClearBanks();
	}
}
Ejemplo n.º 9
0
void UAkGameplayStatics::AddOutputCaptureMarker(const FString& MarkerText)
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->AddOutputCaptureMarker(MarkerText);
	} 
}
Ejemplo n.º 10
0
void UAkGameplayStatics::StopAll()
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->StopAllSounds();
	}
}
void FAssetTypeActions_AkAudioBank::RefreshAllBanks(TArray<TWeakObjectPtr<UAkAudioBank>> Objects)
{
	FAkAudioDevice* AudioDevice = FAkAudioDevice::Get();
	if ( AudioDevice )
	{
		AudioDevice->ReloadAllReferencedBanks();
	}
}
Ejemplo n.º 12
0
void UAkGameplayStatics::SetState( FName stateGroup, FName state )
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice && stateGroup.IsValid() && state.IsValid() )
	{
		AudioDevice->SetState( *stateGroup.ToString() , *state.ToString() );
	}
}
Ejemplo n.º 13
0
void UAkGameplayStatics::PostEventAtLocationByName( const FString& EventName, FVector Location, FRotator Orientation, UObject* WorldContextObject )
{
	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	UWorld* CurrentWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
	if( CurrentWorld->AllowAudioPlayback() && AkAudioDevice )
	{
		AkAudioDevice->PostEventAtLocation(EventName, Location, Orientation.Vector(), GEngine->GetWorldFromContextObject(WorldContextObject) );
	}
}
Ejemplo n.º 14
0
void UAkGameplayStatics::LoadBanks(const TArray<UAkAudioBank *>& SoundBanks, bool SynchronizeSoundBanks)
{
	if( SynchronizeSoundBanks )
	{
		TSet<UAkAudioBank*> BanksToUnload;
		TSet<UAkAudioBank*> BanksToLoad;
		TSet<UAkAudioBank*> InputBankSet(SoundBanks);
		FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
		if( AkAudioDevice )
		{
			FAkBankManager* BankManager = AkAudioDevice->GetAkBankManager();
			if( BankManager )
			{
				FScopeLock Lock(&BankManager->m_BankManagerCriticalSection);
				const TSet<UAkAudioBank *>* LoadedBanks = BankManager->GetLoadedBankList();

				// We load what's in the input set, but not in the already loaded set
				BanksToLoad = InputBankSet.Difference(*LoadedBanks);

				// We unload what's in the loaded set but not in the input set
				BanksToUnload = LoadedBanks->Difference(InputBankSet);
			}
			else
			{
				UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::LoadBanks: Bank Manager unused, and CleanUpBanks set to true!"));
			}
		}
		for(TSet<UAkAudioBank*>::TConstIterator LoadIter(BanksToLoad); LoadIter; ++LoadIter)
		{
			if( *LoadIter != NULL )
			{
				(*LoadIter)->Load();
			}
		}

		for(TSet<UAkAudioBank*>::TConstIterator UnloadIter(BanksToUnload); UnloadIter; ++UnloadIter)
		{
			if( *UnloadIter != NULL )
			{
				(*UnloadIter)->Unload();
			}
		}
	}
	else
	{
		for(TArray<UAkAudioBank*>::TConstIterator LoadIter(SoundBanks); LoadIter; ++LoadIter)
		{
			if( *LoadIter != NULL )
			{
				(*LoadIter)->Load();
			}
		}
	}


}
Ejemplo n.º 15
0
UAkComponent* UAkGameplayStatics::SpawnAkComponentAtLocation(UObject* WorldContextObject, class UAkAudioEvent* AkEvent, FVector Location, FRotator Orientation, bool AutoPost, const FString& EventName, bool AutoDestroy /* = true*/ )
{
	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	UWorld* CurrentWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
	if( CurrentWorld && CurrentWorld->AllowAudioPlayback() && AkAudioDevice )
	{
		return AkAudioDevice->SpawnAkComponentAtLocation(AkEvent, Location, Orientation, AutoPost, EventName, AutoDestroy, CurrentWorld );
	}

	return nullptr;
}
void UInterpTrackAkAudioRTPC::UpdateTrack(float NewPosition, UInterpTrackInst* TrInst, bool bJump)
{
	AActor* Actor = TrInst->GetGroupActor();

	float DefaultValue = 0.0f;
	float NewFloatValue = FloatTrack.Eval( NewPosition, DefaultValue );

	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice && Param.Len() )
	{
		AudioDevice->SetRTPCValue( *Param, NewFloatValue, 0, Actor );
	}
}
Ejemplo n.º 17
0
void UAkGameplayStatics::StartProfilerCapture(const FString& Filename)
{
	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		FString name = Filename;
		if( !name.EndsWith(".prof") )
		{
			name += ".prof";
		}
		AudioDevice->StartProfilerCapture(name);
	} 
}
Ejemplo n.º 18
0
void UAkGameplayStatics::PostTrigger( FName Trigger, class AActor* Actor )
{
	if ( Actor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::PostTrigger: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice && Trigger.IsValid() )
	{
		AudioDevice->PostTrigger( *Trigger.ToString(), Actor );
	}
}
Ejemplo n.º 19
0
void UAkGameplayStatics::StopActor(class AActor* Actor)
{
	if ( Actor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::StopActor: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		AudioDevice->StopGameObject(AudioDevice->GetAkComponent(Actor->GetRootComponent(), FName(), NULL, EAttachLocation::KeepRelativeOffset));
	}
}
Ejemplo n.º 20
0
void UAkGameplayStatics::SetSwitch( FName SwitchGroup, FName SwitchState, class AActor* Actor )
{
	if ( Actor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::SetSwitch: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice && SwitchGroup.IsValid() && SwitchState.IsValid() )
	{
		AudioDevice->SetSwitch( *SwitchGroup.ToString(), *SwitchState.ToString(), Actor );
	}
}
Ejemplo n.º 21
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);
	}
}
Ejemplo n.º 22
0
class UAkComponent * UAkGameplayStatics::GetAkComponent( class USceneComponent* AttachToComponent, FName AttachPointName, FVector Location, EAttachLocation::Type LocationType )
{
	if ( AttachToComponent == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::GetAkComponent: NULL AttachToComponent specified!"));
		return NULL;
	}

	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	if( AkAudioDevice )
	{
		return AkAudioDevice->GetAkComponent( AttachToComponent, AttachPointName, &Location, LocationType );
	}

	return NULL;
}
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;
}
Ejemplo n.º 24
0
void UAkGameplayStatics::SetOcclusionRefreshInterval(float RefreshInterval, class AActor* Actor )
{
	if ( Actor == NULL )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::SetOcclusionRefreshInterval: NULL Actor specified!"));
		return;
	}

	FAkAudioDevice * AudioDevice = FAkAudioDevice::Get();
	if( AudioDevice )
	{
		UAkComponent * ComponentToSet = AudioDevice->GetAkComponent(Actor->GetRootComponent(), FName(), NULL, EAttachLocation::KeepRelativeOffset);
		if( ComponentToSet != NULL )
		{
			ComponentToSet->OcclusionRefreshInterval = RefreshInterval;
		}
	}
}
Ejemplo n.º 25
0
void UAkGameplayStatics::PostEventAtLocation( class UAkAudioEvent* in_pAkEvent, FVector Location, FRotator Orientation, const FString& EventName, UObject* WorldContextObject )
{
	if ( in_pAkEvent == NULL && EventName.IsEmpty() )
	{
		UE_LOG(LogScript, Warning, TEXT("UAkGameplayStatics::PostEventAtLocation: No Event specified!"));
		return;
	}

	FAkAudioDevice * AkAudioDevice = FAkAudioDevice::Get();
	UWorld* CurrentWorld = GEngine->GetWorldFromContextObject(WorldContextObject);
	if( CurrentWorld->AllowAudioPlayback() && AkAudioDevice )
	{
		if (in_pAkEvent != NULL)
		{
			AkAudioDevice->PostEventAtLocation(in_pAkEvent, Location, Orientation.Vector(), GEngine->GetWorldFromContextObject(WorldContextObject));
		}
		else
		{
			AkAudioDevice->PostEventAtLocation(EventName, Location, Orientation.Vector(), GEngine->GetWorldFromContextObject(WorldContextObject));
		}
	}
}
Ejemplo n.º 26
0
void UAkSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
	const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;
	const FName MemberPropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;

	if ( PropertyName == GET_MEMBER_NAME_CHECKED(UAkSettings, MaxSimultaneousReverbVolumes) )
	{
		MaxSimultaneousReverbVolumes = FMath::Clamp<uint8>( MaxSimultaneousReverbVolumes, 0, AK_MAX_AUX_PER_OBJ );
		FAkAudioDevice* AkAudioDevice = FAkAudioDevice::Get();
		if( AkAudioDevice )
		{
			AkAudioDevice->SetMaxAuxBus(MaxSimultaneousReverbVolumes);
		}
	}
	else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettings, WwiseWindowsInstallationPath))
	{
		WwiseWindowsInstallationPath.Path = WwiseWindowsInstallationPath.Path.Trim();
		WwiseWindowsInstallationPath.Path = WwiseWindowsInstallationPath.Path.TrimTrailing();

		FText FailReason;
		if (!FPaths::ValidatePath(WwiseWindowsInstallationPath.Path, &FailReason))
		{
			FMessageDialog::Open(EAppMsgType::Ok, FailReason);
			WwiseWindowsInstallationPath.Path = PreviousWwiseWindowsPath;
		}

		if (!FPaths::DirectoryExists(WwiseWindowsInstallationPath.Path))
		{
			FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("Please enter a valid Wwise Authoring Windows executable path"));
			WwiseWindowsInstallationPath.Path = PreviousWwiseWindowsPath;
		}
	}
	else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettings, WwiseMacInstallationPath))
	{
		WwiseMacInstallationPath.FilePath = WwiseMacInstallationPath.FilePath.Trim();
		WwiseMacInstallationPath.FilePath = WwiseMacInstallationPath.FilePath.TrimTrailing();

		FText FailReason;
		if (!FPaths::ValidatePath(WwiseMacInstallationPath.FilePath, &FailReason))
		{
			FMessageDialog::Open(EAppMsgType::Ok, FailReason);
			WwiseMacInstallationPath.FilePath = PreviousWwiseMacPath;
		}

		if (!FPaths::DirectoryExists(WwiseMacInstallationPath.FilePath))
		{
			FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("Please enter a valid Wwise Authoring Mac executable path"));
			WwiseMacInstallationPath.FilePath = PreviousWwiseMacPath;
		}
	}
	else if (MemberPropertyName == GET_MEMBER_NAME_CHECKED(UAkSettings, WwiseProjectPath))
	{
		WwiseProjectPath.FilePath = WwiseProjectPath.FilePath.Trim();
		WwiseProjectPath.FilePath = WwiseProjectPath.FilePath.TrimTrailing();

		FString TempPath = IFileManager::Get().ConvertToAbsolutePathForExternalAppForWrite(*WwiseProjectPath.FilePath);
		
		FText FailReason;
		if (!FPaths::ValidatePath(TempPath, &FailReason))
		{
            if(EAppReturnType::Ok == FMessageDialog::Open(EAppMsgType::Ok, FailReason))
            {
                WwiseProjectPath.FilePath = PreviousWwiseProjectPath;
                return;
            }
		}

		if (!FPaths::FileExists(TempPath))
		{
			// Path might be a valid one (relative to game) entered manually. Check that.
			TempPath = FPaths::ConvertRelativePathToFull(FPaths::GameDir(), WwiseProjectPath.FilePath);

			if (!FPaths::FileExists(TempPath))
			{
				if (EAppReturnType::Ok == FMessageDialog::Open(EAppMsgType::Ok, FText::FromString("Please enter a valid Wwise project")))
				{
					WwiseProjectPath.FilePath = PreviousWwiseProjectPath;
					return;
				}
			}
		}

		// Make the path relative to the game dir
		FPaths::MakePathRelativeTo(TempPath, *FPaths::GameDir());
        WwiseProjectPath.FilePath = TempPath;

		if (WwiseProjectPath.FilePath != PreviousWwiseProjectPath)
		{
			TSharedRef<SDockTab> WwisePickerTab = FGlobalTabmanager::Get()->InvokeTab(FName("WwisePicker"));
            bRequestRefresh = true;
		}
	}

	Super::PostEditChangeProperty(PropertyChangedEvent);
}