From 110c4147f6fef6f30a82dbe0b70ca1ff79903bf4 Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Tue, 5 Jan 2016 10:58:08 -0500 Subject: [PATCH] Sanity check window length and FFT length --- SyllableDetector/CircularShortTimeFourierTransform.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SyllableDetector/CircularShortTimeFourierTransform.swift b/SyllableDetector/CircularShortTimeFourierTransform.swift index 333f19a..6bbd25c 100644 --- a/SyllableDetector/CircularShortTimeFourierTransform.swift +++ b/SyllableDetector/CircularShortTimeFourierTransform.swift @@ -82,6 +82,11 @@ class CircularShortTimeFourierTransform guard v.isPowerOfTwo() else { fatalError("The FFT size must be a power of 2.") } + + guard lengthWindow <= v else { + fatalError("The FFT size must be greater than or equal to the window length.") + } + lengthFft = v fftSize = vDSP_Length(ceil(log2(CDouble(v)))) }