Skip to content

Commit

Permalink
Merge pull request #832 from andy840119/update-microphone-package
Browse files Browse the repository at this point in the history
Update microphone package
  • Loading branch information
andy840119 authored Sep 3, 2021
2 parents 5909605 + 08f5513 commit 62c23f6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 10 additions & 8 deletions osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="LanguageDetection.karaoke-dev" Version="1.3.3-alpha" />
<PackageReference Include="Octokit" Version="0.50.0" />
<PackageReference Include="osu.Framework.KaraokeFont" Version="2021.814.0" />
<PackageReference Include="osu.Framework.Microphone" Version="2021.829.0" />
<PackageReference Include="osu.Framework.Microphone" Version="2021.904.0" />
<PackageReference Include="ppy.osu.Game" Version="2021.828.0" />
<PackageReference Include="LyricMaker" Version="1.1.1" />
<PackageReference Include="NicoKaraParser" Version="1.1.0" />
Expand Down

0 comments on commit 62c23f6

Please sign in to comment.