diff --git a/inputsource.cpp b/inputsource.cpp index d92b332..24500e3 100644 --- a/inputsource.cpp +++ b/inputsource.cpp @@ -29,8 +29,11 @@ InputSource::~InputSource() { fclose(m_file); } -bool InputSource::getSamples(fftwf_complex *dest, int start, int length) +bool InputSource::getSamples(fftwf_complex *dest, off_t start, int length) { + if(start < 0 || length < 0) + return false; + if (start + length >= sampleCount) return false; diff --git a/inputsource.h b/inputsource.h index 1118d10..34eb49e 100644 --- a/inputsource.h +++ b/inputsource.h @@ -16,6 +16,6 @@ public: InputSource(const char *filename); ~InputSource(); - bool getSamples(fftwf_complex *dest, int start, int length); + bool getSamples(fftwf_complex *dest, off_t start, int length); off_t getSampleCount() { return sampleCount; }; }; diff --git a/spectrogram.cpp b/spectrogram.cpp index 6d544f0..d4c5f10 100644 --- a/spectrogram.cpp +++ b/spectrogram.cpp @@ -61,7 +61,7 @@ void Spectrogram::paintEvent(QPaintEvent *event) if (inputSource != nullptr) { int height = rect.height(); - int y = rect.y(); + off_t y = rect.y(); QImage image(fftSize, height, QImage::Format_RGB32); @@ -216,7 +216,7 @@ int Spectrogram::getStride() return fftSize / pow(2, zoomLevel); } -off_t Spectrogram::lineToSample(int line) { +off_t Spectrogram::lineToSample(off_t line) { return line * getStride(); } diff --git a/spectrogram.h b/spectrogram.h index f49d835..6a2a17e 100644 --- a/spectrogram.h +++ b/spectrogram.h @@ -55,7 +55,7 @@ private: float* getFFTTile(off_t tile); void getLine(float *dest, off_t sample); void paintTimeAxis(QPainter *painter, QRect rect); - off_t lineToSample(int line); + off_t lineToSample(off_t line); int sampleToLine(off_t sample); QString sampleToTime(off_t sample); int linesPerTile();