Skip to content

Commit

Permalink
Fixed vocal video and input calibration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Jan 21, 2024
1 parent 4a438fb commit b593eec
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Assets/Script/Gameplay/Player/VocalsPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected override void UpdateInputs(double time)
/// <summary>
/// Calculate if the engine considers this point in time as singing.
/// </summary>
private double GetTimeThreshold(double lastTime)
private static double GetTimeThreshold(double lastTime)
{
// Add an arbitrary value to prevent it from hiding too fast
return lastTime + 1f / IMicDevice.UPDATES_PER_SECOND + 0.05;
Expand All @@ -196,7 +196,13 @@ protected override void UpdateVisuals(double time)
// Update HUD
_hud.UpdateInfo(fill, Engine.EngineStats.ScoreMultiplier, (float) Engine.EngineStats.StarPowerAmount);

if (GameManager.SongTime >= GetTimeThreshold(Engine.State.LastSingTime))
// Get the appropriate sing time
var singTime = GameManager.InputTime - Player.Profile.InputCalibrationSeconds;

// Get whether or not the player has sang within the time threshold.
// We gotta use a threshold here because microphone inputs are passed every X seconds,
// not in a constant stream.
if (singTime >= GetTimeThreshold(Engine.State.LastSingTime))
{
// Hide the needle if there's no singing
if (_needleVisualContainer.activeSelf)
Expand All @@ -221,7 +227,7 @@ protected override void UpdateVisuals(double time)
var transformCache = transform;
float lastNotePitch = _lastTargetNote?.PitchAtSongTime(GameManager.SongTime) ?? -1f;

if (_lastTargetNote is not null && GameManager.SongTime < GetTimeThreshold(Engine.State.LastHitTime))
if (_lastTargetNote is not null && singTime < GetTimeThreshold(Engine.State.LastHitTime))
{
// Show particles if hitting
_hittingParticleGroup.Play();
Expand Down

0 comments on commit b593eec

Please sign in to comment.