From 697886465d1ef3bb065d14a17ddf7ae7f99c5cdc Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Thu, 10 Mar 2016 16:36:31 +0000 Subject: [PATCH] Fix a bug in read_wav_file() that made it process and return too few data points when files with sample rate 11025 Hz are read. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6518 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 35529adaf..2e01e6ae5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1610,13 +1610,14 @@ void MainWindow::read_wav_file (QString const& fname) auto bytes_per_frame = file.format ().bytesPerFrame (); int n = file.read (reinterpret_cast (dec_data.d2), std::min (qint64 (bytes_per_frame * ntps), file.size ())); + int npts=n / file.format ().bytesPerFrame (); std::memset (dec_data.d2 + n, 0, bytes_per_frame * ntps - n); if (11025 == file.format ().sampleRate ()) { auto sample_size = static_cast (file.format ().sampleSize ()); - wav12_ (dec_data.d2, dec_data.d2, &n, &sample_size); + wav12_ (dec_data.d2, dec_data.d2, &npts, &sample_size); } - dec_data.params.kin = n / file.format ().bytesPerFrame (); + dec_data.params.kin = npts; dec_data.params.newdat = 1; }); m_wav_future_watcher.setFuture(m_wav_future); // call diskDat() when done