Skip to content

Commit 8249be0

Browse files
committed
additional SFF test #20
1 parent f2c1eb9 commit 8249be0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Spectrogram.Tests/FileFormat.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,32 @@ public void Test_SFF_Mel()
5050
Assert.AreEqual(spec.Height, spec2.Height);
5151
Assert.AreEqual(spec.OffsetHz, spec2.OffsetHz);
5252
}
53+
54+
[Test]
55+
public void Test_SFF_Linear2()
56+
{
57+
// test creating SFF file from 16-bit 48kHz mono WAV file
58+
59+
// read the wav file
60+
(int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/03-02-03-01-02-01-19.wav");
61+
Assert.AreEqual(48000, sampleRate);
62+
63+
// save the SFF
64+
int fftSize = 1 << 12;
65+
var spec = new Spectrogram(sampleRate, fftSize, stepSize: 700, maxFreq: 2000);
66+
spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical
67+
spec.Add(audio);
68+
spec.SaveData("testDoor.sff");
69+
70+
// load the SFF and verify all the values are the same
71+
var spec2 = new SFF("testDoor.sff");
72+
Assert.AreEqual(spec.SampleRate, spec2.SampleRate);
73+
Assert.AreEqual(spec.StepSize, spec2.StepSize);
74+
Assert.AreEqual(spec.Width, spec2.Width);
75+
Assert.AreEqual(spec.FftSize, spec2.FftSize);
76+
Assert.AreEqual(spec.NextColumnIndex, spec2.FftFirstIndex);
77+
Assert.AreEqual(spec.Height, spec2.Height);
78+
Assert.AreEqual(spec.OffsetHz, spec2.OffsetHz);
79+
}
5380
}
5481
}

0 commit comments

Comments
 (0)