diff --git a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs index f532688..4801453 100644 --- a/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs +++ b/osu.Framework.Microphone.Tests/Visual/Input/TestSceneMicrophone.cs @@ -51,7 +51,7 @@ protected override bool OnMicrophoneEndSinging(MicrophoneEndPitchingEvent e) protected override bool OnMicrophoneSinging(MicrophonePitchingEvent e) { var pitch = e.CurrentState.Microphone.Pitch; - Y = (float)-(pitch - 50); + Y = -(pitch - 50); BoxText.Text = "Pitching : " + pitch; return base.OnMicrophoneSinging(e); } diff --git a/osu.Framework.Microphone/Input/Handlers/Microphone/OsuTKMicrophoneHandler.cs b/osu.Framework.Microphone/Input/Handlers/Microphone/OsuTKMicrophoneHandler.cs index 2175cbd..d859c7b 100644 --- a/osu.Framework.Microphone/Input/Handlers/Microphone/OsuTKMicrophoneHandler.cs +++ b/osu.Framework.Microphone/Input/Handlers/Microphone/OsuTKMicrophoneHandler.cs @@ -70,7 +70,7 @@ private bool procedure(int handle, IntPtr buffer, int length, IntPtr user) var loudness = Perceptual.Loudness(spectrum); // Send new event - onPitchDetected(new MicrophoneState(pitch, loudness)); + onPitchDetected(new MicrophoneState { Pitch = pitch, Loudness = loudness }); return true; } diff --git a/osu.Framework.Microphone/Input/States/MicrophoneInputState.cs b/osu.Framework.Microphone/Input/States/MicrophoneInputState.cs index 777cd8c..7a476a8 100644 --- a/osu.Framework.Microphone/Input/States/MicrophoneInputState.cs +++ b/osu.Framework.Microphone/Input/States/MicrophoneInputState.cs @@ -5,11 +5,27 @@ namespace osu.Framework.Input.States { public class MicrophoneInputState : InputState, IMicrophoneInputState { + /// + /// The microphone state. + /// public MicrophoneState Microphone { get; } + /// + /// Creates a new using the individual input states from another . + /// + /// The to take the individual input states from. Note that states are not cloned and will remain as references to the same objects. + public MicrophoneInputState(MicrophoneInputState other) + : this(other.Microphone) + { + } + + /// + /// Creates a new using given individual input states. + /// + /// The microphone state. public MicrophoneInputState(MicrophoneState microphone) { - Microphone = microphone; + Microphone = microphone ?? new MicrophoneState(); } } } diff --git a/osu.Framework.Microphone/Input/States/MicrophoneState.cs b/osu.Framework.Microphone/Input/States/MicrophoneState.cs index 32570c1..b96502d 100644 --- a/osu.Framework.Microphone/Input/States/MicrophoneState.cs +++ b/osu.Framework.Microphone/Input/States/MicrophoneState.cs @@ -22,21 +22,16 @@ public class MicrophoneState : IEquatable, ICloneable /// public bool HasSound => Pitch != 0; - public MicrophoneState() + public bool Equals(MicrophoneState other) { + return Pitch == other.Pitch && Loudness == other.Loudness; } - public MicrophoneState(float pitch, float loudness) - { - Pitch = pitch; - Loudness = loudness; - } + public object Clone() => HasSound ? new MicrophoneState { Pitch = Pitch, Loudness = Loudness } : new MicrophoneState(); - public bool Equals(MicrophoneState other) + public override string ToString() { - return Pitch == other.Pitch && Loudness == other.Loudness; + return $@"Pitch: {Pitch}, Loudness: {Loudness}"; } - - public object Clone() => HasSound ? new MicrophoneState(Pitch, Loudness) : new MicrophoneState(); } } diff --git a/osu.Framework.Microphone/osu.Framework.Microphone.csproj b/osu.Framework.Microphone/osu.Framework.Microphone.csproj index e591d5d..0931d51 100644 --- a/osu.Framework.Microphone/osu.Framework.Microphone.csproj +++ b/osu.Framework.Microphone/osu.Framework.Microphone.csproj @@ -11,7 +11,7 @@ true true false - 1.0.7 + 1.0.10 Unofficial osu!framework extension for using microphon as input device. Git osu-framework microphone andy840119 @@ -24,7 +24,7 @@ - +