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;
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;
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;
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
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;
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();
More descriptive frame rate type.
FrameRate(FrameRateType type)
Creates a FrameRate instance from a FrameRateType.
bool isPullDown() const
Returns true if the effective framerate is actually equal to the base rate divided by 1....
FrameRate withPullDown(bool x=true) const
Returns a copy of this object with pulldown enabled or disabled, as specified.
FrameRate withDrop(bool x=true) const
Returns a copy of this object with drop frames enabled or disabled, as specified.
FrameRateType getType() const
Gets the FrameRateType that matches the state of this FrameRate.
FrameRate withBaseRate(int x) const
Returns a copy of this object with the specified base rate.
int getBaseRate() const
Returns the plain rate, without taking pulldown into account.
bool isDrop() const
Returns true if drop-frame timecode is in use.
double getEffectiveRate() const
Returns the actual rate described by this object, taking pulldown into account.
FrameRate()=default
Creates a frame rate with a base rate of 0.
Describes the time at the start of the current audio callback.
void setBpm(Optional< double > bpmIn)
void setIsRecording(bool isRecordingIn)
void setTimeInSamples(Optional< int64_t > timeInSamplesIn)
bool getIsRecording() const
True if the transport is currently recording.
Optional< double > getBpm() const
Returns the bpm, if available.
Optional< int64_t > getTimeInSamples() const
Returns the number of samples that have elapsed.
void setHostTimeNs(Optional< uint64_t > hostTimeNsIn)
void setLoopPoints(Optional< LoopPoints > loopPointsIn)
Optional< double > getPpqPositionOfLastBarStart() const
The position of the start of the last bar, in units of quarter-notes.
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
Get the host's callback time in nanoseconds, if available.
Optional< double > getPpqPosition() const
The current play position, in units of quarter-notes.
void setIsLooping(bool isLoopingIn)
Optional< TimeSignature > getTimeSignature() const
Returns the time signature, if available.
Optional< LoopPoints > getLoopPoints() const
Returns host loop points, if available.
Optional< double > getTimeInSeconds() const
Returns the number of seconds that have elapsed.
bool getIsPlaying() const
True if the transport is currently playing.
void setTimeSignature(Optional< TimeSignature > timeSignatureIn)
void setFrameRate(Optional< FrameRate > frameRateIn)
void setEditOriginTime(Optional< double > editOriginTimeIn)
void setIsPlaying(bool isPlayingIn)
Optional< double > getEditOriginTime() const
For timecode, the position of the start of the timeline, in seconds from 00:00:00:00.
Optional< int64_t > getBarCount() const
The number of bars since the beginning of the timeline.
Optional< FrameRate > getFrameRate() const
The video frame rate, if available.
bool getIsLooping() const
True if the transport is currently looping.
A subclass of AudioPlayHead can supply information about the position and status of a moving play hea...
virtual Optional< PositionInfo > getPosition() const =0
Fetches details about the transport's position at the start of the current processing block.
FrameRateType
Frame rate types.
bool getCurrentPosition(CurrentPositionInfo &result)
Deprecated, use getPosition() instead.
@ copy
The command ID that should be used to send a "Copy to clipboard" command.
long long int64
A platform-independent 64-bit integer type.
This type is deprecated; prefer PositionInfo instead.
int timeSigDenominator
Time signature denominator, e.g.
double ppqPositionOfLastBarStart
The position of the start of the last bar, in units of quarter-notes.
double ppqLoopEnd
The current cycle end position in units of quarter-notes.
int timeSigNumerator
Time signature numerator, e.g.
double ppqLoopStart
The current cycle start position in units of quarter-notes.
bool isPlaying
True if the transport is currently playing.
double ppqPosition
The current play position, in units of quarter-notes.
FrameRate frameRate
The video frame rate, if applicable.
double bpm
The tempo in BPM.
bool isLooping
True if the transport is currently looping.
int64 timeInSamples
The current play position, in samples from the start of the timeline.
double editOriginTime
For timecode, the position of the start of the timeline, in seconds from 00:00:00:00.
double timeInSeconds
The current play position, in seconds from the start of the timeline.
bool isRecording
True if the transport is currently recording.
Holds the begin and end points of a looped region.
Describes a musical time signature.