[Flac-dev] reading vorbis comments with FLAC++?
Josh Coalson
xflac at yahoo.com
Tue Nov 11 15:52:20 PST 2003
--- Joshua Kwan <joshk at triplehelix.org> wrote:
> Well, I'm quite frankly stumped. I'm writing a program that recurses
> into directories and reads (among others) FLAC files and should be
> able
> to read the vorbis comments ARTIST and TITLE from the file.
>
> A while back, I was popen()ing to metaflac, because I didn't want to
> mess with libFLAC. But now, it's the weekend, so I can mess around
> with
> this. Here's the code in question:
...
> When I run this code, I get a SEGV during get_comment because
> object_->data.vorbis_comment.comments is junk. Must I initialize it
> somewhere? Note that vc.get_num_comments returns 14, which I imagine
> is
> a correct number. The documentation isn't overly clear about how this
> works
> and it would be cooler if some basic examples could be provided.
>
> Thanks in advance for any help that can be provided. Excuse my
> ignorance! :(
it's in the API docs; here's one link:
http://flac.sourceforge.net/api/group__flac__metadata__level1.html#_details
The C++ interface is a little simpler:
FLAC::Metadata::SimpleIterator it;
if (it.is_valid()) {
if (it.init(filename, true, true)) {
FLAC::Metadata::VorbisComment *vc = 0;
do {
if (it.get_block_type() ==
::FLAC__METADATA_TYPE_VORBIS_COMMENT) {
vc =
dynamic_cast<FLAC::Metadata::VorbisComment*>(it.get_block());
assert(0 != vc);
}
} while (!vc && it.next());
//use vc
delete vc;
}
}
maybe I should add a shorthand function similar to
flac__metadata_get_streaminfo()
Josh
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
More information about the Flac-dev
mailing list