diff --git a/sstv/decode.py b/sstv/decode.py index 8d7304b..044dc0a 100644 --- a/sstv/decode.py +++ b/sstv/decode.py @@ -38,7 +38,6 @@ class SSTVDecoder(object): """Create an SSTV decoder for decoding audio data""" def __init__(self, audio_file): - self.log_basic = True self.mode = None self._audio_file = audio_file diff --git a/test/data/220hz_sine.ogg b/test/data/220hz_sine.ogg new file mode 100644 index 0000000..da579bd Binary files /dev/null and b/test/data/220hz_sine.ogg differ diff --git a/test/test_decoder.py b/test/test_decoder.py index 7547c92..94075ec 100644 --- a/test/test_decoder.py +++ b/test/test_decoder.py @@ -26,3 +26,24 @@ class SSTVDecoderTestCase(unittest.TestCase): bins = [1, 2, 2, 2, 1] # Centre 2 surrounded by 2s should result in no change self.assertEqual(barycentric_peak_interp(bins, 2), 2) + + def test_decoder_init(self): + with open("./test/data/m1.ogg", 'rb') as fp: + with SSTVDecoder(fp) as decoder: + self.assertEqual(decoder._audio_file, fp) + self.assertEqual(decoder._sample_rate, 44100) + + def test_decoder_freq_detect(self): + with open("./test/data/220hz_sine.ogg", 'rb') as fp: + with SSTVDecoder(fp) as decoder: + # Test using all samples in sound file + freq = round(decoder._peak_fft_freq(decoder._samples)) + self.assertEqual(freq, 220, "Incorrect frequency determined by peak detector using all samples") + + # Test using 1/4 of a second of samples + freq = round(decoder._peak_fft_freq(decoder._samples[:11025])) + self.assertEqual(freq, 220, "Incorrect frequency determined by peak detector using 1/4 second samples") + + # Test using 2000 samples + freq = round(decoder._peak_fft_freq(decoder._samples[:1000])) + self.assertEqual(freq, 220, "Incorrect frequency determined by peak detector using 1000 samples")