91 = tr(
"Simple counter");
93 = tr(
"Cyclical counter");
95 = tr(
"Cyclical two-level counter (bar/beat)");
97 = tr(
"Audio sample frame number");
99 = tr(
"Time in seconds");
101 = tr(
"Duration to the following item");
103 = tr(
"Tempo (bpm) based on duration to following item");
105 = tr(
"Duration since the previous item");
107 = tr(
"Tempo (bpm) based on duration since previous item");
109 = tr(
"Same as the nearest previous item");
111 = tr(
"Value extracted from the item's label (where possible)");
154 template <
typename Po
intType>
155 void label(PointType &newPoint, PointType *prevPoint = 0) {
163 newPoint.label = tr(
"%1").arg(newPoint.frame);
165 float value = getValueFor<PointType>(newPoint, prevPoint);
167 prevPoint->label = QString(
"%1").arg(value);
169 newPoint.label = QString(
"%1").arg(value);
174 template <
typename Po
intType>
182 (&model, tr(
"Label Points"));
184 PointType prevPoint(0);
186 for (i = pl.begin(); i != pl.end(); ++i) {
191 if (s.isEmpty() || !s.contains(i->frame)) {
204 if (i != pl.begin()) {
206 label<PointType>(p, &prevPoint);
211 label<PointType>(p, &prevPoint);
221 template <
typename Po
intType>
222 void setValue(PointType &newPoint, PointType *prevPoint = 0) {
225 std::cerr <<
"ERROR: Labeller::setValue: Previous point required but not provided" << std::endl;
227 newPoint.value = prevPoint->value;
230 float value = getValueFor<PointType>(newPoint, prevPoint);
232 prevPoint->value = value;
234 newPoint.value = value;
252 template <
typename Po
intType>
275 value = newPoint.frame;
280 std::cerr <<
"ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl;
282 value = float(newPoint.frame) / float(
m_rate);
291 std::cerr <<
"ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl;
292 }
else if (!prevPoint) {
293 std::cerr <<
"ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl;
295 int f0 = prevPoint->frame, f1 = newPoint.frame;
298 value = float(f1 - f0) /
m_rate;
301 value = (60.f *
m_rate) / (f1 - f0);
314 if (newPoint.label !=
"") {
316 value = atof(newPoint.label.toLocal8Bit());
std::multiset< PointType, typename PointType::OrderComparator > PointList
int getCounterCycleSize() const
A selection object simply represents a range in time, via start and end frame.
void setCounterCycleSize(int s)
void setType(ValueType type)
virtual void addPoint(const PointType &point)
Add a point.
std::map< ValueType, QString > TypeNameMap
Command to add or remove a series of points, with undo.
Labeller(const Labeller &l)
virtual const PointList & getPoints() const
Get all points.
int getCounterValue() const
Selection getContainingSelection(int frame, bool defaultToFollowing) const
Return the selection that contains a given frame.
bool requiresPrevPoint() const
bool actingOnPrevPoint() const
void setCounterValue(int v)
void label(PointType &newPoint, PointType *prevPoint=0)
Labeller(ValueType type=ValueNone)
float getValueFor(PointType &newPoint, PointType *prevPoint)
void labelAll(SparseModel< PointType > &model, MultiSelection *ms)
TypeNameMap getTypeNames() const
virtual void deletePoint(const PointType &point)
Remove a point.
int getSecondLevelCounterValue() const
ValueType getType() const
Model containing sparse data (points with some properties).
void setValue(PointType &newPoint, PointType *prevPoint=0)
void setSecondLevelCounterValue(int v)
void setSampleRate(float rate)