Skip to content

Commit d8cddf0

Browse files
committed
protect ffts
1 parent 85d4a30 commit d8cddf0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Spectrogram/Spectrogram.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Spectrogram
2323
public int OffsetHz { get { return settings.OffsetHz; } set { settings.OffsetHz = value; } }
2424

2525
private readonly Settings settings;
26-
public readonly List<double[]> ffts = new List<double[]>(); // TODO: private
26+
private readonly List<double[]> ffts = new List<double[]>();
2727
private readonly List<double> newAudio = new List<double>();
2828
private Colormap cmap = Colormap.Viridis;
2929

@@ -156,6 +156,9 @@ public Bitmap GetBitmapMax(double intensity = 1, bool dB = false, bool roll = fa
156156

157157
private static Bitmap _GetBitmap(List<double[]> ffts, Colormap cmap, double intensity = 1, bool dB = false, bool roll = false, int rollOffset = 0)
158158
{
159+
if (ffts.Count == 0)
160+
throw new ArgumentException("no audio has been added to this Spectrogram");
161+
159162
int Width = ffts.Count;
160163
int Height = ffts[0].Length;
161164

@@ -323,5 +326,11 @@ public int PixelY(double frequency, int reduction = 1)
323326
int pixelRow = settings.Height / reduction - 1 - pixelsFromMinFreq;
324327
return pixelRow - 1;
325328
}
329+
330+
// provide access to the raw FFT data
331+
public List<double[]> GetFFTs()
332+
{
333+
return ffts;
334+
}
326335
}
327336
}

0 commit comments

Comments
 (0)