changeset 1698:314cb383b807

Automated merge with file:/home/ccr/audacious/plugins
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 09 Sep 2007 23:52:19 +0300
parents f35f9d6fcb6d (diff) 7398400de204 (current diff)
children 11135fc0e183
files
diffstat 30 files changed, 372 insertions(+), 401 deletions(-) [+]
line wrap: on
line diff
--- a/src/aac/src/libmp4.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/aac/src/libmp4.c	Sun Sep 09 23:52:19 2007 +0300
@@ -329,11 +329,11 @@
     {
         g_free(mp4cb);
 
-        tuple_associate_string(ti, "title", vfs_get_metadata(mp4fh, "track-name"));
-        tuple_associate_string(ti, "album", vfs_get_metadata(mp4fh, "stream-name"));
+        tuple_associate_string(ti, FIELD_TITLE, NULL, vfs_get_metadata(mp4fh, "track-name"));
+        tuple_associate_string(ti, FIELD_ALBUM, NULL, vfs_get_metadata(mp4fh, "stream-name"));
 
-        tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
-        tuple_associate_string(ti, "quality", "lossy");
+        tuple_associate_string(ti, FIELD_CODEC, NULL, "Advanced Audio Coding (AAC)");
+        tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
         vfs_fclose(mp4fh);
         return ti;
@@ -389,45 +389,45 @@
         faacDecClose(decoder);
 
         msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000;
-        tuple_associate_int(ti, "length", msDuration);
+        tuple_associate_int(ti, FIELD_LENGTH, NULL, msDuration);
 
         mp4ff_meta_get_title(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "title", tmpval);
+            tuple_associate_string(ti, FIELD_TITLE, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_album(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "album", tmpval);
+            tuple_associate_string(ti, FIELD_ALBUM, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_artist(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "artist", tmpval);
+            tuple_associate_string(ti, FIELD_ARTIST, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_genre(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_string(ti, "genre", tmpval);
+            tuple_associate_string(ti, FIELD_GENRE, NULL, tmpval);
             free(tmpval);
         }
 
         mp4ff_meta_get_date(mp4file, &tmpval);
         if (tmpval)
         {
-            tuple_associate_int(ti, "year", atoi(tmpval));
+            tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(tmpval));
             free(tmpval);
         }
 
-        tuple_associate_string(ti, "codec", "Advanced Audio Coding (AAC)");
-        tuple_associate_string(ti, "quality", "lossy");
+        tuple_associate_string(ti, FIELD_CODEC, NULL, "Advanced Audio Coding (AAC)");
+        tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
         free (mp4cb);
         vfs_fclose(mp4fh);
--- a/src/adplug/adplug-xmms.cc	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/adplug/adplug-xmms.cc	Sun Sep 09 23:52:19 2007 +0300
@@ -694,16 +694,16 @@
   {
     Tuple *ti = tuple_new_from_filename(filename);
     if (! p->getauthor().empty())
-      tuple_associate_string(ti, "artist", p->getauthor().c_str());
+      tuple_associate_string(ti, FIELD_ARTIST, NULL, p->getauthor().c_str());
     if (! p->gettitle().empty())
-      tuple_associate_string(ti, "title", p->gettitle().c_str());
+      tuple_associate_string(ti, FIELD_TITLE, NULL, p->gettitle().c_str());
     else if (! p->getdesc().empty())
-      tuple_associate_string(ti, "title", p->getdesc().c_str());
+      tuple_associate_string(ti, FIELD_TITLE, NULL, p->getdesc().c_str());
     else
-      tuple_associate_string(ti, "title", g_path_get_basename(filename));
-    tuple_associate_string(ti, "codec", p->gettype().c_str());
-    tuple_associate_string(ti, "quality", "sequenced");
-    tuple_associate_int(ti, "length", p->songlength (plr.subsong));
+      tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(filename));
+    tuple_associate_string(ti, FIELD_CODEC, NULL, p->gettype().c_str());
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+    tuple_associate_int(ti, FIELD_LENGTH, NULL, p->songlength (plr.subsong));
     delete p;
     return ti;
   }
@@ -715,7 +715,7 @@
 {
   char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
   if ( result )
-    *length = tuple_get_int(ti, "length");
+    *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
   tuple_free((void *) ti);
 
   return result;
--- a/src/alac/plugin.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/alac/plugin.c	Sun Sep 09 23:52:19 2007 +0300
@@ -122,20 +122,20 @@
     Tuple *ti = tuple_new_from_filename(path);
 
     if (demux_res->tuple.art != NULL)
-        tuple_associate_string(ti, "artist", demux_res->tuple.art);
+        tuple_associate_string(ti, FIELD_ARTIST, NULL, demux_res->tuple.art);
     if (demux_res->tuple.nam != NULL)
-        tuple_associate_string(ti, "title", demux_res->tuple.nam);
+        tuple_associate_string(ti, FIELD_TITLE, NULL, demux_res->tuple.nam);
     if (demux_res->tuple.alb != NULL)
-        tuple_associate_string(ti, "album", demux_res->tuple.alb);
+        tuple_associate_string(ti, FIELD_ALBUM, NULL, demux_res->tuple.alb);
     if (demux_res->tuple.gen != NULL)
-        tuple_associate_string(ti, "genre", demux_res->tuple.gen);
+        tuple_associate_string(ti, FIELD_GENRE, NULL, demux_res->tuple.gen);
     if (demux_res->tuple.cmt != NULL)
-        tuple_associate_string(ti, "comment", demux_res->tuple.cmt);
+        tuple_associate_string(ti, FIELD_COMMENT, NULL, demux_res->tuple.cmt);
     if (demux_res->tuple.day != NULL)
-        tuple_associate_int(ti, "year", atoi(demux_res->tuple.day));
+        tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(demux_res->tuple.day));
 
-    tuple_associate_string(ti, "codec", "Apple Lossless (ALAC)");
-    tuple_associate_string(ti, "quality", "lossless");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Apple Lossless (ALAC)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
 
     return ti;
 }
--- a/src/console/Audacious_Driver.cxx	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/console/Audacious_Driver.cxx	Sun Sep 09 23:52:19 2007 +0300
@@ -208,23 +208,23 @@
 	Tuple* ti = tuple_new();
 	if ( ti )
 	{
-		tuple_associate_string(ti, "file-name", g_path_get_basename(path));
-		tuple_associate_string(ti, "file-path", g_path_get_dirname(path));
-		tuple_associate_string(ti, "artist", info.author);
-		tuple_associate_string(ti, "album", info.game);
-		tuple_associate_string(ti, "game", info.game);
-		tuple_associate_string(ti, "title", info.song ? info.song : g_path_get_basename(path));
+		tuple_associate_string(ti, FIELD_FILE_NAME, NULL, g_path_get_basename(path));
+		tuple_associate_string(ti, FIELD_FILE_PATH, NULL, g_path_get_dirname(path));
+		tuple_associate_string(ti, FIELD_ARTIST, NULL, info.author);
+		tuple_associate_string(ti, FIELD_ALBUM, NULL, info.game);
+		tuple_associate_string(ti, -1, "game", info.game);
+		tuple_associate_string(ti, FIELD_TITLE, NULL, info.song ? info.song : g_path_get_basename(path));
 		if ( info.track_count > 1 )
 		{
-			tuple_associate_int(ti, "track-number", track + 1);
-			tuple_associate_int(ti, "subsong", track);
+			tuple_associate_int(ti, FIELD_TRACK_NUMBER, NULL, track + 1);
+			tuple_associate_int(ti, -1, "subsong", track);
 		}
-		tuple_associate_string(ti, "copyright", info.copyright);
-		tuple_associate_string(ti, "console", info.system);
-		tuple_associate_string(ti, "codec", info.system);
-		tuple_associate_string(ti, "quality", "sequenced");
-		tuple_associate_string(ti, "dumper", info.dumper);
-		tuple_associate_string(ti, "comment", info.comment);
+		tuple_associate_string(ti, FIELD_COPYRIGHT, NULL, info.copyright);
+		tuple_associate_string(ti, -1, "console", info.system);
+		tuple_associate_string(ti, FIELD_CODEC, NULL, info.system);
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+		tuple_associate_string(ti, -1, "dumper", info.dumper);
+		tuple_associate_string(ti, FIELD_COMMENT, NULL, info.comment);
 
 		int length = info.length;
 		if ( length <= 0 )
@@ -233,7 +233,7 @@
 			length = audcfg.loop_length * 1000;
 		else if ( length >= fade_threshold )
 			length += fade_length;
-		tuple_associate_int(ti, "length", length);
+		tuple_associate_int(ti, FIELD_LENGTH, NULL, length);
 	}
 	return ti;
 }
@@ -242,7 +242,7 @@
 {
 	char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
 	if ( result )
-		*length = tuple_get_int(ti, "length");
+		*length = tuple_get_int(ti, FIELD_LENGTH, NULL);
 	tuple_free((void *) ti);
 
 	return result;
--- a/src/cue/cuesheet.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/cue/cuesheet.c	Sun Sep 09 23:52:19 2007 +0300
@@ -225,11 +225,11 @@
 	return get_tuple_uri(uri);
 }
 
-static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gchar *field)
+static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gint nfield, const gchar *field)
 {
-    const gchar *str = tuple_get_string(tuple, field);
-    tuple_disassociate(tuple2, field);
-    tuple_associate_string(tuple2, field, str);
+    const gchar *str = tuple_get_string(tuple, nfield, field);
+    tuple_disassociate(tuple2, nfield, field);
+    tuple_associate_string(tuple2, nfield, field, str);
 }
 
 static Tuple *get_tuple_uri(gchar *uri)
@@ -274,26 +274,26 @@
 
     out = tuple_new();
 
-    _tuple_copy_field(phys_tuple, out, "file-path");
-    _tuple_copy_field(phys_tuple, out, "file-name");
-    _tuple_copy_field(phys_tuple, out, "file-ext");
-    _tuple_copy_field(phys_tuple, out, "codec");
-    _tuple_copy_field(phys_tuple, out, "quality");
-    _tuple_copy_field(phys_tuple, out, "copyright");
-    _tuple_copy_field(phys_tuple, out, "comment");
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_PATH, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_NAME, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_FILE_EXT, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_CODEC, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_QUALITY, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_COPYRIGHT, NULL);
+    _tuple_copy_field(phys_tuple, out, FIELD_COMMENT, NULL);
 
-    tuple_associate_int(out, "length", tuple_get_int(phys_tuple, "length"));
+    tuple_associate_int(out, FIELD_LENGTH, NULL, tuple_get_int(phys_tuple, FIELD_LENGTH, NULL));
 
     tuple_free(phys_tuple);
 
-    tuple_associate_string(out, "title", cue_tracks[track].title);
-    tuple_associate_string(out, "artist", cue_tracks[track].performer ?
+    tuple_associate_string(out, FIELD_TITLE, NULL, cue_tracks[track].title);
+    tuple_associate_string(out, FIELD_ARTIST, NULL, cue_tracks[track].performer ?
 				  cue_tracks[track].performer : cue_performer);
-    tuple_associate_string(out, "album", cue_title);
-    tuple_associate_string(out, "genre", cue_genre);
+    tuple_associate_string(out, FIELD_ALBUM, NULL, cue_title);
+    tuple_associate_string(out, FIELD_GENRE, NULL, cue_genre);
     if(cue_year)
-        tuple_associate_int(out, "year", atoi(cue_year));
-    tuple_associate_int(out, "track-number", track + 1);
+        tuple_associate_int(out, FIELD_YEAR, NULL, atoi(cue_year));
+    tuple_associate_int(out, FIELD_TRACK_NUMBER, NULL, track + 1);
 
     return out;
 }
@@ -315,7 +315,7 @@
 	g_return_if_fail(tuple != NULL);
 
 	*title = tuple_formatter_make_title_string(tuple, get_gentitle_format());
-	*length = tuple_get_int(tuple, "length");
+	*length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
 
 	tuple_free(tuple);
 }
--- a/src/filewriter/filewriter.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/filewriter/filewriter.c	Sun Sep 09 23:52:19 2007 +0300
@@ -183,6 +183,7 @@
 static gint file_open(AFormat fmt, gint rate, gint nch)
 {
     gchar *filename = NULL, *temp = NULL;
+    const gchar *directory;
     gint pos;
     gint rv;
     Playlist *playlist;
@@ -222,7 +223,7 @@
     }
     if (filename == NULL)
     {
-        filename = g_strdup(tuple_get_string(tuple, "file-name"));
+        filename = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
         if (!use_suffix)
             if ((temp = strrchr(filename, '.')) != NULL)
                 *temp = '\0';
@@ -233,10 +234,8 @@
 
     if (prependnumber)
     {
-        gint number;
-        if (tuple && tuple_get_int(tuple, "track-number"))
-            number = tuple_get_int(tuple, "track-number");
-        else
+        gint number = tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL);
+        if (!tuple || !number)
             number = pos + 1;
 
         temp = g_strdup_printf("%.02d %s", number, filename);
@@ -244,15 +243,13 @@
         filename = temp;
     }
 
-    gchar *directory;
     if (save_original)
-        directory = g_strdup(tuple_get_string(tuple, "file-path"));
+        directory = tuple_get_string(tuple, FIELD_FILE_PATH, NULL);
     else
-        directory = g_strdup(file_path);
+        directory = file_path;
 
     temp = g_strdup_printf("file://%s/%s.%s",
                            directory, filename, fileext_str[fileext]);
-    g_free(directory);
     g_free(filename);
     filename = temp;
 
--- a/src/filewriter/flac.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/filewriter/flac.c	Sun Sep 09 23:52:19 2007 +0300
@@ -107,14 +107,14 @@
 
         meta = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
 
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "title"), "title=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "artist"), "artist=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "album"), "album=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "genre"), "genre=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "comment"), "comment=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, "date"), "date=%s");
-        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "year"), "year=%d");
-        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, "track-number"), "tracknumber=%d");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_TITLE, NULL), "title=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_ARTIST, NULL), "artist=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_ALBUM, NULL), "album=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_GENRE, NULL), "genre=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_COMMENT, NULL), "comment=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_string(tuple, FIELD_DATE, NULL), "date=%s");
+        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, FIELD_YEAR, NULL), "year=%d");
+        INSERT_VORBIS_COMMENT(tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL), "tracknumber=%d");
 
         FLAC__stream_encoder_set_metadata(flac_encoder, &meta, 1);
     }
--- a/src/filewriter/mp3.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/filewriter/mp3.c	Sun Sep 09 23:52:19 2007 +0300
@@ -207,24 +207,24 @@
     if (tuple) {
         /* XXX write UTF-8 even though libmp3lame does id3v2.3. --yaz */
 #ifdef DEBUG
-        g_print("track_name = %s\n", tuple_get_string(tuple, "title"));
+        g_print("track_name = %s\n", tuple_get_string(tuple, FIELD_TITLE, NULL));
 #endif
-        lameid3.track_name = g_strdup(tuple_get_string(tuple, "title"));
+        lameid3.track_name = g_strdup(tuple_get_string(tuple, FIELD_TITLE, NULL));
         id3tag_set_title(gfp, lameid3.track_name);
 
-        lameid3.performer = g_strdup(tuple_get_string(tuple, "artist"));
+        lameid3.performer = g_strdup(tuple_get_string(tuple, FIELD_ARTIST, NULL));
         id3tag_set_artist(gfp, lameid3.performer);
 
-        lameid3.album_name = g_strdup(tuple_get_string(tuple, "album"));
+        lameid3.album_name = g_strdup(tuple_get_string(tuple, FIELD_ALBUM, NULL));
         id3tag_set_album(gfp, lameid3.album_name);
 
-        lameid3.genre = g_strdup(tuple_get_string(tuple, "genre"));
+        lameid3.genre = g_strdup(tuple_get_string(tuple, FIELD_GENRE, NULL));
         id3tag_set_genre(gfp, lameid3.genre);
 
-        lameid3.year = g_strdup_printf("%d", tuple_get_int(tuple, "year"));
+        lameid3.year = g_strdup_printf("%d", tuple_get_int(tuple, FIELD_YEAR, NULL));
         id3tag_set_year(gfp, lameid3.year);
 
-        lameid3.track_number = g_strdup_printf("%d", tuple_get_int(tuple, "track-number"));
+        lameid3.track_number = g_strdup_printf("%d", tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
         id3tag_set_track(gfp, lameid3.track_number);
 
         //        id3tag_write_v1(gfp);
--- a/src/filewriter/vorbis.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/filewriter/vorbis.c	Sun Sep 09 23:52:19 2007 +0300
@@ -85,32 +85,32 @@
     if (tuple)
     {
         const gchar *scratch;
+        gchar tmpstr[32];
+        gint scrint;
 
-        if ((scratch = tuple_get_string(tuple, "title")))
+        if ((scratch = tuple_get_string(tuple, FIELD_TITLE, NULL)))
             vorbis_comment_add_tag(&vc, "title", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "artist")))
+        if ((scratch = tuple_get_string(tuple, FIELD_ARTIST, NULL)))
             vorbis_comment_add_tag(&vc, "artist", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "album")))
+        if ((scratch = tuple_get_string(tuple, FIELD_ALBUM, NULL)))
             vorbis_comment_add_tag(&vc, "album", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "genre")))
+        if ((scratch = tuple_get_string(tuple, FIELD_GENRE, NULL)))
             vorbis_comment_add_tag(&vc, "genre", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "date")))
+        if ((scratch = tuple_get_string(tuple, FIELD_DATE, NULL)))
             vorbis_comment_add_tag(&vc, "date", (gchar *) scratch);
-        if ((scratch = tuple_get_string(tuple, "comment")))
+        if ((scratch = tuple_get_string(tuple, FIELD_COMMENT, NULL)))
             vorbis_comment_add_tag(&vc, "comment", (gchar *) scratch);
 
-        if (tuple_get_int(tuple, "track-number"))
+        if ((scrint = tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL)))
         {
-            gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "track-number"));
-            vorbis_comment_add_tag(&vc, "tracknumber", tmp);
-            g_free(tmp);
+            g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint);
+            vorbis_comment_add_tag(&vc, "tracknumber", tmpstr);
         }
 
-        if (tuple_get_int(tuple, "year"))
+        if ((scrint = tuple_get_int(tuple, FIELD_YEAR, NULL)))
         {
-            gchar *tmp = g_strdup_printf("%d", tuple_get_int(tuple, "year"));
-            vorbis_comment_add_tag(&vc, "year", tmp);
-            g_free(tmp);
+            g_snprintf(tmpstr, sizeof(tmpstr), "%d", scrint);
+            vorbis_comment_add_tag(&vc, "year", tmpstr);
         }
     }
 
--- a/src/flacng/tools.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/flacng/tools.c	Sun Sep 09 23:52:19 2007 +0300
@@ -241,29 +241,29 @@
 
     out = tuple_new_from_filename(filename);
 
-    tuple_associate_string(out, "codec", "Free Lossless Audio Codec (FLAC)");
-    tuple_associate_string(out, "quality", "lossless");
+    tuple_associate_string(out, FIELD_CODEC, NULL, "Free Lossless Audio Codec (FLAC)");
+    tuple_associate_string(out, FIELD_CODEC, NULL, "lossless");
 
-    tuple_associate_string(out, "artist", info->comment.artist);
-    tuple_associate_string(out, "title", info->comment.title);
-    tuple_associate_string(out, "album", info->comment.album);
-    tuple_associate_string(out, "genre", info->comment.genre);
+    tuple_associate_string(out, FIELD_ARTIST, NULL, info->comment.artist);
+    tuple_associate_string(out, FIELD_TITLE, NULL, info->comment.title);
+    tuple_associate_string(out, FIELD_ALBUM, NULL, info->comment.album);
+    tuple_associate_string(out, FIELD_GENRE, NULL, info->comment.genre);
 
     if (info->comment.tracknumber != NULL)
-        tuple_associate_int(out, "track-number", atoi(info->comment.tracknumber));
+        tuple_associate_int(out, FIELD_TRACK_NUMBER, NULL, atoi(info->comment.tracknumber));
 
     if (info->comment.date != NULL)
-        tuple_associate_int(out, "year", atoi(info->comment.date));
+        tuple_associate_int(out, FIELD_YEAR, NULL, atoi(info->comment.date));
 
     /*
      * Calculate the stream length (milliseconds)
      */
     if (0 == info->stream.samplerate) {
         _ERROR("Invalid sample rate for stream!");
-        tuple_associate_int(out, "length", -1);
+        tuple_associate_int(out, FIELD_LENGTH, NULL, -1);
     } else {
-        tuple_associate_int(out, "length", (info->stream.samples / info->stream.samplerate) * 1000);
-        _DEBUG("Stream length: %d seconds", tuple_get_int(out, "length"));
+        tuple_associate_int(out, FIELD_LENGTH, NULL, (info->stream.samples / info->stream.samplerate) * 1000);
+        _DEBUG("Stream length: %d seconds", tuple_get_int(out, FIELD_LENGTH, NULL));
     }
 
     _DEBUG("Tuple created: [%p]", out);
--- a/src/madplug/decoder.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/madplug/decoder.c	Sun Sep 09 23:52:19 2007 +0300
@@ -192,7 +192,7 @@
     info->duration = mad_timer_zero; // should be cleared before loop, if we use it as break condition.
 
     if(info->fileinfo_request == TRUE) {
-        tuple_associate_int(info->tuple, "length", -1);
+        tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1);
         info->fileinfo_request = FALSE;
     }
 
@@ -270,10 +270,10 @@
             g_message("size = %d", stream.next_frame - stream.this_frame);
 #endif
 #endif
-            if(tuple_get_int(info->tuple, "length") == -1)
+            if(tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1)
                 mad_timer_add(&info->duration, header.duration);
             else {
-                gint length = tuple_get_int(info->tuple, "length");
+                gint length = tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
 
                 info->duration.seconds = length / 1000;
                 info->duration.fraction = length % 1000;
@@ -357,7 +357,7 @@
 #ifdef DEBUG
                 g_message("info->frames = %d", info->frames);
 #endif
-                if(tuple_get_int(info->tuple, "length") == -1) {
+                if(tuple_get_int(info->tuple, FIELD_LENGTH, NULL) == -1) {
                     if(xing_bitrate > 0.0) {
                         /* calc duration with xing info */
                         double tmp = 8 * (double)info->xing.bytes * 1000 / xing_bitrate;
@@ -371,7 +371,7 @@
                     }
                 }
                 else {
-                    gint length = tuple_get_int(info->tuple, "length");
+                    gint length = tuple_get_int(info->tuple, FIELD_LENGTH, NULL);
 
                     info->duration.seconds = length / 1000;
                     info->duration.fraction = length % 1000;
--- a/src/madplug/input.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/madplug/input.c	Sun Sep 09 23:52:19 2007 +0300
@@ -322,12 +322,12 @@
     return rtn;
 }
 
-static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gchar *tuple_name)
+static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gint nfield)
 {
     gchar *scratch = input_id3_get_string(tag, frame);
 
-    tuple_associate_string(tuple, tuple_name, scratch);
-    tuple_associate_string(tuple, frame, scratch);
+    tuple_associate_string(tuple, nfield, NULL, scratch);
+    tuple_associate_string(tuple, -1, frame, scratch);
 
     g_free(scratch);
 }
@@ -339,7 +339,7 @@
     if (info->tuple == NULL) {
         tuple = tuple_new();
         info->tuple = tuple;
-        tuple_associate_int(info->tuple, "length", -1);
+        tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1);
     }
 }
 
@@ -349,19 +349,17 @@
 static void input_read_tag(struct mad_info_t *info)
 {
     gchar *string = NULL;
-    gchar *realfn = NULL;
     Tuple *tuple;
     glong curpos = 0;
 
 #ifdef DEBUG
     g_message("f: input_read_tag");
 #endif
-    if (info->tuple == NULL) {
-        tuple = tuple_new();
-        info->tuple = tuple;
-    }
-    else
-        tuple = info->tuple;
+    if (info->tuple != NULL)
+        tuple_free(info->tuple);
+        
+    tuple = tuple_new_from_filename(info->filename);
+    info->tuple = tuple;
 
     if(info->infile) {
         curpos = vfs_ftell(info->infile);
@@ -386,15 +384,15 @@
         return;
     }
 
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, "artist");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, "title");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ALBUM, "album");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_GENRE, "genre");
-    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_COMMENT, "comment");
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, FIELD_ARTIST);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, FIELD_TITLE);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ALBUM, FIELD_ALBUM);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_GENRE, FIELD_GENRE);
+    input_set_and_free_tag(info->tag, tuple, ID3_FRAME_COMMENT, FIELD_COMMENT);
 
     string = input_id3_get_string(info->tag, ID3_FRAME_TRACK);
     if (string) {
-        tuple_associate_int(tuple, "track-number", atoi(string));
+        tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
         g_free(string);
         string = NULL;
     }
@@ -406,7 +404,7 @@
         string = input_id3_get_string(info->tag, "TYER");
 
     if (string) {
-        tuple_associate_int(tuple, "year", atoi(string));
+        tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
         g_free(string);
         string = NULL;
     }
@@ -414,7 +412,7 @@
     // length
     string = input_id3_get_string(info->tag, "TLEN");
     if (string) {
-        tuple_associate_int(tuple, "length", atoi(string));
+        tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string));
 #ifdef DEBUG
         g_message("input_read_tag: TLEN = %d", atoi(string));
 #endif	
@@ -422,25 +420,8 @@
         string = NULL;
     }
     
-    realfn = g_filename_from_uri(info->filename, NULL, NULL);
-    
-    string = g_strdup(g_basename(realfn ? realfn : info->filename));
-    tuple_associate_string(tuple, "file-name", string);
-    g_free(string);
-
-    string = g_path_get_dirname(realfn ? realfn : info->filename);
-    tuple_associate_string(tuple, "file-path", string);
-    g_free(string);
-
-    if ((string = strrchr(realfn ? realfn : info->filename, '.'))) {
-        *string = '\0';         // make filename end at dot.
-        tuple_associate_string(tuple, "file-ext", string + 1);
-    }
-
-    g_free(realfn); realfn = NULL;
-
-    tuple_associate_string(tuple, "codec", "MPEG Audio (MP3)");
-    tuple_associate_string(tuple, "quality", "lossy");
+    tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
+    tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
 
     info->title = tuple_formatter_make_title_string(tuple, audmad_config.title_override == TRUE ?
         audmad_config.id3_format : get_gentitle_format());
@@ -470,8 +451,8 @@
 
         g_free(info->title);
         info->title = NULL;
-        tuple_disassociate(info->tuple, "title");
-        tuple_disassociate(info->tuple, "album");
+        tuple_disassociate(info->tuple, FIELD_TITLE, NULL);
+        tuple_disassociate(info->tuple, FIELD_ALBUM, NULL);
 
         tmp = vfs_get_metadata(info->infile, "track-name");
         if(tmp){
@@ -479,7 +460,7 @@
             gchar *scratch;
 
             scratch = str_to_utf8(tmp);
-            tuple_associate_string(info->tuple, "title", scratch);
+            tuple_associate_string(info->tuple, FIELD_TITLE, NULL, scratch);
             g_free(scratch);
 
             g_free(tmp);
@@ -492,8 +473,8 @@
             gchar *scratch;
 
             scratch = str_to_utf8(tmp);
-            tuple_associate_string(info->tuple, "album", scratch);
-            tuple_associate_string(info->tuple, "stream", scratch);
+            tuple_associate_string(info->tuple, FIELD_ALBUM, NULL, scratch);
+            tuple_associate_string(info->tuple, -1, "stream", scratch);
             g_free(scratch);
 
             g_free(tmp);
--- a/src/madplug/plugin.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/madplug/plugin.c	Sun Sep 09 23:52:19 2007 +0300
@@ -516,14 +516,14 @@
     }
 
     if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
-        if(tuple_get_string(myinfo.tuple, "track-name"))
-            *title = g_strdup(tuple_get_string(myinfo.tuple, "track-name"));
+        if(tuple_get_string(myinfo.tuple, -1, "track-name"))
+            *title = g_strdup(tuple_get_string(myinfo.tuple, -1, "track-name"));
         else
             *title = g_strdup(url);
-        if(tuple_get_int(myinfo.tuple, "length") == -1)
+        if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1)
             *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
         else
-            *length = tuple_get_int(myinfo.tuple, "length");
+            *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
     }
     else {
         *title = g_strdup(url);
@@ -553,10 +553,10 @@
     }
 
     if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) {
-        if(tuple_get_int(myinfo.tuple, "length") == -1)
+        if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1)
             *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS);
         else
-            *length = tuple_get_int(myinfo.tuple, "length");
+            *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL);
     }
     else {
         *length = -1;
@@ -629,9 +629,9 @@
 extern void audmad_get_file_info(char *filename);
 extern void audmad_configure();
 
-static void __set_and_free(Tuple *tuple, gchar *name, gchar *value)
+static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value)
 {
-    tuple_associate_string(tuple, name, value);
+    tuple_associate_string(tuple, nfield, name, value);
     g_free(value);
 }
 
@@ -657,7 +657,7 @@
     if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){
         if((fd && vfs_is_streaming(fd)) || (info.playback && info.playback->playing)) {
             gchar *tmp = NULL;
-            tuple = tuple_new();
+            tuple = tuple_new_from_filename(filename);
 
 #ifdef DEBUG
             if(info.playback)
@@ -668,7 +668,7 @@
                 gchar *scratch;
 
                 scratch = str_to_utf8(tmp);
-                tuple_associate_string(tuple, "title", scratch);
+                tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
                 g_free(tmp);
                 g_free(scratch);
 
@@ -679,7 +679,7 @@
                 gchar *scratch;
 
                 scratch = str_to_utf8(tmp);
-                tuple_associate_string(tuple, "title", scratch);
+                tuple_associate_string(tuple, FIELD_TITLE, NULL, scratch);
                 g_free(tmp);
                 g_free(scratch);
 
@@ -687,17 +687,11 @@
             }
 
 #ifdef DEBUG
-            g_message("audmad_get_song_tuple: track_name = %s", tuple_get_string(tuple, "track-name"));
-            g_message("audmad_get_song_tuple: stream_name = %s", tuple_get_string(tuple, "stream-name"));
+            g_message("audmad_get_song_tuple: track_name = %s", tuple_get_string(tuple, -1, "track-name"));
+            g_message("audmad_get_song_tuple: stream_name = %s", tuple_get_string(tuple, -1, "stream-name"));
 #endif
-            realfn = g_filename_from_uri(filename, NULL, NULL);
-            __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-            __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-            tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
-            g_free(realfn); realfn = NULL;
-
-            tuple_associate_int(tuple, "length", -1);
-            tuple_associate_int(tuple, "mtime", 0); // this indicates streaming
+            tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
+            tuple_associate_int(tuple, FIELD_MTIME, NULL, 0); // this indicates streaming
 #ifdef DEBUG
             g_message("get_song_tuple: remote: tuple");
 #endif
@@ -718,7 +712,7 @@
     }
 
     tuple = tuple_new();
-    tuple_associate_int(tuple, "length", -1);
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
 
     id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READONLY);
 
@@ -726,9 +720,9 @@
 
         tag = id3_file_tag(id3file);
         if (tag) {
-            __set_and_free(tuple, "artist", input_id3_get_string(tag, ID3_FRAME_ARTIST));
-            __set_and_free(tuple, "album", input_id3_get_string(tag, ID3_FRAME_ALBUM));
-            __set_and_free(tuple, "title", input_id3_get_string(tag, ID3_FRAME_TITLE));
+            __set_and_free(tuple, FIELD_ARTIST, NULL, input_id3_get_string(tag, ID3_FRAME_ARTIST));
+            __set_and_free(tuple, FIELD_ALBUM, NULL, input_id3_get_string(tag, ID3_FRAME_ALBUM));
+            __set_and_free(tuple, FIELD_TITLE, NULL, input_id3_get_string(tag, ID3_FRAME_TITLE));
 
             // year
             string = NULL;
@@ -737,22 +731,22 @@
                 string = input_id3_get_string(tag, "TYER");
 
             if (string) {
-                tuple_associate_int(tuple, "year", atoi(string));
+                tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string));
                 g_free(string);
                 string = NULL;
             }
             realfn = g_filename_from_uri(filename, NULL, NULL);
-            __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-            __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-            tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
+            __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
+            __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
+            tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
             g_free(realfn); realfn = NULL;
 
             // length
             string = input_id3_get_string(tag, "TLEN");
             if (string) {
-                tuple_associate_int(tuple, "length", atoi(string));
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string));
 #ifdef DEBUG
-                g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, "length"));
+                g_message("get_song_tuple: TLEN = %d", tuple_get_int(tuple, FIELD_LENGTH, NULL));
 #endif
                 g_free(string);
                 string = NULL;
@@ -761,46 +755,46 @@
                 char *dummy = NULL;
                 int length = 0;
                 audmad_get_song_length(filename, &length, fd);
-                tuple_associate_int(tuple, "length", length);
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
                 g_free(dummy);
             }
 
             // track number
             string = input_id3_get_string(tag, ID3_FRAME_TRACK);
             if (string) {
-                tuple_associate_int(tuple, "track-number", atoi(string));
+                tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string));
                 g_free(string);
                 string = NULL;
             }
             // genre
-            __set_and_free(tuple, "genre", input_id3_get_string(tag, ID3_FRAME_GENRE));
-            __set_and_free(tuple, "comment", input_id3_get_string(tag, ID3_FRAME_COMMENT));
+            __set_and_free(tuple, FIELD_GENRE, NULL, input_id3_get_string(tag, ID3_FRAME_GENRE));
+            __set_and_free(tuple, FIELD_COMMENT, NULL, input_id3_get_string(tag, ID3_FRAME_COMMENT));
 #ifdef DEBUG
-            g_message("genre = %s", tuple_get_string(tuple, "genre"));
+            g_message("genre = %s", tuple_get_string(tuple, FIELD_GENRE, NULL));
 #endif
         }
         id3_file_close(id3file);
     } // id3file
     else { // no id3tag
         realfn = g_filename_from_uri(filename, NULL, NULL);
-        __set_and_free(tuple, "file-name", g_path_get_basename(realfn ? realfn : filename));
-        __set_and_free(tuple, "file-path", g_path_get_dirname(realfn ? realfn : filename));
-        tuple_associate_string(tuple, "file-ext", extname(realfn ? realfn : filename));
+        __set_and_free(tuple, FIELD_FILE_NAME, NULL, g_path_get_basename(realfn ? realfn : filename));
+        __set_and_free(tuple, FIELD_FILE_PATH, NULL, g_path_get_dirname(realfn ? realfn : filename));
+        tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, extname(realfn ? realfn : filename));
         g_free(realfn); realfn = NULL;
         // length
         {
             char *dummy = NULL;
             int length = 0;
-            if(tuple_get_int(tuple, "length") == -1) {
+            if(tuple_get_int(tuple, FIELD_LENGTH, NULL) == -1) {
                 audmad_get_song_length(filename, &length, fd);
-                tuple_associate_int(tuple, "length", length);
+                tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
             }
             g_free(dummy);
         }
     }
 
-    tuple_associate_string(tuple, "quality", "lossy");
-    tuple_associate_string(tuple, "codec", "MPEG Audio (MP3)");
+    tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
+    tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)");
 
     if(local_fd)
         vfs_fclose(fd);
--- a/src/modplug/modplugbmp.cxx	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/modplug/modplugbmp.cxx	Sun Sep 09 23:52:19 2007 +0300
@@ -26,7 +26,7 @@
 {
         char* result = tuple_formatter_make_title_string(ti, get_gentitle_format());
         if ( result )
-                *length = tuple_get_int(ti, "length");
+                *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
         tuple_free((void *) ti);
 
         return result;
@@ -519,7 +519,7 @@
 	Tuple *ti = tuple_new_from_filename(aFilename.c_str());
 	lSoundFile = new CSoundFile;
 	lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size());
-
+	
 	switch(lSoundFile->GetType())
         {
 	case MOD_TYPE_MOD:	tmps = "ProTracker"; break;
@@ -545,19 +545,18 @@
 	case MOD_TYPE_PSM:	tmps = "Protracker Studio Module"; break;
 	default:		tmps = "ModPlug unknown"; break;
 	}
-	tuple_associate_string(ti, "codec", tmps);
-	tuple_associate_string(ti, "quality", "sequenced");
-	tuple_associate_int(ti, "length", lSoundFile->GetSongTime() * 1000);
+	tuple_associate_string(ti, FIELD_CODEC, NULL, tmps);
+	tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
+	tuple_associate_int(ti, FIELD_LENGTH, NULL, lSoundFile->GetSongTime() * 1000);
 
 	/* NOTICE! FIXME? This is actually incorrect. We _cannot_ know what charset
 	 * an arbitrary module file uses .. typically it is some DOS CP-variant,
 	 * except for true Amiga modules.
 	 */
 	tmps = str_to_utf8(lSoundFile->GetTitle());
-	tuple_associate_string(ti, "title", tmps);
+	tuple_associate_string(ti, FIELD_TITLE, NULL, lSoundFile->GetTitle());
 	g_free(tmps);
 	
-	
 	//unload the file
 	lSoundFile->Destroy();
 	delete lSoundFile;
--- a/src/mtp_up/mtp.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/mtp_up/mtp.c	Sun Sep 09 23:52:19 2007 +0300
@@ -135,7 +135,7 @@
     uint32_t parent_id = 0;
     struct stat sb;
 
-    from_path = g_strdup_printf("%s/%s", tuple_get_string(from_tuple, "file-path"), tuple_get_string(from_tuple, "file-name"));
+    from_path = g_strdup_printf("%s/%s", tuple_get_string(from_tuple, FIELD_FILE_PATH, NULL), tuple_get_string(from_tuple, FIELD_FILE_NAME));
     gchar *tmp;
     tmp = g_strescape(from_path,NULL);
     filename=g_filename_from_uri(tmp,NULL,NULL);
@@ -162,15 +162,15 @@
 
     /* track metadata*/
     tr = LIBMTP_new_track_t();
-    tr->title =g_strdup((gchar*) tuple_get_string(from_tuple, "title")); 
-    tr->artist =g_strdup((gchar*) tuple_get_string(from_tuple,"artist"));
-    tr->album = g_strdup((gchar*)tuple_get_string(from_tuple,"album"));
+    tr->title = g_strdup((gchar*) tuple_get_string(from_tuple, FIELD_TITLE, NULL)); 
+    tr->artist = g_strdup((gchar*) tuple_get_string(from_tuple, FIELD_ARTIST, NULL));
+    tr->album = g_strdup((gchar*)tuple_get_string(from_tuple, FIELD_ALBUM, NULL));
     tr->filesize = filesize;
-    tr->filename = g_strdup(tuple_get_string(from_tuple, "file-name"));
-    tr->duration = (uint32_t)tuple_get_int(from_tuple, "length");
+    tr->filename = g_strdup(tuple_get_string(from_tuple, FIELD_FILE_NAME, NULL));
+    tr->duration = (uint32_t)tuple_get_int(from_tuple, FIELD_LENGTH, NULL);
     tr->filetype = find_filetype (from_path);
-    tr->genre = g_strdup((gchar*)tuple_get_string(from_tuple, "genre"));
-    tr->date = g_strdup_printf("%d",tuple_get_int(from_tuple, "year"));
+    tr->genre = g_strdup((gchar*)tuple_get_string(from_tuple, FIELD_GENRE, NULL));
+    tr->date = g_strdup_printf("%d",tuple_get_int(from_tuple, FIELD_YEAR, NULL));
     g_free(filename);
     g_free(from_path);
     g_free(tmp); 
@@ -184,7 +184,7 @@
     uint32_t parent_id = 0;
     LIBMTP_track_t *gentrack;
     gentrack = track_metadata(from_tuple);
-    from_path = g_strdup_printf("%s/%s", tuple_get_string(from_tuple, "file-path"), tuple_get_string(from_tuple, "file-name"));
+    from_path = g_strdup_printf("%s/%s", tuple_get_string(from_tuple, FIELD_FILE_PATH, NULL), tuple_get_string(from_tuple, FIELD_FILE_NAME, NULL));
     if(gentrack == NULL) return 1;
     comp = g_strescape(from_path,NULL);
     g_free(from_path);
--- a/src/scrobbler/fmt.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/scrobbler/fmt.c	Sun Sep 09 23:52:19 2007 +0300
@@ -29,7 +29,7 @@
 	static char buf[30];
 
 	tm = gmt ? gmtime(&t) : localtime(&t);
-	snprintf(buf, sizeof(buf), "%d-%.2d-%.2d %.2d:%.2d:%.2d",
+	g_snprintf(buf, sizeof(buf), "%d-%.2d-%.2d %.2d:%.2d:%.2d",
 			tm->tm_year + 1900,
 			tm->tm_mon + 1,
 			tm->tm_mday,
--- a/src/scrobbler/gerpok.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/scrobbler/gerpok.c	Sun Sep 09 23:52:19 2007 +0300
@@ -92,10 +92,10 @@
 
 	item = malloc(sizeof(item_t));
 
-	item->artist = fmt_escape(tuple_get_string(tuple, "artist"));
-	item->title = fmt_escape(tuple_get_string(tuple, "title"));
+	item->artist = fmt_escape(tuple_get_string(tuple, FIELD_ARTIST, NULL));
+	item->title = fmt_escape(tuple_get_string(tuple, FIELD_TITLE, NULL));
 	item->utctime = fmt_escape(fmt_timestr(time(NULL), 1));
-	snprintf(item->len, sizeof(item->len), "%d", len);
+	g_snprintf(item->len, sizeof(item->len), "%d", len);
 
 #ifdef NOTYET
 	if(tuple->mb == NULL)
@@ -106,7 +106,7 @@
 		item->mb = fmt_escape((char*)tuple->mb);
 #endif
 
-	if((album = tuple_get_string(tuple, "album")))
+	if((album = tuple_get_string(tuple, FIELD_ALBUM, NULL)))
 		item->album = fmt_escape("");
 	else
 		item->album = fmt_escape((char*) album);
@@ -412,7 +412,7 @@
 	char buf[4096];
 	CURL *curl;
 
-	snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s",
+	g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s",
 			SCROBBLER_HS_URL, SCROBBLER_VERSION,
 			SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, gerpok_sc_username);
 
@@ -568,9 +568,9 @@
 
 static gchar *gerpok_sc_itemtag(char c, int n, char *str)
 {
-    static char buf[SCROBBLER_SB_MAXLEN]; 
-    snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
-    return buf;
+	static char buf[SCROBBLER_SB_MAXLEN]; 
+	g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
+	return buf;
 }
 
 #define cfa(f, l, n, v) \
@@ -748,7 +748,7 @@
 
 	cachesize = written = 0;
 
-	snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -832,7 +832,7 @@
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/gerpokqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "w")))
 	{
--- a/src/scrobbler/plugin.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/scrobbler/plugin.c	Sun Sep 09 23:52:19 2007 +0300
@@ -240,16 +240,19 @@
 			if (tuple == NULL)
 				continue;
 
-			if (ishttp(tuple_get_string(tuple, "file-name")))
+			if (ishttp(tuple_get_string(tuple, FIELD_FILE_NAME, NULL)))
 				continue;
 
-			if(tuple_get_string(tuple, "artist") != NULL && tuple_get_string(tuple, "title") != NULL)
+			if (tuple_get_string(tuple, FIELD_ARTIST, NULL) != NULL &&
+				tuple_get_string(tuple, FIELD_TITLE, NULL) != NULL)
 			{
 				pdebug(fmt_vastr(
 					"submitting artist: %s, title: %s",
-					tuple_get_string(tuple, "artist"), tuple_get_string(tuple, "title")), DEBUG);
-				sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, "length") / 1000);
-				gerpok_sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, "length") / 1000);
+					tuple_get_string(tuple, FIELD_ARTIST, NULL),
+					tuple_get_string(tuple, FIELD_TITLE, NULL)), DEBUG);
+				
+				sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000);
+				gerpok_sc_addentry(m_scrobbler, tuple, tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000);
 			}
 			else
 				pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG);
--- a/src/scrobbler/scrobbler.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/scrobbler/scrobbler.c	Sun Sep 09 23:52:19 2007 +0300
@@ -131,11 +131,12 @@
 
 	item = malloc(sizeof(item_t));
 
-	item->artist = fmt_escape(tuple_get_string(tuple, "artist"));
-	item->title = fmt_escape(tuple_get_string(tuple, "title"));
-	snprintf(item->utctime, sizeof(item->utctime), "%ld", time(NULL));
-	snprintf(item->len, sizeof(item->len), "%d", len);
-	snprintf(item->track, sizeof(item->track), "%d", tuple_get_int(tuple, "track-number"));
+	item->artist = fmt_escape(tuple_get_string(tuple, FIELD_ARTIST, NULL));
+	item->title = fmt_escape(tuple_get_string(tuple, FIELD_TITLE, NULL));
+	g_snprintf(item->utctime, sizeof(item->utctime), "%ld", time(NULL));
+	g_snprintf(item->len, sizeof(item->len), "%d", len);
+	g_snprintf(item->track, sizeof(item->track), "%d",
+		tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
 
 #ifdef NOTYET
 	if(tuple->mb == NULL)
@@ -146,7 +147,7 @@
 		item->mb = fmt_escape((char*)tuple->mb);
 #endif
 
-	if((album = tuple_get_string(tuple, "album")) != NULL)
+	if((album = tuple_get_string(tuple, FIELD_ALBUM, NULL)) != NULL)
 		item->album = fmt_escape("");
 	else
 		item->album = fmt_escape((char*) album);
@@ -442,7 +443,7 @@
 	hexify(auth, strlen(auth));
 	auth_tmp = g_strdup(sc_response_hash);
 
-	snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s&t=%ld&a=%s",
+	g_snprintf(buf, sizeof(buf), "%s/?hs=true&p=%s&c=%s&v=%s&u=%s&t=%ld&a=%s",
 			SCROBBLER_HS_URL, SCROBBLER_VERSION,
 			SCROBBLER_CLI_ID, SCROBBLER_IMPLEMENTATION, sc_username, time(NULL),
 			auth_tmp);
@@ -600,9 +601,9 @@
 
 static gchar *sc_itemtag(char c, int n, char *str)
 {
-    static char buf[SCROBBLER_SB_MAXLEN]; 
-    snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
-    return buf;
+	static char buf[SCROBBLER_SB_MAXLEN]; 
+	g_snprintf(buf, SCROBBLER_SB_MAXLEN, "&%c[%d]=%s", c, n, str);
+	return buf;
 }
 
 #define cfa(f, l, n, v) \
@@ -673,10 +674,11 @@
 	/*cfa(&post, &last, "debug", "failed");*/
 
 	entry = g_strdup_printf("s=%s&a=%s&t=%s&b=%s&l=%d&n=%d&m=", sc_session_id,
-		tuple_get_string(tuple, "artist"),
-		tuple_get_string(tuple, "title"),
-		tuple_get_string(tuple, "album") ? tuple_get_string(tuple, "album") : "",
-		tuple_get_int(tuple, "length") / 1000, tuple_get_int(tuple, "track-number"));
+		tuple_get_string(tuple, FIELD_ARTIST, NULL),
+		tuple_get_string(tuple, FIELD_TITLE, NULL),
+		tuple_get_string(tuple, FIELD_ALBUM, NULL) ? tuple_get_string(tuple, FIELD_ALBUM, NULL) : "",
+		tuple_get_int(tuple, FIELD_LENGTH, NULL) / 1000,
+		tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL));
 
 	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *) entry);
 	memset(sc_curl_errbuf, 0, sizeof(sc_curl_errbuf));
@@ -831,7 +833,7 @@
 
 	cachesize = written = 0;
 
-	snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "r")))
 		return;
@@ -883,9 +885,9 @@
 		{
 			Tuple *tuple = tuple_new();
 
-			tuple_associate_string(tuple, "artist", xmms_urldecode_plain(artist));
-			tuple_associate_string(tuple, "title", xmms_urldecode_plain(title));
-			tuple_associate_string(tuple, "album", xmms_urldecode_plain(album));
+			tuple_associate_string(tuple, FIELD_ARTIST, NULL, xmms_urldecode_plain(artist));
+			tuple_associate_string(tuple, FIELD_TITLE, NULL, xmms_urldecode_plain(title));
+			tuple_associate_string(tuple, FIELD_ALBUM, NULL, xmms_urldecode_plain(album));
 
 			item = q_put(tuple, atoi(len));
 
@@ -926,7 +928,7 @@
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
+	g_snprintf(buf, sizeof(buf), "%s/scrobblerqueue.txt", audacious_get_localdir());
 
 	if (!(fd = fopen(buf, "w")))
 	{
--- a/src/sexypsf/plugin.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/sexypsf/plugin.c	Sun Sep 09 23:52:19 2007 +0300
@@ -226,18 +226,18 @@
 
     if (tmp->length) {
         tuple = tuple_new_from_filename(fn);
-	tuple_associate_int(tuple, "length", tmp->length);
-	tuple_associate_string(tuple, "artist", tmp->artist);
-	tuple_associate_string(tuple, "album", tmp->game);
-	tuple_associate_string(tuple, "game", tmp->game);
-        tuple_associate_string(tuple, "title", tmp->title);
-        tuple_associate_string(tuple, "genre", tmp->genre);
-        tuple_associate_string(tuple, "copyright", tmp->copyright);
-        tuple_associate_string(tuple, "quality", "sequenced");
-        tuple_associate_string(tuple, "codec", "PlayStation Audio");
-        tuple_associate_string(tuple, "console", "PlayStation");
-        tuple_associate_string(tuple, "dumper", tmp->psfby);
-        tuple_associate_string(tuple, "comment", tmp->comment);
+	tuple_associate_int(tuple, FIELD_LENGTH, NULL, tmp->length);
+	tuple_associate_string(tuple, FIELD_ARTIST, NULL, tmp->artist);
+	tuple_associate_string(tuple, FIELD_ALBUM, NULL, tmp->game);
+	tuple_associate_string(tuple, -1, "game", tmp->game);
+        tuple_associate_string(tuple, FIELD_TITLE, NULL, tmp->title);
+        tuple_associate_string(tuple, FIELD_GENRE, NULL, tmp->genre);
+        tuple_associate_string(tuple, FIELD_COPYRIGHT, NULL, tmp->copyright);
+        tuple_associate_string(tuple, FIELD_QUALITY, NULL, "sequenced");
+        tuple_associate_string(tuple, FIELD_CODEC, NULL, "PlayStation Audio");
+        tuple_associate_string(tuple, -1, "console", "PlayStation");
+        tuple_associate_string(tuple, -1, "dumper", tmp->psfby);
+        tuple_associate_string(tuple, FIELD_COMMENT, NULL, tmp->comment);
 
         sexypsf_freepsfinfo(tmp);
     }
--- a/src/sid/xmms-sid.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/sid/xmms-sid.c	Sun Sep 09 23:52:19 2007 +0300
@@ -672,13 +672,13 @@
 {
 	gchar *tmpStr, tmpStr2[64];
 
-	tuple_associate_string(pResult, "title", pInfo->sidName);
-	tuple_associate_string(pResult, "artist", pInfo->sidComposer);
-	tuple_associate_string(pResult, "genre", "SID-tune");
-	tuple_associate_string(pResult, "copyright", pInfo->sidCopyright);
+	tuple_associate_string(pResult, FIELD_TITLE, NULL, pInfo->sidName);
+	tuple_associate_string(pResult, FIELD_ARTIST, NULL, pInfo->sidComposer);
+	tuple_associate_string(pResult, FIELD_GENRE, NULL, "SID-tune");
+	tuple_associate_string(pResult, FIELD_COPYRIGHT, NULL, pInfo->sidCopyright);
 
-	tuple_associate_int(pResult, "subtunes", pInfo->nsubTunes);
-	tuple_associate_string(pResult, "sid-format", pInfo->sidFormat);
+	tuple_associate_int(pResult, -1, "subtunes", pInfo->nsubTunes);
+	tuple_associate_string(pResult, -1, "sid-format", pInfo->sidFormat);
 
 	switch (pInfo->sidModel) {
 		case XS_SIDMODEL_6581: tmpStr = "6581"; break;
@@ -686,7 +686,7 @@
 		case XS_SIDMODEL_ANY: tmpStr = "ANY"; break;
 		default: tmpStr = "?"; break;
 	}
-	tuple_associate_string(pResult, "sid-model", tmpStr);
+	tuple_associate_string(pResult, -1, "sid-model", tmpStr);
 	
 	/* Get sub-tune information, if available */
 	if (subTune < 0 || pInfo->startTune > pInfo->nsubTunes)
@@ -694,7 +694,7 @@
 	
 	if ((subTune > 0) && (subTune <= pInfo->nsubTunes)) {
 		gint tmpInt = pInfo->subTunes[subTune - 1].tuneLength;
-		tuple_associate_int(pResult, "length", (tmpInt < 0) ? -1 : tmpInt * 1000);
+		tuple_associate_int(pResult, FIELD_LENGTH, NULL, (tmpInt < 0) ? -1 : tmpInt * 1000);
 		
 		tmpInt = pInfo->subTunes[subTune - 1].tuneSpeed;
 		if (tmpInt > 0) {
@@ -712,15 +712,15 @@
 		} else
 			tmpStr = "?";
 
-		tuple_associate_string(pResult, "sid-speed", tmpStr);
+		tuple_associate_string(pResult, -1, "sid-speed", tmpStr);
 	} else
 		subTune = 1;
 
-	tuple_associate_int(pResult, "subtune", subTune);
-	tuple_associate_int(pResult, "track-number", subTune);
+	tuple_associate_int(pResult, -1, "subtune", subTune);
+	tuple_associate_int(pResult, FIELD_TRACK_NUMBER, NULL, subTune);
 
 	if (xs_cfg.titleOverride)
-		tuple_associate_string(pResult, "formatter", xs_cfg.titleFormat);
+		tuple_associate_string(pResult, FIELD_FORMATTER, NULL, xs_cfg.titleFormat);
 }
 
 Tuple * xs_get_song_tuple(gchar *songFilename)
--- a/src/statusicon/si_ui.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/statusicon/si_ui.c	Sun Sep 09 23:52:19 2007 +0300
@@ -150,7 +150,7 @@
     GtkWidget *popup = g_object_get_data( G_OBJECT(evbox) , "popup" );
 
     tuple = playlist_get_tuple( pl_active , pos );
-    if ( ( tuple == NULL ) || ( tuple_get_int(tuple, "length") < 1 ) )
+    if ( ( tuple == NULL ) || ( tuple_get_int(tuple, FIELD_LENGTH, NULL) < 1 ) )
     {
       gchar *title = playlist_get_songtitle( pl_active , pos );
       audacious_fileinfopopup_show_from_title( popup , title );
--- a/src/timidity/src/xmms-timidity.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/timidity/src/xmms-timidity.c	Sun Sep 09 23:52:19 2007 +0300
@@ -296,7 +296,7 @@
 
 	title = tuple_formatter_make_title_string(input, get_gentitle_format());
 	if (title == NULL || *title == '\0')
-		title = g_strdup(tuple_get_string(input, "file-name"));
+		title = g_strdup(tuple_get_string(input, FIELD_FILE_NAME, NULL));
 
 	tuple_free(input);
 
--- a/src/tta/libtta.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/tta/libtta.c	Sun Sep 09 23:52:19 2007 +0300
@@ -173,7 +173,7 @@
 	*title = NULL;
 
 	if ((tuple = get_song_tuple(filename)) != NULL) {
-    	    *length = tuple_get_int(tuple, "length");
+    	    *length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     	    *title = get_song_title(tuple);
 	}
 
@@ -561,30 +561,30 @@
 		if(open_tta_file(filename, ttainfo, 0) >= 0) {
 			tuple = tuple_new_from_filename(filename);
 
-			tuple_associate_string(tuple, "codec", "True Audio (TTA)");
-			tuple_associate_string(tuple, "quality", "lossless");
+			tuple_associate_string(tuple, FIELD_CODEC, NULL, "True Audio (TTA)");
+			tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossless");
 
 			if (ttainfo->ID3.id3has) {
 				if (ttainfo->ID3.artist)
-					tuple_associate_string(tuple, "artist", (gchar *) ttainfo->ID3.artist);
+					tuple_associate_string(tuple, FIELD_ARTIST, NULL, (gchar *) ttainfo->ID3.artist);
 
 				if (ttainfo->ID3.album)
-					tuple_associate_string(tuple, "album", (gchar *) ttainfo->ID3.album);
+					tuple_associate_string(tuple, FIELD_ALBUM, NULL, (gchar *) ttainfo->ID3.album);
 
 				if (ttainfo->ID3.title)
-					tuple_associate_string(tuple, "title", (gchar *) ttainfo->ID3.title);
+					tuple_associate_string(tuple, FIELD_TITLE, NULL, (gchar *) ttainfo->ID3.title);
 
 				if (ttainfo->ID3.year)
-					tuple_associate_int(tuple, "year", atoi((char *)ttainfo->ID3.year));
+					tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi((char *)ttainfo->ID3.year));
 
 				if(ttainfo->ID3.track)
-					tuple_associate_int(tuple, "track-number", atoi((char *)ttainfo->ID3.track));
+					tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi((char *)ttainfo->ID3.track));
 
 				if(ttainfo->ID3.genre)
-					tuple_associate_string(tuple, "genre", (gchar *) ttainfo->ID3.genre);
+					tuple_associate_string(tuple, FIELD_GENRE, NULL, (gchar *) ttainfo->ID3.genre);
 
 				if(ttainfo->ID3.comment)
-					tuple_associate_string(tuple, "comment", (gchar *) ttainfo->ID3.comment);
+					tuple_associate_string(tuple, FIELD_COMMENT, NULL, (gchar *) ttainfo->ID3.comment);
 			}
 			close_tta_file (ttainfo);
 		}
--- a/src/vorbis/vorbis.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/vorbis/vorbis.c	Sun Sep 09 23:52:19 2007 +0300
@@ -593,7 +593,7 @@
 {
     Tuple *tuple = get_song_tuple(filename);
 
-    *length = tuple_get_int(tuple, "length");
+    *length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     *title = tuple_formatter_make_title_string(tuple, vorbis_cfg.tag_override ?
                                             vorbis_cfg.tag_format : get_gentitle_format());
 
@@ -716,13 +716,13 @@
     return 2 * ch * samples;
 }
 
-static void _tuple_associate_string(Tuple *tuple, const gchar *field, const gchar *string)
+static void _tuple_associate_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string)
 {
-    gchar *str = str_to_utf8(string);
-
-    tuple_associate_string(tuple, field, str);
-
-    g_free(str);
+    if (string) {
+        gchar *str = str_to_utf8(string);
+        tuple_associate_string(tuple, nfield, field, str);
+        g_free(str);
+    }
 }
 
 /*
@@ -733,36 +733,34 @@
 {
     Tuple *tuple = NULL;
     vorbis_comment *comment;
-    gchar *realfn = NULL;
     tuple = tuple_new_from_filename(filename);
 
     /* Retrieve the length */
-    if (is_stream == FALSE)
-        tuple_associate_int(tuple, "length", ov_time_total(vorbisfile, -1) * 1000);
-    else
-        tuple_associate_int(tuple, "length", -1);
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL,
+        is_stream ? -1 : (ov_time_total(vorbisfile, -1) * 1000));
 
     if ((comment = ov_comment(vorbisfile, -1))) {
-        _tuple_associate_string(tuple, "title", vorbis_comment_query(comment, "title", 0));
-        _tuple_associate_string(tuple, "artist", vorbis_comment_query(comment, "artist", 0));
-        _tuple_associate_string(tuple, "album", vorbis_comment_query(comment, "album", 0));
-        _tuple_associate_string(tuple, "date", vorbis_comment_query(comment, "date", 0));
-        _tuple_associate_string(tuple, "genre", vorbis_comment_query(comment, "genre", 0));
-        _tuple_associate_string(tuple, "comment", vorbis_comment_query(comment, "comment", 0));
+        gchar *tmps;
+        _tuple_associate_string(tuple, FIELD_TITLE, NULL, vorbis_comment_query(comment, "title", 0));
+        _tuple_associate_string(tuple, FIELD_ARTIST, NULL, vorbis_comment_query(comment, "artist", 0));
+        _tuple_associate_string(tuple, FIELD_ALBUM, NULL, vorbis_comment_query(comment, "album", 0));
+        _tuple_associate_string(tuple, -1, "date", vorbis_comment_query(comment, "date", 0));
+        _tuple_associate_string(tuple, FIELD_GENRE, NULL, vorbis_comment_query(comment, "genre", 0));
+        _tuple_associate_string(tuple, FIELD_COMMENT, NULL, vorbis_comment_query(comment, "comment", 0));
 
-        if (vorbis_comment_query(comment, "tracknumber", 0) != NULL)
-            tuple_associate_int(tuple, "track-number", 
-                atoi(vorbis_comment_query(comment, "tracknumber", 0)));
+        if ((tmps = vorbis_comment_query(comment, "tracknumber", 0)) != NULL)
+            tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(tmps));
 
-        tuple_associate_string(tuple, "quality", "lossy");
+        tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
+
         if (comment && comment->vendor)
         {
             gchar *codec = g_strdup_printf("Ogg Vorbis [%s]", comment->vendor);
-            tuple_associate_string(tuple, "codec", codec);
+            tuple_associate_string(tuple, FIELD_CODEC, NULL, codec);
             g_free(codec);
         }
         else
-            tuple_associate_string(tuple, "codec", "Ogg Vorbis");
+            tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
     }
 
     return tuple;
@@ -822,8 +820,8 @@
     {
         gchar *old = displaytitle;
 
-        tuple_associate_string(input, "stream", tmp);
-        tuple_associate_string(input, "title", old);
+        tuple_associate_string(input, -1, "stream", tmp);
+        tuple_associate_string(input, FIELD_TITLE, NULL, old);
 
         displaytitle = tuple_formatter_process_string(input, "${?title:${title}}${?stream: (${stream})}");
 
--- a/src/vtx/vtx.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/vtx/vtx.c	Sun Sep 09 23:52:19 2007 +0300
@@ -98,20 +98,20 @@
   Tuple *out = tuple_new_from_filename(filename);
   gchar *string;
 
-  tuple_associate_string(out, "artist", in->hdr.author);
-  tuple_associate_string(out, "title", in->hdr.title);
+  tuple_associate_string(out, FIELD_ARTIST, NULL, in->hdr.author);
+  tuple_associate_string(out, FIELD_TITLE, NULL, in->hdr.title);
 
-  tuple_associate_int(out, "length", in->hdr.regdata_size / 14 * 1000 / 50);
+  tuple_associate_int(out, FIELD_LENGTH, NULL, in->hdr.regdata_size / 14 * 1000 / 50);
 
-  tuple_associate_string(out, "genre", (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes");
-  tuple_associate_string(out, "album", in->hdr.from);
-  tuple_associate_string(out, "game", in->hdr.from);
+  tuple_associate_string(out, FIELD_GENRE, NULL, (in->hdr.chiptype == AYEMU_AY)? "AY chiptunes" : "YM chiptunes");
+  tuple_associate_string(out, FIELD_ALBUM, NULL, in->hdr.from);
+  tuple_associate_string(out, -1, "game", in->hdr.from);
 
-  tuple_associate_string(out, "quality", "sequenced");
-  tuple_associate_string(out, "codec", in->hdr.tracker);
-  tuple_associate_string(out, "tracker", in->hdr.tracker);
+  tuple_associate_string(out, FIELD_QUALITY, NULL, "sequenced");
+  tuple_associate_string(out, FIELD_CODEC, NULL, in->hdr.tracker);
+  tuple_associate_string(out, -1, "tracker", in->hdr.tracker);
 
-  tuple_associate_int(out, "year", in->hdr.year);
+  tuple_associate_int(out, FIELD_YEAR, NULL, in->hdr.year);
 
   return out;
 }
@@ -299,7 +299,7 @@
     Tuple *ti = vtx_get_song_tuple_from_vtx(filename, &tmp);
 
     *title = tuple_formatter_process_string(ti, get_gentitle_format());
-    *length = tuple_get_int(ti, "length");
+    *length = tuple_get_int(ti, FIELD_LENGTH, NULL);
 
     ayemu_vtx_free (&tmp);
     tuple_free(ti);
--- a/src/wav/wav-sndfile.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/wav/wav-sndfile.c	Sun Sep 09 23:52:19 2007 +0300
@@ -108,14 +108,14 @@
 	realfn = g_filename_from_uri(filename, NULL, NULL);
 	tmp_sndfile = sf_open (realfn ? realfn : filename, SFM_READ, &tmp_sfinfo);
 	if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL)
-		tuple_associate_string(ti, "title", g_path_get_basename(realfn ? realfn : filename));
+		tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(realfn ? realfn : filename));
 	else
-		tuple_associate_string(ti, "title", sf_get_string(tmp_sndfile, SF_STR_TITLE));
+		tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE));
 
-	tuple_associate_string(ti, "artist", sf_get_string(tmp_sndfile, SF_STR_ARTIST));
-	tuple_associate_string(ti, "comment", sf_get_string(tmp_sndfile, SF_STR_COMMENT));
-	tuple_associate_string(ti, "date", sf_get_string(tmp_sndfile, SF_STR_DATE));
-	tuple_associate_string(ti, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
+	tuple_associate_string(ti, FIELD_ARTIST, NULL, sf_get_string(tmp_sndfile, SF_STR_ARTIST));
+	tuple_associate_string(ti, FIELD_COMMENT, NULL, sf_get_string(tmp_sndfile, SF_STR_COMMENT));
+	tuple_associate_string(ti, -1, "date", sf_get_string(tmp_sndfile, SF_STR_DATE));
+	tuple_associate_string(ti, -1, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
 
 	g_free(realfn); realfn = NULL;
 
@@ -126,7 +126,7 @@
 	tmp_sndfile = NULL;
 
 	if (tmp_sfinfo.samplerate > 0)
-		tuple_associate_int(ti, "length", (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
+		tuple_associate_int(ti, FIELD_LENGTH, NULL, (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
 
 	switch (tmp_sfinfo.format & SF_FORMAT_TYPEMASK)
 	{
@@ -283,12 +283,12 @@
 		g_string_append_printf(codec_gs, "%s", format);
 	codec = g_strdup(codec_gs->str);
 	g_string_free(codec_gs, TRUE);
-	tuple_associate_string(ti, "codec", codec);
+	tuple_associate_string(ti, FIELD_CODEC, NULL, codec);
 
 	if (lossy != 0)
-		tuple_associate_string(ti, "quality", "lossy");
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 	else
-		tuple_associate_string(ti, "quality", "lossless");
+		tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
 }
 
 static gchar *get_title(char *filename)
@@ -302,7 +302,7 @@
 	if (*title == '\0')
 	{
 		g_free(title);
-		title = g_strdup(tuple_get_string(tuple, "file-name"));
+		title = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
 	}
 
 	tuple_free(tuple);
--- a/src/wav/wav.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/wav/wav.c	Sun Sep 09 23:52:19 2007 +0300
@@ -193,14 +193,14 @@
 
     tuple = tuple_new_from_filename(filename);
 
-    tuple_associate_string(tuple, "codec", "RIFF/WAV Audio (ADPCM)");
-    tuple_associate_string(tuple, "quality", "lossless");
+    tuple_associate_string(tuple, FIELD_CODEC, NULL, "RIFF/WAV Audio (ADPCM)");
+    tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossless");
 
     title = tuple_formatter_make_title_string(tuple, get_gentitle_format());
     if (*title == '\0')
     {
         g_free(title);
-        title = g_strdup(tuple_get_string(tuple, "file-name"));
+        title = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
     }
 
     tuple_free(tuple);
--- a/src/wma/wma.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/wma/wma.c	Sun Sep 09 23:52:19 2007 +0300
@@ -243,6 +243,18 @@
     return ext;
 }
 
+static void _assoc_string(Tuple *tuple, const gint nfield, const gchar *str)
+{
+    if (strlen(str) > 0)
+        tuple_associate_string(tuple, nfield, NULL, str);
+}
+
+static void _assoc_int(Tuple *tuple, const gint nfield, const gint val)
+{
+    if (val > 0)
+        tuple_associate_int(tuple, nfield, NULL, val);
+}
+
 static Tuple *wma_get_song_tuple(gchar * filename)
 {
     Tuple *ti = tuple_new_from_filename(filename);
@@ -251,27 +263,19 @@
     if (av_open_input_file(&in, str_twenty_to_space(filename), NULL, 0, NULL) < 0)
 	return NULL;
 
-    tuple_associate_string(ti, "codec", "Windows Media Audio (WMA)");
-    tuple_associate_string(ti, "quality", "lossy");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Windows Media Audio (WMA)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
     av_find_stream_info(in);
 
-    if(strlen(in->title))
-        tuple_associate_string(ti, "title", in->title);
-    if(strlen(in->author))
-        tuple_associate_string(ti, "artist", in->author);
-    if(strlen(in->album))
-        tuple_associate_string(ti, "album", in->album);
-    if(strlen(in->comment))
-        tuple_associate_string(ti, "comment", in->comment);
-    if(strlen(in->genre))
-        tuple_associate_string(ti, "genre", in->genre);
-    if(in->year > 0)
-        tuple_associate_int(ti, "year", in->year);
-    if(in->track > 0)
-        tuple_associate_int(ti, "track", in->track);
-    if (in->duration)
-        tuple_associate_int(ti, "length", in->duration / 1000);
+    _assoc_string(ti, FIELD_TITLE, in->title);
+    _assoc_string(ti, FIELD_ARTIST, in->author);
+    _assoc_string(ti, FIELD_ALBUM, in->album);
+    _assoc_string(ti, FIELD_COMMENT, in->comment);
+    _assoc_string(ti, FIELD_GENRE, in->genre);
+    _assoc_int(ti, FIELD_YEAR, in->year);
+    _assoc_int(ti, FIELD_TRACK_NUMBER, in->track);
+    _assoc_int(ti, FIELD_LENGTH, in->duration / 1000);
 
     av_close_input_file(in);
 
@@ -283,25 +287,17 @@
     gchar *ret = NULL;
     Tuple *ti = tuple_new_from_filename(filename);
 
-    tuple_associate_string(ti, "codec", "Windows Media Audio (WMA)");
-    tuple_associate_string(ti, "quality", "lossy");
+    tuple_associate_string(ti, FIELD_CODEC, NULL, "Windows Media Audio (WMA)");
+    tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
 
-    if(strlen(in->title))
-        tuple_associate_string(ti, "title", in->title);
-    if(strlen(in->author))
-        tuple_associate_string(ti, "artist", in->author);
-    if(strlen(in->album))
-        tuple_associate_string(ti, "album", in->album);
-    if(strlen(in->comment))
-        tuple_associate_string(ti, "comment", in->comment);
-    if(strlen(in->genre))
-        tuple_associate_string(ti, "genre", in->genre);
-    if(in->year > 0)
-        tuple_associate_int(ti, "year", in->year);
-    if(in->track > 0)
-        tuple_associate_int(ti, "track", in->track);
-    if (in->duration)
-        tuple_associate_int(ti, "length", in->duration / 1000);
+    _assoc_string(ti, FIELD_TITLE, in->title);
+    _assoc_string(ti, FIELD_ARTIST, in->author);
+    _assoc_string(ti, FIELD_ALBUM, in->album);
+    _assoc_string(ti, FIELD_COMMENT, in->comment);
+    _assoc_string(ti, FIELD_GENRE, in->genre);
+    _assoc_int(ti, FIELD_YEAR, in->year);
+    _assoc_int(ti, FIELD_TRACK_NUMBER, in->track);
+    _assoc_int(ti, FIELD_LENGTH, in->duration / 1000);
     
     ret = tuple_formatter_make_title_string(ti, get_gentitle_format());
 
@@ -323,7 +319,7 @@
     if (tuple == NULL)
         return;
 
-    (*len_real) = tuple_get_int(tuple, "length");
+    (*len_real) = tuple_get_int(tuple, FIELD_LENGTH, NULL);
     (*title_real) = tuple_formatter_make_title_string(tuple, get_gentitle_format());
 }
 
--- a/src/xspf/xspf.c	Sun Sep 09 13:50:27 2007 -0700
+++ b/src/xspf/xspf.c	Sun Sep 09 23:52:19 2007 +0300
@@ -53,7 +53,7 @@
 } xspf_compare;
 
 typedef struct {
-    gchar *tupleName;
+    gint tupleField;
     gchar *xspfName;
     TupleValueType type;
     gboolean isMeta;
@@ -62,17 +62,17 @@
 
 
 static const xspf_entry_t xspf_entries[] = {
-    { "title",          "title",        TUPLE_STRING,   FALSE,  CMP_DEF },
-    { "artist",         "creator",      TUPLE_STRING,   FALSE,  CMP_DEF },
-    { "comment",        "annotation",   TUPLE_STRING,   FALSE,  CMP_DEF },
-    { "album",          "album",        TUPLE_STRING,   FALSE,  CMP_DEF },
-    { "track-number",   "trackNum",     TUPLE_INT,      FALSE,  CMP_DEF },
-    { "length",         "duration",     TUPLE_INT,      FALSE,  CMP_GT },
+    { FIELD_TITLE,        "title",        TUPLE_STRING,   FALSE,  CMP_DEF },
+    { FIELD_ARTIST,       "creator",      TUPLE_STRING,   FALSE,  CMP_DEF },
+    { FIELD_COMMENT,      "annotation",   TUPLE_STRING,   FALSE,  CMP_DEF },
+    { FIELD_ALBUM,        "album",        TUPLE_STRING,   FALSE,  CMP_DEF },
+    { FIELD_TRACK_NUMBER, "trackNum",     TUPLE_INT,      FALSE,  CMP_DEF },
+    { FIELD_LENGTH,       "duration",     TUPLE_INT,      FALSE,  CMP_GT },
 
-    { "year",           "year",         TUPLE_INT,      TRUE,   CMP_DEF },
-    { "date",           "date",         TUPLE_STRING,   TRUE,   CMP_DEF },
-    { "genre",          "genre",        TUPLE_STRING,   TRUE,   CMP_DEF },
-    { "formatter",      "formatter",    TUPLE_STRING,   TRUE,   CMP_DEF },
+    { FIELD_YEAR,         "year",         TUPLE_INT,      TRUE,   CMP_DEF },
+    { FIELD_DATE,         "date",         TUPLE_STRING,   TRUE,   CMP_DEF },
+    { FIELD_GENRE,        "genre",        TUPLE_STRING,   TRUE,   CMP_DEF },
+    { FIELD_FORMATTER,    "formatter",    TUPLE_STRING,   TRUE,   CMP_DEF },
 };
 
 static const gint xspf_nentries = (sizeof(xspf_entries) / sizeof(xspf_entry_t));
@@ -124,8 +124,8 @@
 
 
     tuple = tuple_new();
-    tuple_associate_int(tuple, "length", -1);
-    tuple_associate_int(tuple, "mtime", -1);
+    tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1);
+    tuple_associate_int(tuple, FIELD_MTIME, NULL, -1);
 
 
     for (nptr = track->children; nptr != NULL; nptr = nptr->next) {
@@ -163,11 +163,11 @@
                     xmlChar *str = xmlNodeGetContent(nptr);
                     switch (xspf_entries[i].type) {
                         case TUPLE_STRING:
-                            tuple_associate_string(tuple, xspf_entries[i].tupleName, (gchar *)str);
+                            tuple_associate_string(tuple, xspf_entries[i].tupleField, NULL, (gchar *)str);
                             break;
                         
                         case TUPLE_INT:
-                            tuple_associate_int(tuple, xspf_entries[i].tupleName, atol((char *)str));
+                            tuple_associate_int(tuple, xspf_entries[i].tupleField, NULL, atol((char *)str));
                             break;
                         
                         default:
@@ -187,18 +187,18 @@
         gchar *scratch;
 
         scratch = g_path_get_basename(location);
-        tuple_associate_string(tuple, "file-name", scratch);
+        tuple_associate_string(tuple, FIELD_FILE_NAME, NULL, scratch);
         g_free(scratch);
 
         scratch = g_path_get_dirname(location);
-        tuple_associate_string(tuple, "file-path", scratch);
+        tuple_associate_string(tuple, FIELD_FILE_PATH, NULL, scratch);
         g_free(scratch);
 
-        tuple_associate_string(tuple, "file-ext", strrchr(location, '.'));
+        tuple_associate_string(tuple, FIELD_FILE_EXT, NULL, strrchr(location, '.'));
 
 #ifdef DEBUG
-        printf("xspf: tuple->file_name = %s\n", tuple_get_string(tuple, "file-name"));
-        printf("xspf: tuple->file_path = %s\n", tuple_get_string(tuple, "file-path"));
+        printf("xspf: tuple->file_name = %s\n", tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
+        printf("xspf: tuple->file_path = %s\n", tuple_get_string(tuple, FIELD_FILE_PATH, NULL));
 #endif
         // add file to playlist
         uri = g_filename_to_uri(location, NULL, NULL);
@@ -518,7 +518,7 @@
                 
                 switch (xs->type) {
                     case TUPLE_STRING:
-                        scratch = tuple_get_string(entry->tuple, xs->tupleName);
+                        scratch = tuple_get_string(entry->tuple, xs->tupleField, NULL);
                         switch (xs->compare) {
                             case CMP_DEF: isOK = (scratch != NULL); break;
                             case CMP_NULL: isOK = (scratch == NULL); break;
@@ -528,7 +528,7 @@
                         break;
                     
                     case TUPLE_INT:
-                        scratchi = tuple_get_int(entry->tuple, xs->tupleName);
+                        scratchi = tuple_get_int(entry->tuple, xs->tupleField, NULL);
                         switch (xs->compare) {
                             case CMP_DEF: isOK = (scratchi != 0); break;
                             case CMP_GT:  isOK = (scratchi > 0); break;
@@ -544,7 +544,8 @@
             }
 
             /* Write mtime unconditionally to support staticlist */
-            xspf_add_node(track, TUPLE_INT, TRUE, "mtime", NULL, tuple_get_int(entry->tuple, "mtime"));
+            xspf_add_node(track, TUPLE_INT, TRUE, "mtime", NULL,
+                tuple_get_int(entry->tuple, FIELD_MTIME, NULL));
         } else {
 
             if (entry->title != NULL && g_utf8_validate(entry->title, -1, NULL))