Skip to content

Commit c7cb5af

Browse files
committed
replace SetColormap() with a public property
1 parent 562f76e commit c7cb5af

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/Spectrogram.MicrophoneDemo/FormMicrophone.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private void timer1_Tick(object sender, EventArgs e)
105105

106106
private void cbColormap_SelectedIndexChanged(object sender, EventArgs e)
107107
{
108-
spec.SetColormap(cmaps[cbColormap.SelectedIndex]);
108+
spec.Colormap = cmaps[cbColormap.SelectedIndex];
109109
}
110110

111111
private void btnResetRoll_Click(object sender, EventArgs e)

src/Spectrogram.Tests/ColormapExamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Test_Make_CommonColormaps()
2121

2222
foreach (var cmap in Colormap.GetColormaps())
2323
{
24-
spec.SetColormap(cmap);
24+
spec.Colormap = cmap;
2525
spec.SaveImage($"../../../../../dev/graphics/hal-{cmap.Name}.png");
2626
Debug.WriteLine($"![](dev/graphics/hal-{cmap.Name}.png)");
2727
}

src/Spectrogram/SpectrogramGenerator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public class SpectrogramGenerator
7979
private readonly List<double[]> ffts = new List<double[]>();
8080
private readonly List<double> newAudio;
8181
private Colormap cmap = Colormap.Viridis;
82+
/// <summary>
83+
/// Colormap to use when generating future FFTs.
84+
/// </summary>
85+
public Colormap Colormap = Colormap.Viridis;
8286

8387
/// <summary>
8488
/// Instantiate a spectrogram generator.
@@ -129,12 +133,13 @@ public override string ToString()
129133
$"overlap: {settings.StepOverlapFrac * 100:N0}%";
130134
}
131135

136+
[Obsolete("Assign to the Colormap field")]
132137
/// <summary>
133138
/// Set the colormap to use for future renders
134139
/// </summary>
135140
public void SetColormap(Colormap cmap)
136141
{
137-
this.cmap = cmap ?? this.cmap;
142+
Colormap = cmap ?? this.Colormap;
138143
}
139144

140145
/// <summary>

0 commit comments

Comments
 (0)