82 case 24:
return pulldown ? fps23976 : fps24;
83 case 25:
return fps25;
84 case 30:
return pulldown ? (drop ? fps2997drop : fps2997)
85 : (drop ? fps30drop : fps30);
86 case 60:
return drop ? fps60drop : fps60;
102 double getEffectiveRate()
const {
return pulldown ? (double) base / 1.001 : (
double) base; }
116 const auto tie = [] (
const FrameRate& x) {
return std::tie (x.base, x.drop, x.pulldown); };
117 return tie (*
this) == tie (other);
121 bool operator!= (
const FrameRate& other)
const {
return ! (*
this == other); }
137 case fpsUnknown:
break;
143 template <
typename Member,
typename Value>
144 FrameRate with (Member&& member, Value&& value)
const
147 copy.*member = std::forward<Value> (value);
152 bool drop =
false, pulldown =
false;
169 const auto tie = [] (
auto& x) {
return std::tie (x.numerator, x.denominator); };
170 return tie (*
this) == tie (other);
175 return ! operator== (other);
191 bool operator== (
const LoopPoints& other)
const
193 const auto tie = [] (
auto& x) {
return std::tie (x.ppqStart, x.ppqEnd); };
194 return tie (*
this) == tie (other);
197 bool operator!= (
const LoopPoints& other)
const
199 return ! operator== (other);
216 int timeSigNumerator = 4;
219 int timeSigDenominator = 4;
222 int64 timeInSamples = 0;
224 double timeInSeconds = 0;
227 double editOriginTime = 0;
230 double ppqPosition = 0;
240 double ppqPositionOfLastBarStart = 0;
246 bool isPlaying =
false;
252 bool isRecording =
false;
258 double ppqLoopStart = 0;
264 double ppqLoopEnd = 0;
267 bool isLooping =
false;
274 return std::tie (i.timeInSamples,
277 i.ppqPositionOfLastBarStart,
283 i.timeSigDenominator,
289 return tie (*
this) == tie (other);
294 return ! operator== (other);
297 void resetToDefault()
299 *
this = CurrentPositionInfo{};
399 void setIsPlaying (
bool isPlayingIn) { setFlag (flagIsPlaying, isPlayingIn); }
408 void setIsRecording (
bool isRecordingIn) { setFlag (flagIsRecording, isRecordingIn); }
414 void setIsLooping (
bool isLoopingIn) { setFlag (flagIsLooping, isLoopingIn); }
416 bool operator== (
const PositionInfo& other)
const noexcept
420 return std::make_tuple (i.getTimeInSamples(),
421 i.getTimeInSeconds(),
423 i.getEditOriginTime(),
424 i.getPpqPositionOfLastBarStart(),
427 i.getTimeSignature(),
436 return tie (*
this) == tie (other);
439 bool operator!= (
const PositionInfo& other)
const noexcept
441 return ! operator== (other);
445 bool getFlag (int64_t flagToCheck)
const
447 return (flagToCheck & flags) != 0;
450 void setFlag (int64_t flagToCheck,
bool value)
452 flags = (value ? flags | flagToCheck : flags & ~flagToCheck);
455 template <
typename Value>
456 Optional<Value> getOptional (int64_t flagToCheck, Value value)
const
458 return getFlag (flagToCheck) ? makeOptional (std::move (value)) : nullopt;
461 template <
typename Value>
462 void setOptional (int64_t flagToCheck, Value& value, Optional<Value> opt)
467 setFlag (flagToCheck, opt.hasValue());
472 flagTimeSignature = 1 << 0,
473 flagLoopPoints = 1 << 1,
474 flagFrameRate = 1 << 2,
475 flagTimeSeconds = 1 << 3,
476 flagLastBarStartPpq = 1 << 4,
477 flagPpqPosition = 1 << 5,
478 flagOriginTime = 1 << 6,
480 flagTimeSamples = 1 << 8,
481 flagBarCount = 1 << 9,
482 flagHostTimeNs = 1 << 10,
483 flagIsPlaying = 1 << 11,
484 flagIsRecording = 1 << 12,
485 flagIsLooping = 1 << 13
488 TimeSignature timeSignature;
489 LoopPoints loopPoints;
490 FrameRate frame = FrameRateType::fps23976;
491 double timeInSeconds = 0.0;
492 double lastBarStartPpq = 0.0;
493 double positionPpq = 0.0;
494 double originTime = 0.0;
495 double tempoBpm = 0.0;
496 int64_t timeInSamples = 0;
497 int64_t barCount = 0;
498 uint64_t hostTimeNs = 0;
515 [[deprecated (
"Use getPosition instead. Not all hosts are able to provide all time position information; getPosition differentiates clearly between set and unset fields.")]]
518 if (
const auto pos = getPosition())
520 result.resetToDefault();
522 if (
const auto sig = pos->getTimeSignature())
528 if (
const auto loop = pos->getLoopPoints())
534 if (
const auto frame = pos->getFrameRate())
537 if (
const auto timeInSeconds = pos->getTimeInSeconds())
540 if (
const auto lastBarStartPpq = pos->getPpqPositionOfLastBarStart())
543 if (
const auto ppqPosition = pos->getPpqPosition())
546 if (
const auto originTime = pos->getEditOriginTime())
549 if (
const auto bpm = pos->getBpm())
552 if (
const auto timeInSamples = pos->getTimeInSamples())
581 virtual bool canControlTransport();
584 virtual void transportPlay (
bool shouldStartPlaying);
587 virtual void transportRecord (
bool shouldStartRecording);
590 virtual void transportRewind();
FrameRate(FrameRateType type)
FrameRate withPullDown(bool x=true) const
FrameRate withDrop(bool x=true) const
FrameRateType getType() const
FrameRate withBaseRate(int x) const
double getEffectiveRate() const
void setBpm(Optional< double > bpmIn)
void setIsRecording(bool isRecordingIn)
void setTimeInSamples(Optional< int64_t > timeInSamplesIn)
bool getIsRecording() const
Optional< double > getBpm() const
Optional< int64_t > getTimeInSamples() const
void setHostTimeNs(Optional< uint64_t > hostTimeNsIn)
void setLoopPoints(Optional< LoopPoints > loopPointsIn)
Optional< double > getPpqPositionOfLastBarStart() const
void setPpqPositionOfLastBarStart(Optional< double > positionIn)
void setBarCount(Optional< int64_t > barCountIn)
void setPpqPosition(Optional< double > ppqPositionIn)
void setTimeInSeconds(Optional< double > timeInSecondsIn)
Optional< uint64_t > getHostTimeNs() const
Optional< double > getPpqPosition() const
void setIsLooping(bool isLoopingIn)
Optional< TimeSignature > getTimeSignature() const
Optional< LoopPoints > getLoopPoints() const
Optional< double > getTimeInSeconds() const
bool getIsPlaying() const
void setTimeSignature(Optional< TimeSignature > timeSignatureIn)
void setFrameRate(Optional< FrameRate > frameRateIn)
void setEditOriginTime(Optional< double > editOriginTimeIn)
void setIsPlaying(bool isPlayingIn)
Optional< double > getEditOriginTime() const
Optional< int64_t > getBarCount() const
Optional< FrameRate > getFrameRate() const
bool getIsLooping() const
virtual Optional< PositionInfo > getPosition() const =0
bool getCurrentPosition(CurrentPositionInfo &result)
double ppqPositionOfLastBarStart