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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#pragma once
#include <QDateTime>
#include "audio/types.h"
#include "track/albuminfo.h"
#include "track/trackinfo.h"
namespace mixxx {
namespace audio {
class StreamInfo;
} // namespace audio
class TrackMetadata final {
// Audio properties
// - read-only
// - stored in file tags
// - adjusted when opening the audio stream (if available)
PROPERTY_SET_BYVAL_GET_BYREF(audio::ChannelCount, channels, ChannelCount)
PROPERTY_SET_BYVAL_GET_BYREF(audio::SampleRate, sampleRate, SampleRate)
PROPERTY_SET_BYVAL_GET_BYREF(audio::Bitrate, bitrate, Bitrate)
PROPERTY_SET_BYVAL_GET_BYREF(Duration, duration, Duration)
// Track properties
// - read-write
// - stored in file tags
PROPERTY_SET_BYVAL_GET_BYREF(AlbumInfo, albumInfo, AlbumInfo)
PROPERTY_SET_BYVAL_GET_BYREF(TrackInfo, trackInfo, TrackInfo)
public:
TrackMetadata() = default;
TrackMetadata(TrackMetadata&&) = default;
TrackMetadata(const TrackMetadata&) = default;
/*non-virtual*/ ~TrackMetadata() = default;
TrackMetadata& operator=(TrackMetadata&&) = default;
TrackMetadata& operator=(const TrackMetadata&) = default;
bool updateAudioPropertiesFromStream(
const audio::StreamInfo& streamInfo);
// Adjusts floating-point values to match their string representation
// in file tags to account for rounding errors.
void normalizeBeforeExport();
// Returns true if the current metadata differs from the imported metadata
// and needs to be exported. A result of false indicates that no export
// is needed.
// NOTE: Some tag formats like ID3v1/v2 only support integer precision
// for storing bpm values. To avoid re-exporting unmodified track metadata
// with fractional bpm values over and over again the comparison of bpm
// values should be restricted to integer.
bool anyFileTagsModified(
const TrackMetadata& importedFromFile,
Bpm::Comparison cmpBpm = Bpm::Comparison::Default) const;
// Parse an format date/time values according to ISO 8601
static QDate parseDate(QString str) {
return QDate::fromString(str.trimmed().replace(" ", ""), Qt::ISODate);
}
static QDateTime parseDateTime(QString str) {
return QDateTime::fromString(str.trimmed().replace(" ", ""), Qt::ISODate);
}
static QString formatDate(QDate date) {
return date.toString(Qt::ISODate);
}
static QString formatDateTime(QDateTime dateTime) {
return dateTime.toString(Qt::ISODate);
}
// Parse and format the calendar year (for simplified display)
static constexpr int kCalendarYearInvalid = 0;
static int parseCalendarYear(QString year, bool* pValid = nullptr);
static QString formatCalendarYear(QString year, bool* pValid = nullptr);
static QString reformatYear(QString year);
};
bool operator==(const TrackMetadata& lhs, const TrackMetadata& rhs);
inline bool operator!=(const TrackMetadata& lhs, const TrackMetadata& rhs) {
return !(lhs == rhs);
}
QDebug operator<<(QDebug dbg, const TrackMetadata& arg);
} // namespace mixxx
Q_DECLARE_METATYPE(mixxx::TrackMetadata)
|