changeset 1010:36f79bc5c3d7

Provide access to local filename
author Chris Cannam
date Fri, 14 Nov 2014 17:23:38 +0000
parents e369dd281cf2
children dbb7f0ab011e 6370575a812c 13f53ecc8bb5
files data/fileio/AudioFileReader.h data/fileio/CodedAudioFileReader.h data/fileio/WavFileReader.h data/model/AlignmentModel.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h
diffstat 6 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/AudioFileReader.h	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/fileio/AudioFileReader.h	Fri Nov 14 17:23:38 2014 +0000
@@ -62,6 +62,16 @@
      */
     virtual QString getMaker() const { return ""; }
 
+    /**
+     * Return the local file path of the audio data. This is the
+     * location most likely to contain readable audio data: it may be
+     * in a different place or format from the originally specified
+     * location, for example if the file has been retrieved and
+     * decoded. In some cases there may be no local file path, and
+     * this will return "" if there is none.
+     */
+    virtual QString getLocalFilename() const { return ""; }
+    
     typedef std::map<QString, QString> TagMap;
     virtual TagMap getTags() const { return TagMap(); }
 
--- a/data/fileio/CodedAudioFileReader.h	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/fileio/CodedAudioFileReader.h	Fri Nov 14 17:23:38 2014 +0000
@@ -43,6 +43,8 @@
 
     virtual int getNativeRate() const { return m_fileRate; }
 
+    virtual QString getLocalFilename() const { return m_cacheFileName; }
+    
     /// Intermediate cache means all CodedAudioFileReaders are quickly seekable
     virtual bool isQuicklySeekable() const { return true; }
 
--- a/data/fileio/WavFileReader.h	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/fileio/WavFileReader.h	Fri Nov 14 17:23:38 2014 +0000
@@ -42,6 +42,8 @@
     virtual QString getLocation() const { return m_source.getLocation(); }
     virtual QString getError() const { return m_error; }
 
+    virtual QString getLocalFilename() const { return m_path; }
+    
     virtual bool isQuicklySeekable() const { return m_seekable; }
     
     /** 
--- a/data/model/AlignmentModel.h	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/model/AlignmentModel.h	Fri Nov 14 17:23:38 2014 +0000
@@ -32,7 +32,7 @@
 public:
     AlignmentModel(Model *reference,
                    Model *aligned,
-                   Model *inputModel, // probably an AggregateWaveModel; I take ownership
+                   Model *inputModel, // probably an AggregateWaveModel; may be null; I take ownership
                    SparseTimeValueModel *path); // I take ownership
     ~AlignmentModel();
 
--- a/data/model/WaveFileModel.cpp	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/model/WaveFileModel.cpp	Fri Nov 14 17:23:38 2014 +0000
@@ -183,6 +183,13 @@
     if (m_reader) return m_reader->getLocation();
     return "";
 }
+
+QString
+WaveFileModel::getLocalFilename() const
+{
+    if (m_reader) return m_reader->getLocalFilename();
+    return "";
+}
     
 int
 WaveFileModel::getData(int channel, int start, int count,
--- a/data/model/WaveFileModel.h	Fri Nov 14 17:23:27 2014 +0000
+++ b/data/model/WaveFileModel.h	Fri Nov 14 17:23:38 2014 +0000
@@ -52,6 +52,8 @@
     QString getMaker() const;
     QString getLocation() const;
 
+    QString getLocalFilename() const;
+
     virtual Model *clone() const;
 
     float getValueMinimum() const { return -1.0f; }