Skip to content

Commit 81b30d6

Browse files
committed
Upgrade FftSharp and ScottPlot
1 parent fe9f19b commit 81b30d6

File tree

9 files changed

+19
-20
lines changed

9 files changed

+19
-20
lines changed

src/Spectrogram.MicrophoneDemo/Spectrogram.MicrophoneDemo.csproj renamed to src/Spectrogram.MicrophoneDemo/Spectrogram.Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ProjectReference Include="..\Spectrogram\Spectrogram.csproj" />
1111
</ItemGroup>
1212
<ItemGroup>
13-
<PackageReference Include="FftSharp" Version="1.0.12" />
13+
<PackageReference Include="FftSharp" Version="1.1.2" />
1414
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
1515
<PackageReference Include="NAudio" Version="1.10.0" />
1616
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />

src/Spectrogram.Tests/ColormapExamples.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public void Test_Make_CommonColormaps()
1212
(double[] audio, int sampleRate) = AudioFile.ReadWAV("../../../../../data/cant-do-that-44100.wav");
1313
int fftSize = 1 << 12;
1414
var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 700, maxFreq: 2000);
15-
spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical
15+
var window = new FftSharp.Windows.Hanning();
16+
spec.SetWindow(window.Create(fftSize / 3)); // sharper window than typical
1617
spec.Add(audio);
1718

1819
// delete old colormap files

src/Spectrogram.Tests/FileFormat.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public void Test_SFF_Linear()
1414
(double[] audio, int sampleRate) = AudioFile.ReadWAV("../../../../../data/cant-do-that-44100.wav");
1515
int fftSize = 1 << 12;
1616
var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 700, maxFreq: 2000);
17-
spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical
17+
var window = new FftSharp.Windows.Hanning();
18+
spec.SetWindow(window.Create(fftSize / 3)); // sharper window than typical
1819
spec.Add(audio);
1920
spec.SaveData("../../../../../dev/sff/hal.sff");
2021

@@ -34,7 +35,8 @@ public void Test_SFF_Mel()
3435
(double[] audio, int sampleRate) = AudioFile.ReadWAV("../../../../../data/cant-do-that-44100.wav");
3536
int fftSize = 1 << 12;
3637
var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 700);
37-
spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical
38+
var window = new FftSharp.Windows.Hanning();
39+
spec.SetWindow(window.Create(fftSize / 3)); // sharper window than typical
3840
spec.Add(audio);
3941

4042
Bitmap bmp = spec.GetBitmapMel(250);

src/Spectrogram.Tests/Mel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void Test_Mel_Graph()
4141
double[] power = ScottPlot.DataGen.RandomWalk(rand, specPoints, .02, .5);
4242

4343
var plt1 = new ScottPlot.Plot(800, 300);
44-
plt1.PlotScatter(freq, power, markerSize: 0);
44+
plt1.AddScatter(freq, power, markerSize: 0);
4545

4646
int filterSize = 25;
4747

@@ -64,7 +64,7 @@ public void Test_Mel_Graph()
6464
double freqCenter = binStartFreqs[binIndex + 1];
6565
double freqHigh = binStartFreqs[binIndex + 2];
6666

67-
var sctr = plt1.PlotScatter(
67+
var sctr = plt1.AddScatter(
6868
xs: new double[] { freqLow, freqCenter, freqHigh },
6969
ys: new double[] { 0, 1, 0 },
7070
markerSize: 0, lineWidth: 2);
@@ -84,7 +84,7 @@ public void Test_Mel_Graph()
8484
binValue += power[indexLow + i] * frac;
8585
}
8686
binValue /= binScaleSum;
87-
plt1.PlotPoint(freqCenter, binValue, sctr.color, 10);
87+
plt1.AddPoint(freqCenter, binValue, sctr.Color, 10);
8888
}
8989

9090
plt1.SaveFig("mel1.png");

src/Spectrogram.Tests/Spectrogram.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="nunit" Version="3.12.0" />
1212
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
14-
<PackageReference Include="ScottPlot" Version="4.0.48" />
14+
<PackageReference Include="ScottPlot" Version="4.1.27" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Spectrogram.Tests/TestAGC.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ private double[] SubtractMovingWindow(double[] input, int windowSizePx = 100)
7878
{
7979
// return a copy of the input array with the moving window subtracted
8080

81-
double[] window = FftSharp.Window.Hanning(windowSizePx);
81+
var hanningWindow = new FftSharp.Windows.Hanning();
82+
double[] window = hanningWindow.Create(windowSizePx);
8283
double windowSum = window.Sum();
8384

8485
double[] windowed = new double[input.Length];

src/Spectrogram.sln

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30128.74
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31815.197
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectrogram", "Spectrogram\Spectrogram.csproj", "{6FF83EDD-E18A-4EDD-8D53-D2281515AC47}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectrogram.MicrophoneDemo", "Spectrogram.MicrophoneDemo\Spectrogram.MicrophoneDemo.csproj", "{D51ABC6A-53F4-4620-88A1-14EA1D779538}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectrogram.Demo", "Spectrogram.MicrophoneDemo\Spectrogram.Demo.csproj", "{D51ABC6A-53F4-4620-88A1-14EA1D779538}"
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectrogram.Tests", "Spectrogram.Tests\Spectrogram.Tests.csproj", "{E7482801-78C7-41FD-88D1-72A7ED3EFC9D}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SffViewer", "..\dev\sff\SffViewer\SffViewer.csproj", "{9478208D-60C7-4F6A-B2E4-6325D38139DA}"
13-
EndProject
1412
Global
1513
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1614
Debug|Any CPU = Debug|Any CPU
@@ -29,10 +27,6 @@ Global
2927
{E7482801-78C7-41FD-88D1-72A7ED3EFC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
3028
{E7482801-78C7-41FD-88D1-72A7ED3EFC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
3129
{E7482801-78C7-41FD-88D1-72A7ED3EFC9D}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{9478208D-60C7-4F6A-B2E4-6325D38139DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{9478208D-60C7-4F6A-B2E4-6325D38139DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{9478208D-60C7-4F6A-B2E4-6325D38139DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{9478208D-60C7-4F6A-B2E4-6325D38139DA}.Release|Any CPU.Build.0 = Release|Any CPU
3630
EndGlobalSection
3731
GlobalSection(SolutionProperties) = preSolution
3832
HideSolutionNode = FALSE

src/Spectrogram/Settings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public Settings(int sampleRate, int fftSize, int stepSize, double minFreq, doubl
5555

5656
// horizontal
5757
StepLengthSec = (double)StepSize / sampleRate;
58-
Window = FftSharp.Window.Hanning(fftSize);
58+
var window = new FftSharp.Windows.Hanning();
59+
Window = window.Create(fftSize);
5960
StepOverlapSec = FftLengthSec - StepLengthSec;
6061
StepOverlapFrac = StepOverlapSec / FftLengthSec;
6162
}

src/Spectrogram/Spectrogram.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ItemGroup>
3030

3131
<ItemGroup>
32-
<PackageReference Include="FftSharp" Version="1.0.12" />
32+
<PackageReference Include="FftSharp" Version="1.1.2" />
3333
<PackageReference Include="System.Drawing.Common" Version="4.6.1" />
3434
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.8.64" Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'" />
3535
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">

0 commit comments

Comments
 (0)