forked from spotify/echoprint-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetadata.cxx
More file actions
33 lines (27 loc) · 1.07 KB
/
Metadata.cxx
File metadata and controls
33 lines (27 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// echoprint-codegen
// Copyright 2011 The Echo Nest Corporation. All rights reserved.
//
#include "Metadata.h"
#include <fileref.h>
#include <tag.h>
#include <iostream>
Metadata::Metadata(const string& file) : _Filename(file), _Artist(""), _Album(""), _Title(""), _Genre(""), _Bitrate(0), _SampleRate(0), _Seconds(0) {
if (file != "stdin") {
// TODO: Consider removing the path from the filename -- not sure if we can do this in a platform-independent way.
TagLib::FileRef f(_Filename.c_str());
TagLib::Tag* tag = f.isNull() ? NULL : f.tag();
if (tag != NULL) {
_Artist = tag->artist().to8Bit(true);
_Album = tag->album().to8Bit(true);
_Title = tag->title().to8Bit(true);
_Genre = tag->genre().to8Bit(true);
}
TagLib::AudioProperties* properties = f.isNull() ? NULL : f.audioProperties();
if (properties != NULL) {
_Bitrate = properties->bitrate();
_SampleRate = properties->sampleRate();
_Seconds = properties->length();
}
}
}