@@ -14,8 +14,6 @@ public class ArtTimePacket extends ArtNetPacket {
14
14
private int hours ;
15
15
private int type ;
16
16
17
- public long encoded ;
18
-
19
17
public ArtTimePacket () {
20
18
super (PacketType .ART_TIMECODE );
21
19
setData (new byte [19 ]);
@@ -32,133 +30,21 @@ public boolean parse(byte[] raw) {
32
30
minutes = data .getInt8 (16 );
33
31
hours = data .getInt8 (17 );
34
32
type = data .getInt8 (18 );
35
- encoded = encode (hours , minutes , seconds , frames , type );
36
33
return true ;
37
34
}
38
35
39
36
/**
40
- * Increment the timecode by 1.
37
+ * Set the time in one method.
38
+ * @param hour hours
39
+ * @param min minutes
40
+ * @param sec seconds
41
+ * @param frame frames
41
42
*/
42
- public void increment () {
43
- encoded ++;
44
- int [] val = decode (encoded , type );
45
- frames = val [3 ];
46
- seconds = val [2 ];
47
- minutes = val [1 ];
48
- hours = val [0 ];
49
- updateData ();
50
- }
51
-
52
- /**
53
- * Decrement the timecode by 1;
54
- */
55
- public void decrement () {
56
- encoded --;
57
- int [] val = decode (encoded , type );
58
- frames = val [3 ];
59
- seconds = val [2 ];
60
- minutes = val [1 ];
61
- hours = val [0 ];
62
- updateData ();
63
- }
64
-
65
- /**
66
- * Convert the separate values into one long value, for easy increment/decrement
67
- *
68
- * @param hour number of hours
69
- * @param min number of minutes
70
- * @param sec number of seconds
71
- * @param frame number of frames
72
- * @param frameType the type of the timecode
73
- * @return the encoded time value
74
- */
75
- public long encode (int hour , int min , int sec , int frame , int frameType ) {
76
- int framerate = 30 ;
77
- switch (frameType ) {
78
- case 0 :
79
- //film
80
- framerate = 24 ;
81
- break ;
82
- case 1 :
83
- //ebu
84
- framerate = 25 ;
85
- break ;
86
- case 2 :
87
- //df
88
- throw new IllegalArgumentException ("DF type not implemented! Do you wanna implement it yourself?" );
89
- case 3 :
90
- //smtpe
91
- framerate = 30 ;
92
- break ;
93
- default :
94
- framerate = 30 ;
95
- break ;
96
- }
97
-
98
- int hour_fr = hour * 60 * 60 * framerate ;
99
- int min_fr = min * 60 * framerate ;
100
- int sec_fr = sec * framerate ;
101
-
102
- return hour_fr + min_fr + sec_fr + frame ;
103
- }
104
-
105
- /**
106
- * Decodes the encoded timecode value.<br>
107
- * Elements of the returning int array:<br>
108
- * 0: hour<br>
109
- * 1: minute<br>
110
- * 2: second<br>
111
- * 3: frame<br>
112
- *
113
- * @param frames the encoded time data
114
- * @param frameType the type of the timecode
115
- * @return the decoded time values
116
- */
117
- public int [] decode (long frames , int frameType ) {
118
- int framerate = 30 ;
119
- switch (frameType ) {
120
- case 0 :
121
- framerate = 24 ;
122
- break ;
123
- case 1 :
124
- framerate = 25 ;
125
- break ;
126
- case 2 :
127
- throw new IllegalArgumentException ("DF type not implemented! Do you wanna implement it yourself?" );
128
- case 3 :
129
- framerate = 30 ;
130
- break ;
131
- default :
132
- framerate = 30 ;
133
- break ;
134
- }
135
-
136
- int [] dec = new int [4 ];
137
-
138
- int hour = ((int ) frames / 60 / 60 / framerate );
139
- frames = frames - (hour * 60 * 60 * framerate );
140
- dec [0 ] = hour ;
141
-
142
- int min = ((int ) frames / 60 / framerate );
143
- frames = frames - (min * 60 * framerate );
144
- dec [1 ] = min ;
145
-
146
- int sec = ((int ) frames / framerate );
147
- frames = frames - (sec * framerate );
148
- dec [2 ] = sec ;
149
-
150
- int frame = (int ) frames ;
151
- dec [3 ] = frame ;
152
-
153
- return dec ;
154
- }
155
-
156
43
public void setTime (int hour , int min , int sec , int frame ) {
157
44
this .hours = hour ;
158
45
this .minutes = min ;
159
46
this .seconds = sec ;
160
47
this .frames = frame ;
161
- this .encoded = encode (hours , minutes , seconds , frames , type );
162
48
updateData ();
163
49
}
164
50
@@ -171,8 +57,7 @@ public int getFrames() {
171
57
172
58
173
59
public void setFrames (int frames ) {
174
- this .frames = frames & 0x0f ;
175
- this .encoded = encode (hours , minutes , seconds , this .frames , type );
60
+ this .frames = frames ;
176
61
updateData ();
177
62
}
178
63
@@ -186,7 +71,6 @@ public int getSeconds() {
186
71
187
72
public void setSeconds (int seconds ) {
188
73
this .seconds = seconds ;
189
- this .encoded = encode (hours , minutes , this .seconds , frames , type );
190
74
updateData ();
191
75
}
192
76
@@ -200,7 +84,6 @@ public int getMinutes() {
200
84
201
85
public void setMinutes (int minutes ) {
202
86
this .minutes = minutes ;
203
- this .encoded = encode (hours , this .minutes , seconds , frames , type );
204
87
updateData ();
205
88
}
206
89
@@ -214,7 +97,6 @@ public int getHours() {
214
97
215
98
public void setHours (int hours ) {
216
99
this .hours = hours ;
217
- this .encoded = encode (this .hours , minutes , seconds , frames , type );
218
100
updateData ();
219
101
}
220
102
@@ -232,7 +114,6 @@ public int getFrameType() {
232
114
*/
233
115
public void setFrameType (int type ) {
234
116
this .type = type ;
235
- this .encoded = encode (hours , minutes , seconds , frames , this .type );
236
117
updateData ();
237
118
}
238
119
0 commit comments