Skip to content

Commit

Permalink
Merge pull request #31 from andy840119/update-package
Browse files Browse the repository at this point in the history
Update framework
  • Loading branch information
andy840119 authored Jul 19, 2020
2 parents 8202a54 + 6ae9739 commit 1971401
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 17 additions & 1 deletion osu.Framework.Microphone/Input/States/MicrophoneInputState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@ namespace osu.Framework.Input.States
{
public class MicrophoneInputState : InputState, IMicrophoneInputState
{
/// <summary>
/// The microphone state.
/// </summary>
public MicrophoneState Microphone { get; }

/// <summary>
/// Creates a new <see cref="InputState"/> using the individual input states from another <see cref="InputState"/>.
/// </summary>
/// <param name="other">The <see cref="InputState"/> to take the individual input states from. Note that states are not cloned and will remain as references to the same objects.</param>
public MicrophoneInputState(MicrophoneInputState other)
: this(other.Microphone)
{
}

/// <summary>
/// Creates a new <see cref="InputState"/> using given individual input states.
/// </summary>
/// <param name="microphone">The microphone state.</param>
public MicrophoneInputState(MicrophoneState microphone)
{
Microphone = microphone;
Microphone = microphone ?? new MicrophoneState();
}
}
}
15 changes: 5 additions & 10 deletions osu.Framework.Microphone/Input/States/MicrophoneState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,16 @@ public class MicrophoneState : IEquatable<MicrophoneState>, ICloneable
/// </summary>
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();
}
}
4 changes: 2 additions & 2 deletions osu.Framework.Microphone/osu.Framework.Microphone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>1.0.7</Version>
<Version>1.0.10</Version>
<Description>Unofficial osu!framework extension for using microphon as input device.</Description>
<RepositoryType>Git</RepositoryType>
<PackageTags>osu-framework microphone andy840119</PackageTags>
Expand All @@ -24,7 +24,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="NWaves" Version="0.9.4" />
<PackageReference Include="ppy.osu.Framework" Version="2020.131.0" />
<PackageReference Include="ppy.osu.Framework" Version="2020.707.0" />
</ItemGroup>

</Project>

0 comments on commit 1971401

Please sign in to comment.