├── Content ├── LipSyncMap.umap └── LipSync │ ├── Meshes │ ├── eyes.uasset │ ├── sil.uasset │ ├── sil2.uasset │ ├── sil3.uasset │ ├── Head-3.uasset │ ├── head-2.uasset │ ├── RobotHead.uasset │ ├── head-girl.uasset │ ├── head-girl_Skeleton.uasset │ ├── RobotHead_TextureFlip.uasset │ └── head-girl_PhysicsAsset.uasset │ ├── Textures │ ├── CH.uasset │ ├── DD.uasset │ ├── E.uasset │ ├── FF.uasset │ ├── PP.uasset │ ├── RR.uasset │ ├── SS.uasset │ ├── TH.uasset │ ├── aa.uasset │ ├── ih.uasset │ ├── kk.uasset │ ├── nn.uasset │ ├── oh.uasset │ ├── ou.uasset │ ├── sil.uasset │ ├── Head-3.uasset │ └── Girlhead_Diffuse.uasset │ ├── Materials │ ├── sil.uasset │ ├── head-2.uasset │ └── Mat_Girlhead.uasset │ └── Blueprints │ ├── VisemeTest.uasset │ ├── LipSyncMorphTarget.uasset │ └── LipSyncTextureFlip.uasset ├── Config ├── DefaultGame.ini ├── DefaultEditor.ini ├── DefaultEngine.ini └── DefaultInput.ini ├── Plugins └── OVRLipSync │ ├── .gitignore │ ├── Resources │ └── Icon128.png │ ├── Binaries │ ├── Win32 │ │ └── OVRLipSync.dll │ └── Win64 │ │ ├── OVRLipSync_x64.dll │ │ ├── UE4Editor-OVRLipSync.dll │ │ └── UE4Editor.modules │ ├── Source │ └── OVRLipSync │ │ ├── Private │ │ ├── OVRLipSyncPrivatePCH.h │ │ ├── LipSyncMorphTargetComponent.cpp │ │ ├── OVRLipSync.h │ │ ├── LipSyncTextureFlipComponent.cpp │ │ ├── LipSyncMicInputComponent.cpp │ │ ├── OVRLipSyncContextComponent.cpp │ │ └── OVRLipSync.cpp │ │ ├── Public │ │ ├── OVRLipSyncModule.h │ │ └── ILipSync.h │ │ ├── Classes │ │ ├── LipSyncMorphTargetComponent.h │ │ ├── LipSyncMicInputComponent.h │ │ ├── LipSyncTextureFlipComponent.h │ │ └── OVRLipSyncContextComponent.h │ │ └── OVRLipSync.Build.cs │ ├── OVRLipSync.uplugin │ └── LICENSE ├── README.md ├── Source ├── LipSyncTest │ ├── LipSyncTest.h │ ├── LipSyncTestGameMode.cpp │ ├── LipSyncTest.cpp │ ├── LipSyncTestGameMode.h │ └── LipSyncTest.Build.cs ├── LipSyncTest.Target.cs └── LipSyncTestEditor.Target.cs └── LipSyncTest.uproject /Content/LipSyncMap.umap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSyncMap.umap -------------------------------------------------------------------------------- /Config/DefaultGame.ini: -------------------------------------------------------------------------------- 1 | [/Script/EngineSettings.GeneralProjectSettings] 2 | ProjectID=2BDAD431488C7CECCA470BBC79668EB5 3 | -------------------------------------------------------------------------------- /Content/LipSync/Meshes/eyes.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/eyes.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/sil.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/sil.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/sil2.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/sil2.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/sil3.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/sil3.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/CH.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/CH.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/DD.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/DD.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/E.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/E.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/FF.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/FF.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/PP.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/PP.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/RR.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/RR.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/SS.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/SS.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/TH.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/TH.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/aa.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/aa.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/ih.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/ih.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/kk.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/kk.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/nn.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/nn.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/oh.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/oh.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/ou.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/ou.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/sil.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/sil.uasset -------------------------------------------------------------------------------- /Content/LipSync/Materials/sil.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Materials/sil.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/Head-3.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/Head-3.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/head-2.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/head-2.uasset -------------------------------------------------------------------------------- /Plugins/OVRLipSync/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | *.pdb 7 | 8 | # folders 9 | Intermediate -------------------------------------------------------------------------------- /Content/LipSync/Materials/head-2.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Materials/head-2.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/RobotHead.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/RobotHead.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/head-girl.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/head-girl.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/Head-3.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/Head-3.uasset -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Plugins/OVRLipSync/Resources/Icon128.png -------------------------------------------------------------------------------- /Content/LipSync/Blueprints/VisemeTest.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Blueprints/VisemeTest.uasset -------------------------------------------------------------------------------- /Content/LipSync/Materials/Mat_Girlhead.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Materials/Mat_Girlhead.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/head-girl_Skeleton.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/head-girl_Skeleton.uasset -------------------------------------------------------------------------------- /Content/LipSync/Textures/Girlhead_Diffuse.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Textures/Girlhead_Diffuse.uasset -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Binaries/Win32/OVRLipSync.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Plugins/OVRLipSync/Binaries/Win32/OVRLipSync.dll -------------------------------------------------------------------------------- /Content/LipSync/Blueprints/LipSyncMorphTarget.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Blueprints/LipSyncMorphTarget.uasset -------------------------------------------------------------------------------- /Content/LipSync/Blueprints/LipSyncTextureFlip.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Blueprints/LipSyncTextureFlip.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/RobotHead_TextureFlip.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/RobotHead_TextureFlip.uasset -------------------------------------------------------------------------------- /Content/LipSync/Meshes/head-girl_PhysicsAsset.uasset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Content/LipSync/Meshes/head-girl_PhysicsAsset.uasset -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Binaries/Win64/OVRLipSync_x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Plugins/OVRLipSync/Binaries/Win64/OVRLipSync_x64.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ovrlipsync-example 2 | Example Project for UE4 Unofficial OVRLipSync Plugin 3 | # more information 4 | http://blog.csdn.net/xoyojank/article/details/52636952 5 | -------------------------------------------------------------------------------- /Source/LipSyncTest/LipSyncTest.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "Engine.h" 6 | 7 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Binaries/Win64/UE4Editor-OVRLipSync.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xoyojank/ovrlipsync-example/HEAD/Plugins/OVRLipSync/Binaries/Win64/UE4Editor-OVRLipSync.dll -------------------------------------------------------------------------------- /Config/DefaultEditor.ini: -------------------------------------------------------------------------------- 1 | [EditoronlyBP] 2 | bAllowClassAndBlueprintPinMatching=true 3 | bReplaceBlueprintWithClass=true 4 | bDontLoadBlueprintOutsideEditor=true 5 | bBlueprintIsNotBlueprintType=true 6 | -------------------------------------------------------------------------------- /Source/LipSyncTest/LipSyncTestGameMode.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "LipSyncTest.h" 4 | #include "LipSyncTestGameMode.h" 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Binaries/Win64/UE4Editor.modules: -------------------------------------------------------------------------------- 1 | { 2 | "Changelist" : 3039270, 3 | "BuildId" : "90d3c832-5b80-4237-90bb-c51c3950647c", 4 | "Modules" : 5 | { 6 | "OVRLipSync" : "UE4Editor-OVRLipSync.dll" 7 | } 8 | } -------------------------------------------------------------------------------- /Source/LipSyncTest/LipSyncTest.cpp: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #include "LipSyncTest.h" 4 | 5 | IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, LipSyncTest, "LipSyncTest" ); 6 | -------------------------------------------------------------------------------- /LipSyncTest.uproject: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "EngineAssociation": "4.12", 4 | "Category": "", 5 | "Description": "", 6 | "Modules": [ 7 | { 8 | "Name": "LipSyncTest", 9 | "Type": "Runtime", 10 | "LoadingPhase": "Default" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /Source/LipSyncTest/LipSyncTestGameMode.h: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | #pragma once 4 | 5 | #include "GameFramework/GameMode.h" 6 | #include "LipSyncTestGameMode.generated.h" 7 | 8 | /** 9 | * 10 | */ 11 | UCLASS() 12 | class LIPSYNCTEST_API ALipSyncTestGameMode : public AGameMode 13 | { 14 | GENERATED_BODY() 15 | 16 | 17 | 18 | 19 | }; 20 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/OVRLipSyncPrivatePCH.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | #pragma once 3 | #include "OVRLipSync.h" 4 | #include "Engine.h" 5 | // You should place include statements to your module's private header files here. You only need to 6 | // add includes for headers that are used in most of your module's source files though. 7 | 8 | DEFINE_LOG_CATEGORY_STATIC(OVRLipSyncPluginLog, Log, All); 9 | -------------------------------------------------------------------------------- /Config/DefaultEngine.ini: -------------------------------------------------------------------------------- 1 | [URL] 2 | 3 | [/Script/HardwareTargeting.HardwareTargetingSettings] 4 | TargetedHardwareClass=Desktop 5 | AppliedTargetedHardwareClass=Desktop 6 | DefaultGraphicsPerformance=Maximum 7 | AppliedDefaultGraphicsPerformance=Maximum 8 | 9 | 10 | 11 | [Voice] 12 | bEnabled=true 13 | 14 | [/Script/EngineSettings.GameMapsSettings] 15 | EditorStartupMap=/Game/LipSyncMap.LipSyncMap 16 | GameDefaultMap=/Game/LipSyncMap.LipSyncMap 17 | 18 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Public/OVRLipSyncModule.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "Engine.h" 6 | #include "ModuleManager.h" 7 | #include "IPluginManager.h" 8 | #include 9 | 10 | 11 | class FOVRLipSyncModule : public ILipSync 12 | { 13 | private: 14 | 15 | 16 | public: 17 | 18 | /** IModuleInterface implementation */ 19 | virtual void StartupModule() override; 20 | virtual void ShutdownModule() override; 21 | 22 | }; -------------------------------------------------------------------------------- /Plugins/OVRLipSync/OVRLipSync.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "OVRLipSync", 6 | "Description": "", 7 | "Category": "Other", 8 | "CreatedBy": "", 9 | "CreatedByURL": "", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "EnabledByDefault": false, 14 | "CanContainContent": false, 15 | "IsBetaVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "OVRLipSync", 20 | "Type": "Developer", 21 | "LoadingPhase": "Default" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /Source/LipSyncTest.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class LipSyncTestTarget : TargetRules 7 | { 8 | public LipSyncTestTarget(TargetInfo Target) 9 | { 10 | Type = TargetType.Game; 11 | } 12 | 13 | // 14 | // TargetRules interface. 15 | // 16 | 17 | public override void SetupBinaries( 18 | TargetInfo Target, 19 | ref List OutBuildBinaryConfigurations, 20 | ref List OutExtraModuleNames 21 | ) 22 | { 23 | OutExtraModuleNames.AddRange( new string[] { "LipSyncTest" } ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/LipSyncTestEditor.Target.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | using System.Collections.Generic; 5 | 6 | public class LipSyncTestEditorTarget : TargetRules 7 | { 8 | public LipSyncTestEditorTarget(TargetInfo Target) 9 | { 10 | Type = TargetType.Editor; 11 | } 12 | 13 | // 14 | // TargetRules interface. 15 | // 16 | 17 | public override void SetupBinaries( 18 | TargetInfo Target, 19 | ref List OutBuildBinaryConfigurations, 20 | ref List OutExtraModuleNames 21 | ) 22 | { 23 | OutExtraModuleNames.AddRange( new string[] { "LipSyncTest" } ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Public/ILipSync.h: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. 2 | 3 | #pragma once 4 | 5 | #include "OVRLipSync.h" 6 | #include "ModuleManager.h" 7 | 8 | class ILipSync : public IModuleInterface 9 | { 10 | 11 | int32 instanceCtr; 12 | 13 | public: 14 | 15 | UFUNCTION(BlueprintCallable, Category = "Audio") 16 | static inline ILipSync& Get() 17 | { 18 | return FModuleManager::LoadModuleChecked< ILipSync >("OVRLipSync"); 19 | } 20 | 21 | UFUNCTION(BlueprintCallable, Category = "Audio") 22 | static inline bool IsAvailable() 23 | { 24 | return FModuleManager::Get().IsModuleLoaded("OVRLipSync"); 25 | } 26 | 27 | UFUNCTION(BlueprintCallable, Category = "Audio") 28 | int32 GetInstanceCounter() 29 | { 30 | return instanceCtr++; 31 | } 32 | 33 | }; 34 | 35 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Classes/LipSyncMorphTargetComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OVRLipSyncContextComponent.h" 4 | #include "LipSyncMorphTargetComponent.generated.h" 5 | 6 | UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) 7 | class OVRLIPSYNC_API ULipSyncMorphTargetComponent : public UOVRLipSyncContextComponent 8 | { 9 | GENERATED_UCLASS_BODY() 10 | 11 | public: 12 | virtual void BeginPlay() override; 13 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 14 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 15 | 16 | 17 | public: 18 | UPROPERTY(Category = Visemes, EditDefaultsOnly, BlueprintReadOnly) 19 | FName MouseMeshTag; 20 | 21 | private: 22 | UPROPERTY(Transient) 23 | class USkeletalMeshComponent* MouseMesh; 24 | }; 25 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Classes/LipSyncMicInputComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Components/ActorComponent.h" 3 | #include "LipSyncMicInputComponent.generated.h" 4 | 5 | // example micro input for lipsync 6 | UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) 7 | class OVRLIPSYNC_API ULipSyncMicInputComponent : public UActorComponent 8 | { 9 | GENERATED_UCLASS_BODY() 10 | 11 | public: 12 | virtual void BeginPlay() override; 13 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 14 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 15 | 16 | private: 17 | UPROPERTY(Transient) 18 | class UOVRLipSyncContextComponent* LipSyncContext; 19 | 20 | TSharedPtr VoiceCapture; 21 | TArray VoiceBuffer; 22 | TArray TempBuffer; 23 | }; 24 | -------------------------------------------------------------------------------- /Source/LipSyncTest/LipSyncTest.Build.cs: -------------------------------------------------------------------------------- 1 | // Fill out your copyright notice in the Description page of Project Settings. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class LipSyncTest : ModuleRules 6 | { 7 | public LipSyncTest(TargetInfo Target) 8 | { 9 | PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); 10 | 11 | PrivateDependencyModuleNames.AddRange(new string[] { }); 12 | 13 | // Uncomment if you are using Slate UI 14 | // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); 15 | 16 | // Uncomment if you are using online features 17 | // PrivateDependencyModuleNames.Add("OnlineSubsystem"); 18 | // if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64)) 19 | // { 20 | // if (UEBuildConfiguration.bCompileSteamOSS == true) 21 | // { 22 | // DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam"); 23 | // } 24 | // } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Classes/LipSyncTextureFlipComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OVRLipSyncContextComponent.h" 4 | #include "LipSyncTextureFlipComponent.generated.h" 5 | 6 | UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) 7 | class OVRLIPSYNC_API ULipSyncTextureFlipComponent : public UOVRLipSyncContextComponent 8 | { 9 | GENERATED_UCLASS_BODY() 10 | 11 | public: 12 | virtual void BeginPlay() override; 13 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 14 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 15 | 16 | 17 | public: 18 | UPROPERTY(Category = Visemes, EditDefaultsOnly, BlueprintReadOnly) 19 | TArray VisemeTextures; 20 | UPROPERTY(Category = Visemes, EditDefaultsOnly, BlueprintReadWrite) 21 | class UMaterialInstanceDynamic* MouseMaterail; 22 | UPROPERTY(Category = Visemes, EditDefaultsOnly, BlueprintReadOnly) 23 | FName MouseTextureName; 24 | }; 25 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/LICENSE: -------------------------------------------------------------------------------- 1 | Anything not covered by Sixense EULA and Unreal Engine EULA in Hydra UE4 Plugin provided under MIT license. 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2015 Jan "Getnamo" Kaniewski 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/LipSyncMorphTargetComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "OVRLipSyncPrivatePCH.h" 2 | #include "LipSyncMorphTargetComponent.h" 3 | 4 | ULipSyncMorphTargetComponent::ULipSyncMorphTargetComponent(const FObjectInitializer& ObjectInitializer) 5 | : Super(ObjectInitializer) 6 | { 7 | struct FConstructorStatics 8 | { 9 | FName MouseMeshTag; 10 | 11 | FConstructorStatics() 12 | { 13 | MouseMeshTag = "Mouse"; 14 | } 15 | }; 16 | static FConstructorStatics ConstructorStatics; 17 | MouseMeshTag = ConstructorStatics.MouseMeshTag; 18 | } 19 | 20 | void ULipSyncMorphTargetComponent::BeginPlay() 21 | { 22 | Super::BeginPlay(); 23 | 24 | auto Components = GetOwner()->GetComponentsByTag(USkeletalMeshComponent::StaticClass(), MouseMeshTag); 25 | if (Components.Num() > 0) 26 | { 27 | MouseMesh = (USkeletalMeshComponent*)(Components[0]); 28 | check(MouseMesh != nullptr); 29 | } 30 | } 31 | 32 | void ULipSyncMorphTargetComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) 33 | { 34 | Super::EndPlay(EndPlayReason); 35 | 36 | } 37 | 38 | void ULipSyncMorphTargetComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 39 | { 40 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 41 | 42 | if (MouseMesh == nullptr) 43 | return; 44 | FOVRLipSyncFrame LipSyncFrame; 45 | if (ovrLipSyncSuccess == GetPhonemeFrame(&LipSyncFrame)) 46 | { 47 | for (int i = 0; i < (int)ovrLipSyncViseme::VisemesCount; ++i) 48 | { 49 | float VisemeValue = LipSyncFrame.Visemes[i]; 50 | MouseMesh->SetMorphTarget(VisemeNames[i], VisemeValue, false); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/OVRLipSync.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "OVRLipSyncModule.h" 3 | #include "OVRLipSyncContextComponent.h" 4 | 5 | // Error codes that may return from Lip-Sync engine 6 | enum ovrLipSyncError 7 | { 8 | Unknown = -2200, //< An unknown error has occurred 9 | CannotCreateContext = -2201, //< Unable to create a context 10 | InvalidParam = -2202, //< An invalid parameter, e.g. NULL pointer or out of range 11 | BadSampleRate = -2203, //< An unsupported sample rate was declared 12 | MissingDLL = -2204, //< The DLL or shared library could not be found 13 | BadVersion = -2205, //< Mismatched versions between header and libs 14 | UndefinedFunction = -2206 //< An undefined function 15 | }; 16 | 17 | /// Flags 18 | enum ovrLipSyncFlag 19 | { 20 | None = 0x0000, 21 | DelayCompensateAudio = 0x0001 22 | 23 | }; 24 | 25 | // Enum for sending lip-sync engine specific signals 26 | enum ovrLipSyncSignals 27 | { 28 | VisemeOn, 29 | VisemeOff, 30 | VisemeAmount, 31 | VisemeSmoothing, 32 | SignalCount 33 | }; 34 | 35 | #define ovrLipSyncSuccess 0 36 | 37 | class FOVRLipSync 38 | { 39 | static int sOVRLipSyncInit; 40 | 41 | public: 42 | static void Initialize(); 43 | static int IsInitialized(); 44 | static void Shutdown(); 45 | 46 | static int CreateContext(unsigned int* Context, ovrLipSyncContextProvider Provider); 47 | static int DestroyContext(unsigned int Context); 48 | static int ResetContext(unsigned int Context); 49 | static int SendSignal(unsigned int Context, ovrLipSyncSignals Signal, int Arg1, int Arg2); 50 | static int ProcessFrame(unsigned int Context, float* AudioBuffer, ovrLipSyncFlag Flags, FOVRLipSyncFrame* Frame); 51 | static int ProcessFrameInterleaved(unsigned int Context, float* AudioBuffer, ovrLipSyncFlag Flags, FOVRLipSyncFrame* Frame); 52 | }; -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/LipSyncTextureFlipComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "OVRLipSyncPrivatePCH.h" 2 | #include "LipSyncTextureFlipComponent.h" 3 | 4 | ULipSyncTextureFlipComponent::ULipSyncTextureFlipComponent(const FObjectInitializer& ObjectInitializer) 5 | : Super(ObjectInitializer) 6 | { 7 | struct FConstructorStatics 8 | { 9 | FName MouseTextureName; 10 | 11 | FConstructorStatics() 12 | { 13 | MouseTextureName = "Mouse"; 14 | } 15 | }; 16 | static FConstructorStatics ConstructorStatics; 17 | MouseTextureName = ConstructorStatics.MouseTextureName; 18 | } 19 | 20 | void ULipSyncTextureFlipComponent::BeginPlay() 21 | { 22 | Super::BeginPlay(); 23 | 24 | check(VisemeTextures.Num() == (int)ovrLipSyncViseme::VisemesCount); 25 | } 26 | 27 | void ULipSyncTextureFlipComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) 28 | { 29 | Super::EndPlay(EndPlayReason); 30 | 31 | } 32 | 33 | void ULipSyncTextureFlipComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 34 | { 35 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 36 | 37 | if (MouseMaterail == nullptr) 38 | return; 39 | FOVRLipSyncFrame LipSyncFrame; 40 | if (ovrLipSyncSuccess == GetPhonemeFrame(&LipSyncFrame)) 41 | { 42 | int MaxValueIndex = 0; 43 | float MaxValue = -FLT_MAX; 44 | for (int i = 0; i < (int)ovrLipSyncViseme::VisemesCount; ++i) 45 | { 46 | float VisemeValue = LipSyncFrame.Visemes[i]; 47 | if (VisemeValue > MaxValue) 48 | { 49 | MaxValue = VisemeValue; 50 | MaxValueIndex = i; 51 | } 52 | } 53 | MouseMaterail->SetTextureParameterValue(MouseTextureName, VisemeTextures[MaxValueIndex]); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/LipSyncMicInputComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "OVRLipSyncPrivatePCH.h" 2 | #include "LipSyncMicInputComponent.h" 3 | #include "OVRLipSyncContextComponent.h" 4 | 5 | #include "VoiceCapture.h" 6 | #include "VoiceModule.h" 7 | 8 | 9 | ULipSyncMicInputComponent::ULipSyncMicInputComponent(const FObjectInitializer& ObjectInitializer) 10 | : Super(ObjectInitializer) 11 | { 12 | PrimaryComponentTick.bCanEverTick = true; 13 | } 14 | 15 | void ULipSyncMicInputComponent::BeginPlay() 16 | { 17 | Super::BeginPlay(); 18 | 19 | LipSyncContext = GetOwner()->FindComponentByClass(); 20 | check(LipSyncContext != nullptr); 21 | 22 | VoiceCapture = FVoiceModule::Get().CreateVoiceCapture(); 23 | check(VoiceCapture.IsValid()); 24 | VoiceCapture->Start(); 25 | } 26 | 27 | void ULipSyncMicInputComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) 28 | { 29 | Super::EndPlay(EndPlayReason); 30 | 31 | VoiceCapture->Shutdown(); 32 | } 33 | 34 | void ULipSyncMicInputComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 35 | { 36 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 37 | 38 | // should be moved to background thread for better performance 39 | uint32 BytesAvailable = 0; 40 | EVoiceCaptureState::Type CaptureState = VoiceCapture->GetCaptureState(BytesAvailable); 41 | if (CaptureState == EVoiceCaptureState::Ok) 42 | { 43 | TempBuffer.SetNumUninitialized(BytesAvailable); 44 | VoiceCapture->GetVoiceData(TempBuffer.GetData(), BytesAvailable, BytesAvailable); 45 | VoiceBuffer.Append(TempBuffer); 46 | } 47 | if (VoiceBuffer.Num() >= VISEME_BUF_SIZE) 48 | { 49 | LipSyncContext->ProcessFrame(VoiceBuffer.GetData(), VISEME_BUF_SIZE); 50 | VoiceBuffer.RemoveAt(0, VISEME_BUF_SIZE); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Classes/OVRLipSyncContextComponent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Components/ActorComponent.h" 3 | #include "OVRLipSyncContextComponent.generated.h" 4 | 5 | #define VISEME_SAMPLES 1024 6 | #define VISEME_BUF_SIZE 2048 7 | 8 | // Various visemes 9 | enum ovrLipSyncViseme 10 | { 11 | sil, 12 | PP, 13 | FF, 14 | TH, 15 | DD, 16 | kk, 17 | CH, 18 | SS, 19 | nn, 20 | RR, 21 | aa, 22 | E, 23 | ih, 24 | oh, 25 | ou, 26 | VisemesCount 27 | }; 28 | 29 | // Enum for provider context to create 30 | enum ovrLipSyncContextProvider 31 | { 32 | Main, 33 | Other 34 | }; 35 | 36 | USTRUCT(BlueprintType) 37 | struct FOVRLipSyncFrame 38 | { 39 | GENERATED_BODY() 40 | 41 | FOVRLipSyncFrame() 42 | { 43 | FrameNumber = 0; 44 | FrameDelay = 0; 45 | Visemes.AddDefaulted((int)ovrLipSyncViseme::VisemesCount); 46 | } 47 | 48 | FOVRLipSyncFrame& operator=(const FOVRLipSyncFrame& Other) 49 | { 50 | FrameNumber = Other.FrameNumber; 51 | FrameDelay = Other.FrameDelay; 52 | Visemes = Other.Visemes; 53 | 54 | return *this; 55 | } 56 | 57 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = LipSync) 58 | int FrameNumber; // count from start of recognition 59 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = LipSync) 60 | int FrameDelay; // in ms 61 | UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = LipSync) 62 | TArray Visemes; // Array of floats for viseme frame. Size of Viseme Count, above 63 | }; 64 | 65 | DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FVisemeGeneratedSignature, FOVRLipSyncFrame, LipSyncFrame); 66 | 67 | UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) 68 | class OVRLIPSYNC_API UOVRLipSyncContextComponent : public UActorComponent 69 | { 70 | GENERATED_UCLASS_BODY() 71 | 72 | public: 73 | virtual void BeginPlay() override; 74 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; 75 | virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; 76 | 77 | /** 78 | * thread safe voice processing, the result is saved in CurrentFrame 79 | * 80 | * @param AudioData - 16000 sample rate, 1 channel 81 | * @param BufferSize - must be >= VISEME_BUF_SIZE 82 | */ 83 | void ProcessFrame(const uint8* AudioData, const int32 BufferSize); 84 | 85 | int GetPhonemeFrame(FOVRLipSyncFrame *OutFrame); 86 | 87 | public: 88 | UPROPERTY(Category = Voice, BlueprintAssignable) 89 | FVisemeGeneratedSignature VisemeGenerated; 90 | 91 | UPROPERTY(Category = Visemes, EditDefaultsOnly, BlueprintReadOnly) 92 | TArray VisemeNames; 93 | 94 | UPROPERTY(Category = Visemes, EditAnywhere, BlueprintReadWrite) 95 | bool bDebugVisemes; 96 | 97 | private: 98 | FCriticalSection LipSyncFrameCriticalSection; 99 | FOVRLipSyncFrame CurrentFrame; 100 | float SampleBuffer[VISEME_SAMPLES * 2]; 101 | 102 | unsigned int CurrentContext = 0; 103 | ovrLipSyncContextProvider ContextProvider = ovrLipSyncContextProvider::Main; 104 | }; 105 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/OVRLipSync.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | using System.IO; 5 | 6 | public class OVRLipSync : ModuleRules 7 | { 8 | private string ModulePath 9 | { 10 | get { return ModuleDirectory; } 11 | } 12 | 13 | private string ThirdPartyPath 14 | { 15 | get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); } 16 | } 17 | 18 | private string BinariesPath 19 | { 20 | get { return Path.GetFullPath(Path.Combine(ModulePath, "../../Binaries/")); } 21 | } 22 | 23 | public OVRLipSync(TargetInfo Target) 24 | { 25 | 26 | PublicIncludePaths.AddRange( 27 | new string[] { 28 | "OVRLipSync/Public" 29 | // ... add public include paths required here ... 30 | } 31 | ); 32 | 33 | 34 | PrivateIncludePaths.AddRange( 35 | new string[] { 36 | "OVRLipSync/Private", 37 | // ... add other private include paths required here ... 38 | } 39 | ); 40 | 41 | 42 | PublicDependencyModuleNames.AddRange( 43 | new string[] 44 | { 45 | "Core", 46 | "Projects", 47 | "CoreUObject", 48 | "Engine", 49 | "InputCore", 50 | "RHI", 51 | "Voice", 52 | "OnlineSubsystem", 53 | "OnlineSubsystemUtils" 54 | // ... add other public dependencies that you statically link with here ... 55 | } 56 | ); 57 | 58 | 59 | PrivateDependencyModuleNames.AddRange( 60 | new string[] 61 | { 62 | // ... add private dependencies that you statically link with here ... 63 | "Core", 64 | "Projects", 65 | "CoreUObject", 66 | "Engine", 67 | "InputCore", 68 | "RHI", 69 | "Voice", 70 | "OnlineSubsystem", 71 | "OnlineSubsystemUtils" 72 | } 73 | ); 74 | 75 | 76 | DynamicallyLoadedModuleNames.AddRange( 77 | new string[] 78 | { 79 | // ... add any modules that your module loads dynamically here ... 80 | } 81 | ); 82 | 83 | LoadOVRLipSyncLib(Target); 84 | } 85 | 86 | public bool LoadOVRLipSyncLib(TargetInfo Target) 87 | { 88 | bool isLibrarySupported = false; 89 | 90 | if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)) 91 | { 92 | isLibrarySupported = true; 93 | 94 | string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x32"; 95 | 96 | if (Target.Platform == UnrealTargetPlatform.Win64) 97 | { 98 | PublicDelayLoadDLLs.Add("OVRLipSync_x64.dll"); 99 | RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(BinariesPath, "Win64", "OVRLipSync_x64.dll"))); 100 | } 101 | else 102 | { 103 | PublicDelayLoadDLLs.Add("OVRLipSync.dll"); 104 | RuntimeDependencies.Add(new RuntimeDependency(Path.Combine(BinariesPath, "Win32", "OVRLipSync.dll"))); 105 | } 106 | } 107 | 108 | return isLibrarySupported; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Config/DefaultInput.ini: -------------------------------------------------------------------------------- 1 | 2 | [/Script/Engine.InputSettings] 3 | -AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 4 | -AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 5 | -AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 6 | -AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f)) 7 | -AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 8 | -AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f)) 9 | +AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 10 | +AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 11 | +AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 12 | +AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 13 | +AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 14 | +AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False)) 15 | +AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 16 | +AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 17 | +AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 18 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 19 | +AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 20 | +AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 21 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 22 | +AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 23 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 24 | +AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 25 | +AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 26 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 27 | +AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 28 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 29 | +AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False)) 30 | bAltEnterTogglesFullscreen=True 31 | bUseMouseForTouch=False 32 | bEnableMouseSmoothing=True 33 | bEnableFOVScaling=True 34 | FOVScale=0.011110 35 | DoubleClickTime=0.200000 36 | bCaptureMouseOnLaunch=True 37 | DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown 38 | bDefaultViewportMouseLock=True 39 | bAlwaysShowTouchInterface=False 40 | bShowConsoleOnFourFingerTap=True 41 | DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks 42 | ConsoleKey=None 43 | -ConsoleKeys=Tilde 44 | +ConsoleKeys=Tilde 45 | 46 | 47 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/OVRLipSyncContextComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "OVRLipSyncPrivatePCH.h" 2 | #include "OVRLipSyncContextComponent.h" 3 | 4 | 5 | UOVRLipSyncContextComponent::UOVRLipSyncContextComponent(const FObjectInitializer& ObjectInitializer) 6 | : Super(ObjectInitializer) 7 | { 8 | struct FConstructorStatics 9 | { 10 | TArray VisemeNames; 11 | 12 | FConstructorStatics() 13 | { 14 | VisemeNames.SetNum(ovrLipSyncViseme::VisemesCount); 15 | VisemeNames[ovrLipSyncViseme::sil] = "sil"; 16 | VisemeNames[ovrLipSyncViseme::PP] = "PP"; 17 | VisemeNames[ovrLipSyncViseme::FF] = "FF"; 18 | VisemeNames[ovrLipSyncViseme::TH] = "TH"; 19 | VisemeNames[ovrLipSyncViseme::DD] = "DD"; 20 | VisemeNames[ovrLipSyncViseme::kk] = "kk"; 21 | VisemeNames[ovrLipSyncViseme::CH] = "CH"; 22 | VisemeNames[ovrLipSyncViseme::SS] = "SS"; 23 | VisemeNames[ovrLipSyncViseme::nn] = "nn"; 24 | VisemeNames[ovrLipSyncViseme::RR] = "RR"; 25 | VisemeNames[ovrLipSyncViseme::aa] = "aa"; 26 | VisemeNames[ovrLipSyncViseme::E] = "E"; 27 | VisemeNames[ovrLipSyncViseme::ih] = "ih"; 28 | VisemeNames[ovrLipSyncViseme::oh] = "oh"; 29 | VisemeNames[ovrLipSyncViseme::ou] = "ou"; 30 | } 31 | }; 32 | static FConstructorStatics ConstructorStatics; 33 | VisemeNames = ConstructorStatics.VisemeNames; 34 | 35 | PrimaryComponentTick.bCanEverTick = true; 36 | } 37 | 38 | void UOVRLipSyncContextComponent::BeginPlay() 39 | { 40 | Super::BeginPlay(); 41 | 42 | FOVRLipSync::CreateContext(&CurrentContext, ContextProvider); 43 | } 44 | 45 | void UOVRLipSyncContextComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) 46 | { 47 | Super::EndPlay(EndPlayReason); 48 | 49 | if (CurrentContext) 50 | { 51 | FOVRLipSync::DestroyContext(CurrentContext); 52 | } 53 | } 54 | 55 | void UOVRLipSyncContextComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) 56 | { 57 | Super::TickComponent(DeltaTime, TickType, ThisTickFunction); 58 | 59 | if (bDebugVisemes) 60 | { 61 | FOVRLipSyncFrame LipSyncFrame; 62 | if (ovrLipSyncSuccess == GetPhonemeFrame(&LipSyncFrame)) 63 | { 64 | for (int i = 0; i < (int)ovrLipSyncViseme::VisemesCount; ++i) 65 | { 66 | float VisemeValue = LipSyncFrame.Visemes[i]; 67 | FString OutputString = FString::Printf(TEXT("%s: %f"), *VisemeNames[i].ToString(), VisemeValue); 68 | GEngine->AddOnScreenDebugMessage((uint64)-1, DeltaTime, FColor::Green, OutputString); 69 | } 70 | } 71 | } 72 | } 73 | 74 | // maybe called in another thread 75 | void UOVRLipSyncContextComponent::ProcessFrame(const uint8* AudioData, const int32 BufferSize) 76 | { 77 | check(BufferSize >= VISEME_BUF_SIZE); 78 | if (CurrentContext == 0) 79 | return; 80 | 81 | for (uint32 i = 0; i < VISEME_SAMPLES; i++) 82 | { 83 | int16 Sample = (int16)(AudioData[i * 2 + 1] << 8 | AudioData[i * 2]); 84 | SampleBuffer[i * 2] = Sample / (float)SHRT_MAX; 85 | SampleBuffer[i * 2 + 1] = Sample / (float)SHRT_MAX; 86 | } 87 | FOVRLipSyncFrame TempFrame; 88 | FOVRLipSync::ProcessFrameInterleaved(CurrentContext, SampleBuffer, ovrLipSyncFlag::None, &TempFrame); 89 | 90 | // only lock the frame copy operation 91 | { 92 | FScopeLock LipSyncFrameLock(&LipSyncFrameCriticalSection); 93 | CurrentFrame = TempFrame; 94 | } 95 | 96 | // dispatch the event 97 | if (VisemeGenerated.IsBound()) 98 | { 99 | FFunctionGraphTask::CreateAndDispatchWhenReady([=]() 100 | { 101 | VisemeGenerated.Broadcast(CurrentFrame); 102 | } 103 | , TStatId(), nullptr, ENamedThreads::GameThread); 104 | } 105 | } 106 | 107 | int UOVRLipSyncContextComponent::GetPhonemeFrame(FOVRLipSyncFrame *OutFrame) 108 | { 109 | if (FOVRLipSync::IsInitialized() != ovrLipSyncSuccess) 110 | return (int)ovrLipSyncError::Unknown; 111 | 112 | // only lock the frame copy operation 113 | { 114 | FScopeLock LipSyncFrameLock(&LipSyncFrameCriticalSection); 115 | *OutFrame = CurrentFrame; 116 | } 117 | 118 | return ovrLipSyncSuccess; 119 | } 120 | -------------------------------------------------------------------------------- /Plugins/OVRLipSync/Source/OVRLipSync/Private/OVRLipSync.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. 2 | 3 | #include "OVRLipSyncPrivatePCH.h" 4 | #include "Voice.h" 5 | 6 | //DLL import definition 7 | typedef int(*dll_ovrlipsyncInitialize)(int, int); 8 | typedef void(*dll_ovrlipsyncShutdown)(void); 9 | typedef int(*dll_ovrlipsyncGetVersion)(int*, int*, int*); 10 | typedef int(*dll_ovrlipsyncCreateContext)(unsigned int*, int); 11 | typedef int(*dll_ovrlipsyncDestroyContext)(unsigned int); 12 | typedef int(*dll_ovrlipsyncResetContext)(unsigned int); 13 | typedef int(*dll_ovrlipsyncSendSignal)(unsigned int, int, int, int); 14 | typedef int(*dll_ovrlipsyncProcessFrame)(unsigned int, float*, int, int*, int*, float*, int); 15 | typedef int(*dll_ovrlipsyncProcessFrameInterleaved)(unsigned int, float*, int, int*, int*, float*, int); 16 | 17 | dll_ovrlipsyncInitialize OVRLipSyncInitialize; 18 | dll_ovrlipsyncShutdown OVRLipSyncShutdown; 19 | dll_ovrlipsyncGetVersion OVRLipSyncGetVersion; 20 | dll_ovrlipsyncCreateContext OVRLipSyncCreateContext; 21 | dll_ovrlipsyncDestroyContext OVRLipSyncDestroyContext; 22 | dll_ovrlipsyncResetContext OVRLipSyncResetContext; 23 | dll_ovrlipsyncSendSignal OVRLipSyncSendSignal; 24 | dll_ovrlipsyncProcessFrame OVRLipSyncProcessFrame; 25 | dll_ovrlipsyncProcessFrameInterleaved OVRLipSyncProcessFrameInterleaved; 26 | 27 | #define LOCTEXT_NAMESPACE "FOVRLipSyncModule" 28 | 29 | void FOVRLipSyncModule::StartupModule() 30 | { 31 | //Define Paths for direct dll bind 32 | FString BinariesRoot = FPaths::Combine(*FPaths::GameDir(), TEXT("Binaries")); 33 | IPluginManager &plgnMgr = IPluginManager::Get(); 34 | TSharedPtr plugin = plgnMgr.FindPlugin("OVRLipSync"); 35 | if (!plugin.IsValid()) 36 | { 37 | UE_LOG(OVRLipSyncPluginLog, Error, TEXT("Plugin not found.")); 38 | return; 39 | } 40 | 41 | FString PluginRoot = plugin->GetBaseDir(); 42 | FString PlatformString; 43 | FString OVRDLLString; 44 | 45 | #if PLATFORM_WINDOWS 46 | # if _WIN64 47 | //64bit 48 | OVRDLLString = FString(TEXT("OVRLipSync_x64.dll")); 49 | PlatformString = FString(TEXT("Win64")); 50 | # else 51 | //32bit 52 | OVRDLLString = FString(TEXT("OVRLipSync.dll")); 53 | PlatformString = FString(TEXT("Win32")); 54 | # endif 55 | 56 | FString DllFilepath = FPaths::ConvertRelativePathToFull(FPaths::Combine(*PluginRoot, TEXT("Binaries"), *PlatformString, *OVRDLLString)); 57 | 58 | UE_LOG(OVRLipSyncPluginLog, Log, TEXT("Fetching dll from %s"), *DllFilepath); 59 | 60 | //Check if the file exists, if not, give a detailed log entry why 61 | if (!FPaths::FileExists(DllFilepath)) 62 | { 63 | //UE_LOG(OVRLipSyncPluginLog, Error, TEXT("%s File is missing (Did you copy Binaries into project root?)! Hydra Unavailable."), *OVRDLLString); 64 | return; 65 | } 66 | 67 | void* OVRDLLHandle = FPlatformProcess::GetDllHandle(*DllFilepath); 68 | 69 | if (!OVRDLLHandle) 70 | { 71 | UE_LOG(OVRLipSyncPluginLog, Error, TEXT("GetDllHandle failed, Hydra Unavailable.")); 72 | UE_LOG(OVRLipSyncPluginLog, Error, TEXT("Full path debug: %s."), *DllFilepath); 73 | return; 74 | } 75 | 76 | OVRLipSyncInitialize = (dll_ovrlipsyncInitialize)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_Initialize")); 77 | OVRLipSyncShutdown = (dll_ovrlipsyncShutdown)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_Shutdown")); 78 | OVRLipSyncGetVersion = (dll_ovrlipsyncGetVersion)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_GetVersion")); 79 | OVRLipSyncCreateContext = (dll_ovrlipsyncCreateContext)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_CreateContext")); 80 | OVRLipSyncDestroyContext = (dll_ovrlipsyncDestroyContext)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_DestroyContext")); 81 | OVRLipSyncResetContext = (dll_ovrlipsyncResetContext)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_ResetContext")); 82 | OVRLipSyncSendSignal = (dll_ovrlipsyncSendSignal)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_SendSignal")); 83 | OVRLipSyncProcessFrame = (dll_ovrlipsyncProcessFrame)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_ProcessFrame")); 84 | OVRLipSyncProcessFrameInterleaved = (dll_ovrlipsyncProcessFrameInterleaved)FPlatformProcess::GetDllExport(OVRDLLHandle, TEXT("ovrLipSyncDll_ProcessFrameInterleaved")); 85 | 86 | FOVRLipSync::Initialize(); 87 | #else 88 | UE_LOG(OVRLipSyncPluginLog, Error, TEXT("Unsupported Platform. OVRLipSync Unavailable.")); 89 | #endif // PLATFORM_WINDOWS 90 | } 91 | 92 | void FOVRLipSyncModule::ShutdownModule() 93 | { 94 | FOVRLipSync::Shutdown(); 95 | } 96 | 97 | #undef LOCTEXT_NAMESPACE 98 | 99 | IMPLEMENT_MODULE(FOVRLipSyncModule, OVRLipSync) 100 | 101 | ///////////////////////////////////////////////////////////////////////////////////////////// 102 | 103 | int FOVRLipSync::sOVRLipSyncInit = -1; 104 | 105 | void FOVRLipSync::Initialize() 106 | { 107 | sOVRLipSyncInit = OVRLipSyncInitialize(VOICE_SAMPLE_RATE, VISEME_SAMPLES); 108 | } 109 | 110 | int FOVRLipSync::IsInitialized() 111 | { 112 | return sOVRLipSyncInit; 113 | } 114 | 115 | void FOVRLipSync::Shutdown() 116 | { 117 | OVRLipSyncShutdown(); 118 | } 119 | 120 | int FOVRLipSync::CreateContext(unsigned int* Context, ovrLipSyncContextProvider Provider) 121 | { 122 | if (IsInitialized() != ovrLipSyncSuccess) 123 | return (int)ovrLipSyncError::CannotCreateContext; 124 | 125 | return OVRLipSyncCreateContext(Context, Provider); 126 | } 127 | 128 | int FOVRLipSync::DestroyContext(unsigned int Context) 129 | { 130 | if (IsInitialized() != ovrLipSyncSuccess) 131 | return (int)ovrLipSyncError::Unknown; 132 | 133 | return OVRLipSyncDestroyContext(Context); 134 | } 135 | 136 | int FOVRLipSync::ResetContext(unsigned int Context) 137 | { 138 | if (IsInitialized() != ovrLipSyncSuccess) 139 | return (int)ovrLipSyncError::Unknown; 140 | 141 | return OVRLipSyncResetContext(Context); 142 | } 143 | 144 | int FOVRLipSync::SendSignal(unsigned int Context, ovrLipSyncSignals Signal, int Arg1, int Arg2) 145 | { 146 | if (IsInitialized() != ovrLipSyncSuccess) 147 | return (int)ovrLipSyncError::Unknown; 148 | 149 | return OVRLipSyncSendSignal(Context, Signal, Arg1, Arg2); 150 | } 151 | 152 | int FOVRLipSync::ProcessFrame(unsigned int Context, float* AudioBuffer, ovrLipSyncFlag Flags, FOVRLipSyncFrame* Frame) 153 | { 154 | if (IsInitialized() != ovrLipSyncSuccess) 155 | return (int)ovrLipSyncError::Unknown; 156 | 157 | // this function has some bugs(version 1.0.1), so use OVRLipSyncProcessFrameInterleaved instead 158 | return OVRLipSyncProcessFrame(Context, AudioBuffer, Flags, &Frame->FrameNumber, &Frame->FrameDelay, Frame->Visemes.GetData(), Frame->Visemes.Num()); 159 | } 160 | 161 | int FOVRLipSync::ProcessFrameInterleaved(unsigned int Context, float* AudioBuffer, ovrLipSyncFlag Flags, FOVRLipSyncFrame* Frame) 162 | { 163 | if (IsInitialized() != ovrLipSyncSuccess) 164 | return (int)ovrLipSyncError::Unknown; 165 | 166 | return OVRLipSyncProcessFrameInterleaved(Context, AudioBuffer, Flags, &Frame->FrameNumber, &Frame->FrameDelay, Frame->Visemes.GetData(), Frame->Visemes.Num()); 167 | } 168 | --------------------------------------------------------------------------------