Skip to content

Commit

Permalink
Make tuner show full semitone up/down. Revert to .NET 6 for VST3 plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeoliphant committed Jul 23, 2024
1 parent 762e265 commit 7d2406f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions StompboxHost/StompboxHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<TrimmerRootAssembly Include="Microsoft.Xna.Framework.Content.ContentTypeReader" Visible="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AudioPlugSharp" Version="0.6.1" />
<PackageReference Include="AudioPlugSharpHost" Version="0.6.1" />
<PackageReference Include="AudioPlugSharp" Version="0.6.3" />
<PackageReference Include="AudioPlugSharpHost" Version="0.6.3" />
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions StompboxPlugin/StompboxPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
Expand All @@ -13,7 +13,7 @@
<ProjectReference Include="..\UnmanagedBridge\UnmanagedBridge.vcxproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AudioPlugSharp" Version="0.6.1" />
<PackageReference Include="AudioPlugSharp" Version="0.6.3" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.1.303" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
Expand Down
2 changes: 0 additions & 2 deletions StompboxPlugin/UnmanagedAudioPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public override bool Enabled
set
{
UnmanagedWrapper.SetEnabled(value);

//GuitarSimPlugin.Instance.SendCommand("SetParam " + ID + " Enabled " + (value ? "1" : "0"));
}
}

Expand Down
14 changes: 7 additions & 7 deletions StompboxShared/Interface/TunerInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ void UpdateTuner(double value)
tunerFrequencyDisplay.StringBuilder.AppendNumber((int)Math.Round((newPitch - (float)integer) * 10));
tunerFrequencyDisplay.StringBuilder.Append("Hz");

int cents = (int)Math.Round(1200 * Math.Log(newPitch / currentPitchCenter, 2));
double centsOffset = 1200 * Math.Log(newPitch / currentPitchCenter, 2);

tunerCentsDisplay.StringBuilder.Clear();

if (cents != 0)
tunerCentsDisplay.StringBuilder.Append((cents > 0) ? "+" : "-");
if (centsOffset != 0)
tunerCentsDisplay.StringBuilder.Append((centsOffset > 0) ? "+" : "-");

tunerCentsDisplay.StringBuilder.AppendNumber(Math.Abs(cents));
tunerCentsDisplay.StringBuilder.AppendNumber(Math.Abs((int)Math.Round(centsOffset)));
}

if (lastClosestNote != (int)closestNote.Note)
Expand All @@ -291,16 +291,16 @@ void UpdateTuner(double value)

double offset = (step / 2);

double range = .03 / (currentPitchCenter / 83.0); // Set range based on pitch (smaller range for higher frequencies)

int lastX = -1;
int lastY = -1;

foreach (double pitch in pitchHistory)
{
if (pitch > 0)
{
double y = ((double)tunerImageHeight / 2) + (((1.0 - (pitch / currentPitchCenter)) / range) * ((double)tunerImageHeight / 2));
double centsOffset = 1200 * Math.Log(pitch / currentPitchCenter, 2);

double y = ((double)tunerImageHeight / 2) + ((-centsOffset / 100) * (double)tunerImageHeight);

double xOffset = offset;
double yOffset = y;
Expand Down

0 comments on commit 7d2406f

Please sign in to comment.