From ab3a7a871fbfeae9a8685ad6675f44b2b01c81ec Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 7 Jul 2020 23:32:33 +0900 Subject: [PATCH 1/2] Update framework --- .../Visual/Input/TestSceneMicrophone.cs | 2 +- osu.Framework.Microphone/osu.Framework.Microphone.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/osu.Framework.Microphone.csproj b/osu.Framework.Microphone/osu.Framework.Microphone.csproj index e591d5d..f05a9d9 100644 --- a/osu.Framework.Microphone/osu.Framework.Microphone.csproj +++ b/osu.Framework.Microphone/osu.Framework.Microphone.csproj @@ -24,7 +24,7 @@ - + From 6ae97394b0b0b6692d86f1324408e0b6cd7f7900 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Thu, 9 Jul 2020 22:16:31 +0900 Subject: [PATCH 2/2] Update some code. --- .../Microphone/OsuTKMicrophoneHandler.cs | 2 +- .../Input/States/MicrophoneInputState.cs | 18 +++++++++++++++++- .../Input/States/MicrophoneState.cs | 15 +++++---------- .../osu.Framework.Microphone.csproj | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) 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 f05a9d9..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