Commits

shuerhaaken committed 0e4ab45

extend tests for BPM tag access

Comments (0)

Files changed (15)

libtaginfo/apetaginfo.cc

                     taglib_apetag->addValue(APE_TAG_DISK, format("%u/%u", volume_number, volume_count), true);
                 }
             }
-            if(!(changedflag & CHANGED_BPM_TAG)) {
-                taglib_apetag->addValue(APE_TAG_BPM, format("%u", beats_per_minute), true);
+            if(changedflag & CHANGED_BPM_TAG) {
+                taglib_apetag->addValue(APE_TAG_BPM, format("%d", beats_per_minute), true);
             }
             if(changedflag & CHANGED_DATA_VOL_CNT) {
                 // prevent overwrite in save_base_tags()

libtaginfo/asfinfo.cc

             if(asf_tag->attributeListMap().contains(ORIGINAL_ARTIST)) {
                 original_artist = asf_tag->attributeListMap()[ ORIGINAL_ARTIST ].front().toString();
             }
-            if(asf_tag->attributeListMap().contains(TOTAL_TRACKS)) {// seems not to be official
-                track_count = 
-                    atol(asf_tag->attributeListMap()[ TOTAL_TRACKS ].front().toString().toCString(false));
+            if(asf_tag->attributeListMap().contains(TOTAL_TRACKS)) {
+                track_count = (int) asf_tag->attributeListMap()[ TOTAL_TRACKS ].front().toUInt();
             }
             if(asf_tag->attributeListMap().contains(BPM_TAG)) {
                 beats_per_minute = 
-                    atol(asf_tag->attributeListMap()[ BPM_TAG ].front().toString().toCString(false));
+                    (int)asf_tag->attributeListMap()[ BPM_TAG ].front().toUInt();
             }
             if(asf_tag->attributeListMap().contains(COPYRIGHT)) {
                 copyright = asf_tag->attributeListMap()[ COPYRIGHT ].front().toString();
             if(asf_tag->attributeListMap().contains(ALBUM_ARTIST)) {
                 album_artist = asf_tag->attributeListMap()[ ALBUM_ARTIST ].front().toString();
             }
-            long rat = 0;
+            int rat = 0;
             if(asf_tag->attributeListMap().contains(SHARED_RATING)) {
-                rat = atol(asf_tag->attributeListMap()[ SHARED_RATING ].front().toString().toCString(false));
+                rat = (int)asf_tag->attributeListMap()[ SHARED_RATING ].front().toUInt();
             }
             if(!rat && asf_tag->attributeListMap().contains("Rating")) {
-                rat = atol(asf_tag->attributeListMap()[ "Rating" ].front().toString().toCString(false));
+                rat = (int)asf_tag->attributeListMap()[ "Rating" ].front().toUInt();
             }
             if(rat) {
                 if(rat > 5)
             }
             if(changedflag & CHANGED_TRACK_COUNT) {
                 asf_tag->removeItem(TOTAL_TRACKS);
-                asf_tag->setAttribute(TOTAL_TRACKS, format("%d", track_count));
+                asf_tag->setAttribute(TOTAL_TRACKS, (uint)track_count);
             }
             if(changedflag & CHANGED_COMPOSER_TAG) {
                 asf_tag->removeItem(COMPOSER);
             if(changedflag & CHANGED_DATA_RATING) {
                 asf_tag->removeItem(SHARED_RATING);
                 int WMRatings[] = { 0, 0, 1, 25, 50, 75, 99 };
-                asf_tag->setAttribute(SHARED_RATING, format("%i", WMRatings[ rating + 1 ]));
+                asf_tag->setAttribute(SHARED_RATING, (uint)WMRatings[ rating + 1 ]);
+            }
+            if(changedflag & CHANGED_BPM_TAG) {
+                asf_tag->setAttribute(BPM_TAG, (uint)beats_per_minute);
             }
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)

libtaginfo/mp4info.cc

             }
             // Rating
             if(mp4_tag->itemListMap().contains(RATING)) {
-                long rat = 0;
-                rat = atol(mp4_tag->itemListMap()[RATING].toStringList().front().toCString(true));
+                int rat = 0;
+                rat = atol(mp4_tag->itemListMap()[RATING].toStringList().front().toCString(false));
                 if(rat) {
                     if(rat > 5) {
                         rating = popularity_to_rating(rat);
                 }
             }
             if(mp4_tag->itemListMap().contains(BPM_TAG)) {
-                beats_per_minute = atol(mp4_tag->itemListMap()[BPM_TAG].toStringList().front().toCString(true));
+                beats_per_minute = mp4_tag->itemListMap()[BPM_TAG].toInt();
             }
             if(mp4_tag->itemListMap().contains(PLAYCOUNT)) {
-                playcount = atol(mp4_tag->itemListMap()[PLAYCOUNT].toStringList().front().toCString(true));
+                playcount = mp4_tag->itemListMap()[PLAYCOUNT].toInt(); //atol(mp4_tag->itemListMap()[PLAYCOUNT].toStringList().front().toCString(false));
             }
             // Labels
             if(track_labels.size() == 0) {
             if(changedflag & CHANGED_IS_COMPILATION_TAG)
                 mp4_tag->itemListMap()[COMPILATION] = MP4::Item(is_compilation);
             if(changedflag & CHANGED_DATA_RATING) {
-                mp4_tag->itemListMap()[RATING ] =
-                    MP4::Item(format("%u", rating_to_popularity(rating)));
-                
+                mp4_tag->itemListMap().insert(RATING, MP4::Item(format("%d", rating_to_popularity(rating))));
             }
             if(changedflag & CHANGED_DATA_PLAYCOUNT) {
-                mp4_tag->itemListMap()[ PLAYCOUNT ] =
-                    MP4::Item(format("%u", playcount));
+                mp4_tag->itemListMap().insert(PLAYCOUNT, MP4::Item(playcount));
             }
             if(changedflag & CHANGED_BPM_TAG) {
-                mp4_tag->itemListMap()[ BPM_TAG ] =
-                    MP4::Item(format("%u", beats_per_minute));
+                mp4_tag->itemListMap().insert(BPM_TAG, MP4::Item(beats_per_minute));
             }
             // The Labels
             if(changedflag & CHANGED_ARTIST_LABELS)

libtaginfo/taginfo_internal.h

 }
 
 
-inline int popularity_to_rating(const int rating) {
-    if(rating <= 0)
+inline int popularity_to_rating(const int popularity) {
+    if(popularity <= 0)
         return 0;
-    if(rating < 64)
+    if(popularity < 64)
         return 1;
-    if(rating < 128)
+    if(popularity < 128)
         return 2;
-    if(rating < 192)
+    if(popularity < 192)
         return 3;
-    if(rating < 255)
+    if(popularity < 255)
         return 4;
     return 5;
 }

tests/ctest_write/main.c

     
     taginfo_info_set_album(info, TESTTITLE " älbum");
     taginfo_info_set_albumartist(info, TESTTITLE "äé");
+    taginfo_info_set_beats_per_minute(info, 180);
     taginfo_info_set_artist(info, TESTTITLE "artist");
     taginfo_info_set_comment(info, TESTTITLE " comment");
     taginfo_info_set_composer(info, TESTTITLE " composer");
            taginfo_info_get_is_compilation(info) &&
            strcmp(taginfo_info_get_original_artist (info), (TESTTITLE " org artist")) == 0 &&
            taginfo_info_get_playcount(info) == 102 &&
+           taginfo_info_get_beats_per_minute(info) == 180 &&
            taginfo_info_get_rating(info) == 5 &&
            strcmp(taginfo_info_get_title(info), (TESTTITLE)) == 0 &&
            taginfo_info_get_track_count(info) == 4 &&

tests/write_aif/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_ape/main.cc

     std::string val = TESTDIR "samples/sample.ape";
     
     //std::cout << std::endl << "val: " << val << std::endl;
-    std::string target = "/tmp/out_01.ape";
+    std::string target = "/tmp/out_07.ape";
     
     std::ifstream  src(val.c_str());
     std::ofstream  dst(target.c_str());
         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
     }
     delete info;
     info = NULL;
-    
     info = Info::create(target);
     if( info ) {
         if(info->load()) {
+//        cout << "info->get_beats_per_minute() " << info->get_beats_per_minute() << endl;
             if(info->get_artist() == "artißt" &&
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_flac/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_m4a/main.cc

     Info * info;
     std::string val = TESTDIR "samples/sample.m4a";
     //std::cout << std::endl << "val: " << val << std::endl;
-    
     std::string target("/tmp/out_23.m4a");
     
     std::ifstream  src(val.c_str());
         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_year(1982);
+        info->set_rating(3);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
     }
     delete info;
     info = NULL;
-    
     info = Info::create(target);
     if( info ) {
         if( info->load() ) {
             //std::cout << "info->get_track_number() : " << info->get_track_number() << std::endl;
             //std::cout << "info->get_track_count() : " << info->get_track_count() << std::endl;
-            //std::cout << "info->get_homepage() : " << info->get_homepage() << std::endl;
+            //std::cout << "info->get_beats_per_minute() : " << info->get_beats_per_minute() << std::endl;
             if(info->get_artist() == "artißt" &&
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_homepage() == "ööö" &&
                info->get_encoder() == "encödr" &&
                info->get_track_number() == 2 &&
+               info->get_rating() == 3 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_track_count() == 5 &&
                info->get_volume_number() == 1 &&
                info->get_volume_count() == 3 &&

tests/write_mod/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");

tests/write_mp3/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_mpc/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_ogg/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_tta/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&

tests/write_wma/main.cc

         info->set_genre("gen re");
         info->set_composer("cömpozér");
         info->set_year(1982);
-        info->set_rating(0);
+        info->set_rating(2);
+        info->set_beats_per_minute(180);
         info->set_title("titlöe");
         info->set_original_artist ("ürgar t");
         info->set_homepage("ööö");
                info->get_genre() == "gen re" &&
                info->get_composer() == "cömpozér" &&
                info->get_year() == 1982 &&
+               info->get_rating() == 2 &&
+               info->get_beats_per_minute() == 180 &&
                info->get_title() == "titlöe" &&
                info->get_original_artist () == "ürgar t" &&
                info->get_homepage() == "ööö" &&
                info->get_encoder() == "encödr" &&
                info->get_track_number() == 2 &&
-                info->get_track_count() == 5 && // not supported !
+               info->get_track_count() == 5 && 
                info->get_volume_number() == 1 &&
                info->get_volume_count() == 3 &&
                info->get_copyright() == "Cöpppyright" &&
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.