OggVorbisReader and metadata


I've seen that the OggVorbis writer does write metadata info into the file, but that the reader doesn't read it at the moment. Here's what I'd suggest (starting from line 124 in juce_OggVorbisAudioFormat.cpp; I've put comments around the new part)

if (err == 0)
            vorbis_info* info = ov_info (&ovFile, -1);
            //begin with metadata
            vorbis_comment* comment = ov_comment(&ovFile,-1);
            char *tagname = vorbis_comment_query(comment,"ENCODER",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"TITLE",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"ARTIST",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"ALBUM",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"COMMENT",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"DATE",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"GENRE",0);
            if (tagname)
            tagname = vorbis_comment_query(comment,"TRACKNUMBER",0);
            if (tagname)
            //end with metadata
            lengthInSamples = (uint32) ov_pcm_total (&ovFile, -1);
            numChannels = (unsigned int) info->channels;
            bitsPerSample = 16;
            sampleRate = info->rate;

            reservoir.setSize ((int) numChannels,
                               (int) jmin (lengthInSamples, (int64) reservoir.getNumSamples()));

The "count" variable in vorbis_comment_query is a bit odd imho...  it specifies how many results one would like to obtain (there could be more than one artist, for instance) but it has to be set to 0 when actually wants 1, due to (what I think is) a bug in the ov code...


Thanks, good request! I've done a cleaner implementation of it, but haven't tested it, so let me know if it doesn't work!


Thanks, looking good!