Mercurial > hg > svcore
diff data/model/Labeller.h @ 355:d02f71281639
* Fix #1841095 tapping time instant gives wrong time in aligned track
* Fix #1815654 source tidying: Labeller
* Fix (I hope) #1849999 Time value graphs one instant out
author | Chris Cannam |
---|---|
date | Thu, 13 Dec 2007 17:14:33 +0000 |
parents | b1a3f7bc035d |
children | bc4712c7d269 |
line wrap: on
line diff
--- a/data/model/Labeller.h Tue Dec 11 14:58:29 2007 +0000 +++ b/data/model/Labeller.h Thu Dec 13 17:14:33 2007 +0000 @@ -36,8 +36,10 @@ ValueFromTwoLevelCounter, ValueFromFrameNumber, ValueFromRealTime, - ValueFromRealTimeDifference, - ValueFromTempo, + ValueFromDurationFromPrevious, + ValueFromDurationToNext, + ValueFromTempoFromPrevious, + ValueFromTempoToNext, ValueFromExistingNeighbour, ValueFromLabel }; @@ -59,7 +61,7 @@ // 4. re-label a set of points that have already been added to a // model - Labeller(ValueType type) : + Labeller(ValueType type = ValueNone) : m_type(type), m_counter(1), m_counter2(1), @@ -81,16 +83,30 @@ typedef std::map<ValueType, QString> TypeNameMap; TypeNameMap getTypeNames() const { TypeNameMap m; - m[ValueNone] = tr("No numbering"); - m[ValueFromSimpleCounter] = tr("Simple counter"); - m[ValueFromCyclicalCounter] = tr("Cyclical counter"); - m[ValueFromTwoLevelCounter] = tr("Cyclical two-level counter (bar/beat)"); - m[ValueFromFrameNumber] = tr("Audio sample frame number"); - m[ValueFromRealTime] = tr("Time in seconds"); - m[ValueFromRealTimeDifference] = tr("Duration to the following item"); - m[ValueFromTempo] = tr("Tempo (bpm) based on duration to following item"); - m[ValueFromExistingNeighbour] = tr("Same as the nearest previous item"); - m[ValueFromLabel] = tr("Value extracted from the item's label (where possible)"); + m[ValueNone] + = tr("No numbering"); + m[ValueFromSimpleCounter] + = tr("Simple counter"); + m[ValueFromCyclicalCounter] + = tr("Cyclical counter"); + m[ValueFromTwoLevelCounter] + = tr("Cyclical two-level counter (bar/beat)"); + m[ValueFromFrameNumber] + = tr("Audio sample frame number"); + m[ValueFromRealTime] + = tr("Time in seconds"); + m[ValueFromDurationToNext] + = tr("Duration to the following item"); + m[ValueFromTempoToNext] + = tr("Tempo (bpm) based on duration to following item"); + m[ValueFromDurationFromPrevious] + = tr("Duration since the previous item"); + m[ValueFromTempoFromPrevious] + = tr("Tempo (bpm) based on duration since previous item"); + m[ValueFromExistingNeighbour] + = tr("Same as the nearest previous item"); + m[ValueFromLabel] + = tr("Value extracted from the item's label (where possible)"); return m; } @@ -212,9 +228,16 @@ } } + bool requiresPrevPoint() const { + return (m_type == ValueFromDurationFromPrevious || + m_type == ValueFromDurationToNext || + m_type == ValueFromTempoFromPrevious || + m_type == ValueFromDurationToNext); + } + bool actingOnPrevPoint() const { - return (m_type == ValueFromRealTimeDifference || - m_type == ValueFromTempo); + return (m_type == ValueFromDurationToNext || + m_type == ValueFromTempoToNext); } protected: @@ -252,15 +275,18 @@ } break; - case ValueFromRealTimeDifference: - case ValueFromTempo: + case ValueFromDurationToNext: + case ValueFromTempoToNext: + case ValueFromDurationFromPrevious: + case ValueFromTempoFromPrevious: if (m_rate == 0.f) { std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl; } else if (!prevPoint) { std::cerr << "ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl; } else { size_t f0 = prevPoint->frame, f1 = newPoint.frame; - if (m_type == ValueFromRealTimeDifference) { + if (m_type == ValueFromDurationToNext || + m_type == ValueFromDurationFromPrevious) { value = float(f1 - f0) / m_rate; } else { if (f1 > f0) {