diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/NavigateCaretPositionAlgorithm.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/NavigateCaretPositionAlgorithm.cs
index 9bff2b608..9baed75d1 100644
--- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/NavigateCaretPositionAlgorithm.cs
+++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/NavigateCaretPositionAlgorithm.cs
@@ -65,9 +65,6 @@ public override NavigateCaretPosition MoveToLast()
return new NavigateCaretPosition(lyric);
}
- public override NavigateCaretPosition MoveToTarget(Lyric lyric)
- {
- return new NavigateCaretPosition(lyric);
- }
+ public override NavigateCaretPosition MoveToTarget(Lyric lyric) => new(lyric);
}
}
diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/TypingCaretPositionAlgorithm.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/TypingCaretPositionAlgorithm.cs
index 6ce0efd10..4d1efc81a 100644
--- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/TypingCaretPositionAlgorithm.cs
+++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/CaretPosition/Algorithms/TypingCaretPositionAlgorithm.cs
@@ -84,10 +84,7 @@ public override TextCaretPosition MoveToLast()
return new TextCaretPosition(lyric, GetMaxIndex(lyric.Text));
}
- public override TextCaretPosition MoveToTarget(Lyric lyric)
- {
- return new TextCaretPosition(lyric, GetMinIndex(lyric.Text));
- }
+ public override TextCaretPosition MoveToTarget(Lyric lyric) => new(lyric, GetMinIndex(lyric.Text));
private bool lyricMovable(Lyric lyric)
{
diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/MicrophoneSoundVisualizer.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/MicrophoneSoundVisualizer.cs
index e90613155..a57904655 100644
--- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/MicrophoneSoundVisualizer.cs
+++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterface/MicrophoneSoundVisualizer.cs
@@ -147,8 +147,9 @@ protected virtual bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e)
protected virtual bool OnMicrophoneSinging(MicrophonePitchingEvent e)
{
- var loudness = e.CurrentState.Microphone.Loudness;
- var pitch = e.CurrentState.Microphone.Pitch;
+ var voice = e.CurrentState.Microphone.Voice;
+ var loudness = voice.Loudness;
+ var pitch = voice.Pitch;
// todo : should convert to better value.
loudnessVisualizer.Loudness = loudness;
diff --git a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs
index 07a8ac1fe..624b35313 100644
--- a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs
+++ b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs
@@ -102,18 +102,20 @@ public override void HandleInputStateChange(InputStateChangeEvent inputStateChan
KeyBindingContainer.TriggerPressed(action);
}
}
- else if (inputStateChange is MicrophoneSoundChangeEvent microphoneSoundChange)
+ else if (inputStateChange is MicrophoneVoiceChangeEvent microphoneSoundChange)
{
// Deal with realtime microphone event
- var inputState = microphoneSoundChange.State as IMicrophoneInputState;
- var lastState = microphoneSoundChange.LastState;
- var state = inputState?.Microphone;
+ if (!(microphoneSoundChange.State is IMicrophoneInputState inputState))
+ throw new NotMicrophoneInputStateException();
- if (state == null)
- throw new ArgumentNullException($"{nameof(state)} cannot be null.");
+ var lastVoice = microphoneSoundChange.LastVoice;
+ var voice = inputState.Microphone.Voice;
+
+ if (voice == null)
+ throw new ArgumentNullException($"{nameof(voice)} cannot be null.");
// Convert beatmap's pitch to scale setting.
- var scale = beatmap.PitchToScale(state.HasSound ? state.Pitch : lastState.Pitch);
+ var scale = beatmap.PitchToScale(voice.HasVoice ? voice.Pitch : lastVoice.Pitch);
// TODO : adjust scale by
scale += 5;
@@ -123,7 +125,7 @@ public override void HandleInputStateChange(InputStateChangeEvent inputStateChan
Scale = scale
};
- if (lastState.HasSound && !state.HasSound)
+ if (lastVoice.HasVoice && !voice.HasVoice)
KeyBindingContainer.TriggerReleased(action);
else
KeyBindingContainer.TriggerPressed(action);
diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
index 22ac8c304..4833aa498 100644
--- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
+++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
@@ -11,7 +11,7 @@
-
+