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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#pragma once
#include <QColor>
#include <QMutex>
#include <QObject>
#include "track/cueinfo.h"
#include "track/trackid.h"
#include "util/audiosignal.h"
#include "util/color/rgbcolor.h"
#include "util/memory.h"
class CuePosition;
class CueDAO;
class Track;
class Cue : public QObject {
Q_OBJECT
public:
static constexpr double kNoPosition = -1.0;
static constexpr int kNoHotCue = -1;
Cue();
Cue(
const mixxx::CueInfo& cueInfo,
mixxx::audio::SampleRate sampleRate);
~Cue() override = default;
bool isDirty() const;
int getId() const;
TrackId getTrackId() const;
mixxx::CueType getType() const;
void setType(mixxx::CueType type);
double getPosition() const;
void setStartPosition(
double samplePosition = kNoPosition);
void setEndPosition(
double samplePosition = kNoPosition);
double getLength() const;
int getHotCue() const;
void setHotCue(
int hotCue = kNoHotCue);
QString getLabel() const;
void setLabel(
QString label = QString());
mixxx::RgbColor getColor() const;
void setColor(mixxx::RgbColor color);
double getEndPosition() const;
mixxx::CueInfo getCueInfo(
mixxx::audio::SampleRate sampleRate) const;
signals:
void updated();
private:
Cue(
int id,
TrackId trackId,
mixxx::CueType type,
double position,
double length,
int hotCue,
QString label,
mixxx::RgbColor color);
void setDirty(bool dirty);
void setId(int id);
void setTrackId(TrackId trackId);
mutable QMutex m_mutex;
bool m_bDirty;
int m_iId;
TrackId m_trackId;
mixxx::CueType m_type;
double m_sampleStartPosition;
double m_sampleEndPosition;
int m_iHotCue;
QString m_label;
mixxx::RgbColor m_color;
friend class Track;
friend class CueDAO;
};
class CuePointer : public std::shared_ptr<Cue> {
public:
CuePointer() = default;
explicit CuePointer(Cue* pCue)
: std::shared_ptr<Cue>(pCue, deleteLater) {
}
private:
static void deleteLater(Cue* pCue);
};
class CuePosition {
public:
CuePosition()
: m_position(0.0) {
}
CuePosition(double position)
: m_position(position) {
}
double getPosition() const {
return m_position;
}
void setPosition(double position) {
m_position = position;
}
void set(double position) {
m_position = position;
}
void reset() {
m_position = 0.0;
}
private:
double m_position;
};
bool operator==(const CuePosition& lhs, const CuePosition& rhs);
inline bool operator!=(const CuePosition& lhs, const CuePosition& rhs) {
return !(lhs == rhs);
}
inline QDebug operator<<(QDebug dbg, const CuePosition& arg) {
return dbg << "position =" << arg.getPosition();
}
|