changeset 632:a4b8ad0f1a8f

* Some sketchy track lookup code
author Chris Cannam
date Fri, 19 Mar 2010 12:21:59 +0000
parents 3a5ee4b6c9ad
children 7feec7756b41
files data/fileio/AudioFileReader.h data/fileio/MP3FileReader.cpp data/fileio/MP3FileReader.h
diffstat 3 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/AudioFileReader.h	Mon Jul 19 17:08:56 2010 +0000
+++ b/data/fileio/AudioFileReader.h	Fri Mar 19 12:21:59 2010 +0000
@@ -21,6 +21,7 @@
 #include "FileSource.h"
 
 #include <vector>
+#include <map>
 
 typedef std::vector<float> SampleBlock;
 
@@ -60,6 +61,9 @@
      */
     virtual QString getMaker() const { return ""; }
 
+    typedef std::map<QString, QString> TagMap;
+    virtual TagMap getTags() const { return TagMap(); }
+
     /** 
      * Return interleaved samples for count frames from index start.
      * The resulting sample block will contain count *
--- a/data/fileio/MP3FileReader.cpp	Mon Jul 19 17:08:56 2010 +0000
+++ b/data/fileio/MP3FileReader.cpp	Fri Mar 19 12:21:59 2010 +0000
@@ -189,6 +189,13 @@
     m_maker = loadTag(tag, "TPE1"); // "lead artist"
     if (m_maker == "") m_maker = loadTag(tag, "TPE2");
 
+    for (unsigned int i = 0; i < tag->nframes; ++i) {
+        if (tag->frames[i]) {
+            QString value = loadTag(tag, tag->frames[i]->id);
+            if (value != "") m_tags[tag->frames[i]->id] = value;
+        }
+    }
+
     id3_file_close(file);
 
 #else
--- a/data/fileio/MP3FileReader.h	Mon Jul 19 17:08:56 2010 +0000
+++ b/data/fileio/MP3FileReader.h	Fri Mar 19 12:21:59 2010 +0000
@@ -49,6 +49,7 @@
     virtual QString getLocation() const { return m_source.getLocation(); }
     virtual QString getTitle() const { return m_title; }
     virtual QString getMaker() const { return m_maker; }
+    virtual TagMap getTags() const { return m_tags; }
     
     static void getSupportedExtensions(std::set<QString> &extensions);
     static bool supportsExtension(QString ext);
@@ -70,6 +71,7 @@
     QString m_error;
     QString m_title;
     QString m_maker;
+    TagMap m_tags;
     size_t m_fileSize;
     double m_bitrateNum;
     size_t m_bitrateDenom;