2 #include <Process/ZoomHelper.hpp>
4 #include <score/serialization/DataStreamFwd.hpp>
5 #include <score/serialization/IsTemplate.hpp>
7 #include <ossia/detail/flicks.hpp>
8 #include <ossia/editor/scenario/time_value.hpp>
10 #include <ossia-qt/time_value.hpp>
14 #include <score_lib_process_export.h>
20 struct SCORE_LIB_PROCESS_EXPORT
TimeVal : ossia::time_value
22 using ossia::time_value::time_value;
24 static constexpr
TimeVal fromMsecs(
double msecs)
27 time.impl = msecs * ossia::flicks_per_millisecond<double>;
30 static constexpr
TimeVal fromPixels(
double pixels,
double flicksPerPixel)
33 time.impl = pixels * flicksPerPixel;
48 constexpr
TimeVal(ossia::time_value v) noexcept
52 explicit constexpr
TimeVal(int64_t v) noexcept
57 static constexpr
TimeVal zero() noexcept {
return TimeVal{time_value{}}; }
59 explicit TimeVal(
const QTime& t) noexcept;
74 if(infinite() || t.infinite())
81 if(infinite() || t.infinite())
87 constexpr
TimeVal& operator=(
bool d) noexcept =
delete;
88 constexpr
TimeVal& operator=(
double d) noexcept =
delete;
89 constexpr
TimeVal& operator=(
float d) noexcept =
delete;
90 constexpr
TimeVal& operator=(uint64_t d) noexcept =
delete;
92 constexpr
TimeVal& operator=(int64_t d) noexcept
97 constexpr
TimeVal& operator=(int32_t d) noexcept
103 constexpr
TimeVal& operator-() noexcept
111 constexpr time_value operator*(time_value d)
const noexcept
113 return time_value{impl * d.impl};
116 constexpr time_value operator*(
double d)
const noexcept
118 time_value res = *
this;
122 constexpr time_value operator*(int64_t d)
const noexcept
124 return time_value{impl * d};
127 operator bool()
const noexcept =
delete;
129 constexpr
double msec()
const noexcept
132 return impl / ossia::flicks_per_millisecond<double>;
137 constexpr
double sec()
const noexcept
140 return double(impl) / ossia::flicks_per_second<double>;
144 constexpr
double toPixels(ZoomRatio ratio)
const noexcept
146 return (ratio > 0 && !infinite()) ? std::round(impl / ratio) : 0;
149 constexpr
double toPixelsRaw(ZoomRatio ratio)
const noexcept
151 return (ratio > 0 && !infinite()) ? impl / ratio : 0;
154 constexpr int64_t toSample(
double sampleRate)
const noexcept
156 return ossia::to_sample(*
this, sampleRate);
159 QTime toQTime()
const noexcept;
160 QString toString()
const noexcept;
162 constexpr
void setMSecs(
double msecs) noexcept
164 impl = msecs * ossia::flicks_per_millisecond<double>;
167 constexpr
bool operator==(
TimeVal other)
const noexcept {
return impl == other.impl; }
169 constexpr
bool operator!=(
TimeVal other)
const noexcept {
return impl != other.impl; }
171 constexpr
bool operator>(
TimeVal other)
const noexcept {
return impl > other.impl; }
173 constexpr
bool operator>=(
TimeVal other)
const noexcept {
return impl >= other.impl; }
175 constexpr
bool operator<(
TimeVal other)
const noexcept {
return impl < other.impl; }
177 constexpr
bool operator<=(
TimeVal other)
const noexcept {
return impl <= other.impl; }
179 constexpr
bool operator==(time_value other)
const noexcept
181 return impl == other.impl;
184 constexpr
bool operator!=(time_value other)
const noexcept
186 return impl != other.impl;
189 constexpr
bool operator>(time_value other)
const noexcept {
return impl > other.impl; }
191 constexpr
bool operator>=(time_value other)
const noexcept
193 return impl >= other.impl;
196 constexpr
bool operator<(time_value other)
const noexcept {
return impl < other.impl; }
198 constexpr
bool operator<=(time_value other)
const noexcept
200 return impl <= other.impl;
218 std::size_t operator()(
const TimeVal& t)
const {
return qHash(t.impl); }
222 struct is_custom_serialized<
TimeVal> : std::true_type
226 SCORE_SERIALIZE_DATASTREAM_DECLARE(SCORE_LIB_PROCESS_EXPORT,
TimeVal)
Definition: TimeValue.hpp:21