changeset 157:c03ec31005e1

* Add zoom thumbwheels to Pane. Implement horizontal thumbwheel, and vertical depending on layer type (supported for waveform and spectrogram, though wrong for log-scale spectrogram at the moment). * Add bare bones of a spectrum layer. * Add window icon * Add shortcut for "insert time instant" on laptops without keypad enter (";") * Delete FFT processing thread when it exits (at least, next time we're asked for something interesting) * Get audio file extensions from the file readers, and thus from libsndfile for the wave file reader -- leads to rather a wide combo box in file dialog though * Better refresh order for spectrogram (redraw centre section first)
author Chris Cannam
date Fri, 04 Aug 2006 17:01:37 +0000
parents 059b0322009c
children 74abef65711b
files data/fft/FFTDataServer.cpp data/fileio/AudioFileReaderFactory.cpp data/fileio/MP3FileReader.cpp data/fileio/MP3FileReader.h data/fileio/OggVorbisFileReader.cpp data/fileio/OggVorbisFileReader.h data/fileio/WavFileReader.cpp data/fileio/WavFileReader.h
diffstat 8 files changed, 67 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.cpp	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fft/FFTDataServer.cpp	Fri Aug 04 17:01:37 2006 +0000
@@ -359,8 +359,6 @@
     }
 
     m_fillThread = new FillThread(*this, fillFromColumn);
-
-    //!!! respond appropriately when thread exits (deleteProcessingData etc)
 }
 
 FFTDataServer::~FFTDataServer()
@@ -427,7 +425,15 @@
     std::cerr << "FFTDataServer(" << this << "): resume" << std::endl;
 #endif
     m_suspended = false;
-    m_condition.wakeAll();
+    if (m_fillThread) {
+        if (m_fillThread->isFinished()) {
+            delete m_fillThread;
+            m_fillThread = 0;
+            deleteProcessingData();
+        } else {
+            m_condition.wakeAll();
+        }
+    }
 }
 
 FFTCache *
--- a/data/fileio/AudioFileReaderFactory.cpp	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/AudioFileReaderFactory.cpp	Fri Aug 04 17:01:37 2006 +0000
@@ -24,17 +24,26 @@
 QString
 AudioFileReaderFactory::getKnownExtensions()
 {
-    return
-	"*.wav *.aiff *.aif"
+    std::set<QString> extensions;
+
+    WavFileReader::getSupportedExtensions(extensions);
 #ifdef HAVE_MAD
-	" *.mp3"
+    MP3FileReader::getSupportedExtensions(extensions);
 #endif
 #ifdef HAVE_OGGZ
 #ifdef HAVE_FISHSOUND
-	" *.ogg"
+    OggVorbisFileReader::getSupportedExtensions(extensions);
 #endif
 #endif
-	;
+
+    QString rv;
+    for (std::set<QString>::const_iterator i = extensions.begin();
+         i != extensions.end(); ++i) {
+        if (i != extensions.begin()) rv += " ";
+        rv += "*." + *i;
+    }
+
+    return rv;
 }
 
 AudioFileReader *
--- a/data/fileio/MP3FileReader.cpp	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/MP3FileReader.cpp	Fri Aug 04 17:01:37 2006 +0000
@@ -224,4 +224,10 @@
     return MAD_FLOW_CONTINUE;
 }
 
+void
+MP3FileReader::getSupportedExtensions(std::set<QString> &extensions)
+{
+    extensions.insert("mp3");
+}
+
 #endif
--- a/data/fileio/MP3FileReader.h	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/MP3FileReader.h	Fri Aug 04 17:01:37 2006 +0000
@@ -22,6 +22,8 @@
 
 #include <mad.h>
 
+#include <set>
+
 class QProgressDialog;
 
 class MP3FileReader : public CodedAudioFileReader
@@ -31,6 +33,8 @@
     virtual ~MP3FileReader();
 
     virtual QString getError() const { return m_error; }
+
+    static void getSupportedExtensions(std::set<QString> &extensions);
     
 protected:
     QString m_path;
--- a/data/fileio/OggVorbisFileReader.cpp	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/OggVorbisFileReader.cpp	Fri Aug 04 17:01:37 2006 +0000
@@ -155,5 +155,11 @@
     return 0;
 }
 
+void
+OggVorbisFileReader::getSupportedExtensions(std::set<QString> &extensions)
+{
+    extensions.insert("ogg");
+}
+
 #endif
 #endif
--- a/data/fileio/OggVorbisFileReader.h	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/OggVorbisFileReader.h	Fri Aug 04 17:01:37 2006 +0000
@@ -24,6 +24,8 @@
 #include <oggz/oggz.h>
 #include <fishsound/fishsound.h>
 
+#include <set>
+
 class QProgressDialog;
 
 class OggVorbisFileReader : public CodedAudioFileReader
@@ -34,6 +36,8 @@
 
     virtual QString getError() const { return m_error; }
 
+    static void getSupportedExtensions(std::set<QString> &extensions);
+
 protected:
     QString m_path;
     QString m_error;
--- a/data/fileio/WavFileReader.cpp	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/WavFileReader.cpp	Fri Aug 04 17:01:37 2006 +0000
@@ -110,3 +110,23 @@
     return;
 }
 
+void
+WavFileReader::getSupportedExtensions(std::set<QString> &extensions)
+{
+    int count;
+
+    if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) {
+        extensions.insert("wav");
+        extensions.insert("aiff");
+        extensions.insert("aif");
+        return;
+    }
+
+    SF_FORMAT_INFO info;
+    for (int i = 0; i < count; ++i) {
+        info.format = i;
+        if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) {
+            extensions.insert(info.extension);
+        }
+    }
+}
--- a/data/fileio/WavFileReader.h	Thu Aug 03 16:04:00 2006 +0000
+++ b/data/fileio/WavFileReader.h	Fri Aug 04 17:01:37 2006 +0000
@@ -21,6 +21,8 @@
 #include <sndfile.h>
 #include <QMutex>
 
+#include <set>
+
 class WavFileReader : public AudioFileReader
 {
 public:
@@ -36,6 +38,8 @@
     virtual void getInterleavedFrames(size_t start, size_t count,
 				      SampleBlock &frames) const;
     
+    static void getSupportedExtensions(std::set<QString> &extensions);
+
 protected:
     SF_INFO m_fileInfo;
     SNDFILE *m_file;