Skip to content

Commit 4861aba

Browse files
committed
Increase TimeValue ms int -> int64
1 parent 17e6065 commit 4861aba

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

Source/Processors/Editors/PopupTimeEditor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ class PLUGIN_API PopupTimeEditor : public Component,
107107
hourEditor.getText().getIntValue(),
108108
minuteEditor.getText().getIntValue(),
109109
secondEditor.getText().getDoubleValue());
110-
int t1 = newTv->getTimeInMilliseconds();
111-
int t2 = p->getTimeValue()->getMaxTimeInMilliseconds();
110+
int64 t1 = newTv->getTimeInMilliseconds();
111+
int64 t2 = p->getTimeValue()->getMaxTimeInMilliseconds();
112112
if (newTv->getTimeInMilliseconds() <= p->getTimeValue()->getMaxTimeInMilliseconds()
113113
&& newTv->getTimeInMilliseconds() >= p->getTimeValue()->getMinTimeInMilliseconds())
114114
p->setNextValue (newTv->toString(), true);

Source/Processors/Parameter/Parameter.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,31 +1009,31 @@ class PLUGIN_API TimeParameter : public Parameter
10091009
class TimeValue
10101010
{
10111011
public:
1012-
/** Constructor */
10131012
TimeValue (int hour_, int minute_, double second_)
10141013
: hour (hour_),
10151014
minute (minute_),
10161015
second (second_) {}
10171016

1018-
TimeValue (int ms) { setTimeFromMilliseconds (ms); }
1017+
TimeValue (int64 ms) { setTimeFromMilliseconds (ms); }
10191018

10201019
TimeValue (String time) { setTimeFromString (time); }
10211020

1022-
/** Destructor */
1023-
~TimeValue() {}
1024-
10251021
String toString()
10261022
{
1027-
return String::formatted ("%02d:%02d:%06.3f", this->hour, this->minute, this->second);
1023+
return String::formatted ("%02d:%02d:%06.3f", hour, minute, second);
10281024
}
10291025

10301026
void setTimeFromString (String time)
10311027
{
10321028
StringArray tokens;
10331029
tokens.addTokens (time, ":", "");
1034-
hour = tokens[0].getIntValue();
1035-
minute = tokens[1].getIntValue();
1036-
second = tokens[2].getDoubleValue();
1030+
1031+
if (tokens.size() == 3)
1032+
{
1033+
hour = tokens[0].getIntValue();
1034+
minute = tokens[1].getIntValue();
1035+
second = tokens[2].getDoubleValue();
1036+
}
10371037
}
10381038

10391039
void setHours (int h) { hour = h; }
@@ -1044,27 +1044,28 @@ class PLUGIN_API TimeParameter : public Parameter
10441044
int getMinutes() { return minute; }
10451045
double getSeconds() { return second; }
10461046

1047-
int getTimeInMilliseconds() { return 1000 * (second + 60.0 * double (minute + 60 * hour)); }
1048-
void setTimeFromMilliseconds (int ms)
1047+
int64 getTimeInMilliseconds() { return static_cast<int64>(1000 * (second + 60.0 * double (minute + 60 * hour))); }
1048+
void setTimeFromMilliseconds (int64 ms)
10491049
{
1050-
hour = ms / 3600000;
1051-
minute = (ms - hour * 3600000) / 60000;
1052-
second = (ms - hour * 3600000.0f - minute * 60000.0f) / 1000.0f;
1050+
hour = int(ms / (1000 * 60 * 60));
1051+
ms -= hour * (1000 * 60 * 60);
1052+
minute = int(ms / (1000 * 60));
1053+
ms -= minute * (1000 * 60);
1054+
second = double(ms) / 1000.0;
10531055
}
10541056

1055-
void setMinTimeInMilliseconds (int ms) { minTimeInMilliseconds = ms; }
1056-
int getMinTimeInMilliseconds() { return minTimeInMilliseconds; }
1057+
void setMinTimeInMilliseconds (int64 ms) { minTimeInMilliseconds = ms; }
1058+
int64 getMinTimeInMilliseconds() { return minTimeInMilliseconds; }
10571059

1058-
void setMaxTimeInMilliseconds (int ms) { maxTimeInMilliseconds = ms; }
1059-
int getMaxTimeInMilliseconds() { return maxTimeInMilliseconds; }
1060+
void setMaxTimeInMilliseconds (int64 ms) { maxTimeInMilliseconds = ms; }
1061+
int64 getMaxTimeInMilliseconds() { return maxTimeInMilliseconds; }
10601062

10611063
private:
10621064
int hour;
10631065
int minute;
10641066
double second;
1065-
1066-
int minTimeInMilliseconds;
1067-
int maxTimeInMilliseconds;
1067+
int64 minTimeInMilliseconds;
1068+
int64 maxTimeInMilliseconds;
10681069
};
10691070

10701071
TimeValue* getTimeValue() { return timeValue.get(); }

0 commit comments

Comments
 (0)