Skip to content

Commit

Permalink
[BetterLipsync] Fixed bug where lipsync was on even though we were mu…
Browse files Browse the repository at this point in the history
…ted.
  • Loading branch information
kafeijao committed Jan 3, 2023
1 parent cf29a85 commit c496ebb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions BetterLipsync/CVRMicLipsyncSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ public class CVRMicLipsyncSubscriber : BaseMicrophoneSubscriber {
private int _channels;
private bool _initialized;
private CVRLipSyncContext _lipSyncContext;
private static CVRMicLipsyncSubscriber Instance;
private static CVRMicLipsyncSubscriber _instance;
private static bool _muted;

public void Initialize(CVRLipSyncContext lipSyncContext) {
_lipSyncContext = lipSyncContext;
_lipSyncContext.Muted = _muted;
_initialized = true;
Instance = this;
_instance = this;
}

protected override void ProcessAudio(ArraySegment<float> data) {
Expand All @@ -33,13 +35,24 @@ private void OnDestroy() {
RootLogic.Instance.comms.MicrophoneCapture.Unsubscribe(this);
}

private static void SetMuted(bool isMuted) {
_muted = isMuted;
if (_instance == null) return;
_instance._lipSyncContext.Muted = isMuted;
}

[HarmonyPatch]
private static class HarmonyPatches {
[HarmonyPostfix]
[HarmonyPatch(typeof(Audio), nameof(Audio.SetMicrophoneActive))]
private static void After_Audio_SetMicrophoneActive(bool muted) {
if (Instance == null) return;
Instance._lipSyncContext.Muted = muted;
SetMuted(muted);
}

[HarmonyPostfix]
[HarmonyPatch(typeof(DissonanceComms), nameof(DissonanceComms.IsMuted), MethodType.Setter)]
private static void After_DissonanceComms_IsMuted_Setter(bool value) {
SetMuted(value);
}
}
}
2 changes: 1 addition & 1 deletion BetterLipsync/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

namespace BetterLipsync.Properties;
internal static class AssemblyInfoParams {
public const string Version = "1.0.2";
public const string Version = "1.0.3";
public const string Author = "kafeijao";
}

0 comments on commit c496ebb

Please sign in to comment.