Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lDEVinux
GitHub Repository: lDEVinux/eaglercraft
Path: blob/main/src/lwjgl/java/paulscode/sound/CommandObject.java
8644 views
1
package paulscode.sound;
2
3
/**
4
* The CommandObject class is used to store arguments in the SoundSystem's
5
* Command Queue. Queued CommandObjects are then processed by the
6
* {@link paulscode.sound.CommandThread CommandThread}. Commands are queued
7
* and executed in the background, so it is unlikely that the user will ever
8
* need to use this class.
9
*<br><br>
10
*<b><i> SoundSystem License:</b></i><br><b><br>
11
* You are free to use this library for any purpose, commercial or otherwise.
12
* You may modify this library or source code, and distribute it any way you
13
* like, provided the following conditions are met:
14
*<br>
15
* 1) You may not falsely claim to be the author of this library or any
16
* unmodified portion of it.
17
*<br>
18
* 2) You may not copyright this library or a modified version of it and then
19
* sue me for copyright infringement.
20
*<br>
21
* 3) If you modify the source code, you must clearly document the changes
22
* made before redistributing the modified source code, so other users know
23
* it is not the original code.
24
*<br>
25
* 4) You are not required to give me credit for this library in any derived
26
* work, but if you do, you must also mention my website:
27
* http://www.paulscode.com
28
*<br>
29
* 5) I the author will not be responsible for any damages (physical,
30
* financial, or otherwise) caused by the use if this library or any part
31
* of it.
32
*<br>
33
* 6) I the author do not guarantee, warrant, or make any representations,
34
* either expressed or implied, regarding the use of this library or any
35
* part of it.
36
* <br><br>
37
* Author: Paul Lamb
38
* <br>
39
* http://www.paulscode.com
40
* </b>
41
*/
42
public class CommandObject
43
{
44
/**
45
* Global identifier for the command to initialize the current sound library.
46
*/
47
public static final int INITIALIZE = 1;
48
/**
49
* Global identifier for the command to pre-load a sound file.
50
*/
51
public static final int LOAD_SOUND = 2;
52
/**
53
* Global identifier for the command to pre-load a sound file.
54
*/
55
public static final int LOAD_DATA = 3;
56
/**
57
* Global identifier for the command to remove a sound file from memory.
58
*/
59
public static final int UNLOAD_SOUND = 4;
60
/**
61
* Global identifier for the command to queue a sound file.
62
*/
63
public static final int QUEUE_SOUND = 5;
64
/**
65
* Global identifier for the command to dequeue a sound file.
66
*/
67
public static final int DEQUEUE_SOUND = 6;
68
/**
69
* Global identifier for the command to fade-out transition a source.
70
*/
71
public static final int FADE_OUT = 7;
72
/**
73
* Global identifier for the command to fade-out/in transition a source.
74
*/
75
public static final int FADE_OUT_IN = 8;
76
/**
77
* Global identifier for the command to check volume levels of fading sources.
78
*/
79
public static final int CHECK_FADE_VOLUMES = 9;
80
/**
81
* Global identifier for the command to create a new source.
82
*/
83
public static final int NEW_SOURCE = 10;
84
/**
85
* Global identifier for the command to create a new raw data stream.
86
*/
87
public static final int RAW_DATA_STREAM = 11;
88
/**
89
* Global identifier for the command to create a source and immediately play it.
90
*/
91
public static final int QUICK_PLAY = 12;
92
/**
93
* Global identifier for the command to set a source's position in 3D space.
94
*/
95
public static final int SET_POSITION = 13;
96
/**
97
* Global identifier for the command to change a source's volume.
98
*/
99
public static final int SET_VOLUME = 14;
100
/**
101
* Global identifier for the command to change a source's pitch.
102
*/
103
public static final int SET_PITCH = 15;
104
/**
105
* Global identifier for the command to change a source's priority.
106
*/
107
public static final int SET_PRIORITY = 16;
108
/**
109
* Global identifier for the command to tell a source whether or not to loop.
110
*/
111
public static final int SET_LOOPING = 17;
112
/**
113
* Global identifier for the command to set a source's attenuation model.
114
*/
115
public static final int SET_ATTENUATION = 18;
116
/**
117
* Global identifier for the command to set a source's fade distance or rolloff
118
* factor.
119
*/
120
public static final int SET_DIST_OR_ROLL = 19;
121
/**
122
* Global identifier for the command to change the Doppler factor.
123
*/
124
public static final int CHANGE_DOPPLER_FACTOR = 20;
125
/**
126
* Global identifier for the command to change the Doppler velocity.
127
*/
128
public static final int CHANGE_DOPPLER_VELOCITY = 21;
129
/**
130
* Global identifier for the command to set a source's velocity.
131
*/
132
public static final int SET_VELOCITY = 22;
133
/**
134
* Global identifier for the command to set a source's velocity.
135
*/
136
public static final int SET_LISTENER_VELOCITY = 23;
137
/**
138
* Global identifier for the command to play a source.
139
*/
140
public static final int PLAY = 24;
141
/**
142
* Global identifier for the command to play a source.
143
*/
144
public static final int FEED_RAW_AUDIO_DATA = 25;
145
/**
146
* Global identifier for the command to pause a source.
147
*/
148
public static final int PAUSE = 26;
149
/**
150
* Global identifier for the command to stop a source.
151
*/
152
public static final int STOP = 27;
153
/**
154
* Global identifier for the command to rewind a source.
155
*/
156
public static final int REWIND = 28;
157
/**
158
* Global identifier for the command to flush all queued data.
159
*/
160
public static final int FLUSH = 29;
161
/**
162
* Global identifier for the command to cull a source.
163
*/
164
public static final int CULL = 30;
165
/**
166
* Global identifier for the command to activate a source.
167
*/
168
public static final int ACTIVATE = 31;
169
/**
170
* Global identifier for the command to set a source as permanant or temporary.
171
*/
172
public static final int SET_TEMPORARY = 32;
173
/**
174
* Global identifier for the command to delete a source.
175
*/
176
public static final int REMOVE_SOURCE = 33;
177
/**
178
* Global identifier for the command to move the listner.
179
*/
180
public static final int MOVE_LISTENER = 34;
181
/**
182
* Global identifier for the command to set the listener's position.
183
*/
184
public static final int SET_LISTENER_POSITION = 35;
185
/**
186
* Global identifier for the command to turn the listener.
187
*/
188
public static final int TURN_LISTENER = 36;
189
/**
190
* Global identifier for the command to set the listener's turn angle.
191
*/
192
public static final int SET_LISTENER_ANGLE = 37;
193
/**
194
* Global identifier for the command to change the listener's orientation.
195
*/
196
public static final int SET_LISTENER_ORIENTATION = 38;
197
/**
198
* Global identifier for the command to change the master volume.
199
*/
200
public static final int SET_MASTER_VOLUME = 39;
201
/**
202
* Global identifier for the command to create a new library.
203
*/
204
public static final int NEW_LIBRARY = 40;
205
206
/**
207
* Any buffer required for a command.
208
*/
209
public byte[] buffer;
210
/**
211
* Any int arguments required for a command.
212
*/
213
public int[] intArgs;
214
/**
215
* Any float arguments required for a command.
216
*/
217
public float[] floatArgs;
218
/**
219
* Any long arguments required for a command.
220
*/
221
public long[] longArgs;
222
/**
223
* Any boolean arguments required for a command.
224
*/
225
public boolean[] boolArgs;
226
/**
227
* Any String arguments required for a command.
228
*/
229
public String[] stringArgs;
230
231
/**
232
* Any Class arguments required for a command.
233
*/
234
public Class[] classArgs;
235
236
/**
237
* Any Object arguments required for a command.
238
*/
239
public Object[] objectArgs;
240
241
/**
242
* Which command to execute.
243
*/
244
public int Command;
245
246
/**
247
* Constructor used to create a command which doesn't require any arguments.
248
* @param cmd Which command to execute.
249
*/
250
public CommandObject( int cmd )
251
{
252
Command = cmd;
253
}
254
/**
255
* Constructor used to create a command which requires one integer argument.
256
* @param cmd Which command to execute.
257
* @param i The integer argument needed to execute this command.
258
*/
259
public CommandObject( int cmd, int i )
260
{
261
Command = cmd;
262
intArgs = new int[1];
263
intArgs[0] = i;
264
}
265
/**
266
* Constructor used to create a command which requires one Library Class
267
* argument.
268
* @param cmd Which command to execute.
269
* @param c The Library Class argument needed to execute this command.
270
*/
271
public CommandObject( int cmd, Class c )
272
{
273
Command = cmd;
274
classArgs = new Class[1];
275
classArgs[0] = c;
276
}
277
/**
278
* Constructor used to create a command which requires one float argument.
279
* @param cmd Which command to execute.
280
* @param f The float argument needed to execute this command.
281
*/
282
public CommandObject( int cmd, float f )
283
{
284
Command = cmd;
285
floatArgs = new float[1];
286
floatArgs[0] = f;
287
}
288
/**
289
* Constructor used to create a command which requires one String argument.
290
* @param cmd Which command to execute.
291
* @param s The String argument needed to execute this command.
292
*/
293
public CommandObject( int cmd, String s )
294
{
295
Command = cmd;
296
stringArgs = new String[1];
297
stringArgs[0] = s;
298
}
299
/**
300
* Constructor used to create a command which requires one Object argument.
301
* @param cmd Which command to execute.
302
* @param o The Object argument needed to execute this command.
303
*/
304
public CommandObject( int cmd, Object o )
305
{
306
Command = cmd;
307
objectArgs = new Object[1];
308
objectArgs[0] = o;
309
}
310
/**
311
* Constructor used to create a command which requires one String argument and
312
* one Object argument.
313
* @param cmd Which command to execute.
314
* @param s The String argument needed to execute this command.
315
* @param o The Object argument needed to execute this command.
316
*/
317
public CommandObject( int cmd, String s, Object o )
318
{
319
Command = cmd;
320
stringArgs = new String[1];
321
stringArgs[0] = s;
322
objectArgs = new Object[1];
323
objectArgs[0] = o;
324
}
325
/**
326
* Constructor used to create a command which requires one String argument and
327
* one byte buffer argument.
328
* @param cmd Which command to execute.
329
* @param s The String argument needed to execute this command.
330
* @param buff The byte buffer argument needed to execute this command.
331
*/
332
public CommandObject( int cmd, String s, byte[] buff )
333
{
334
Command = cmd;
335
stringArgs = new String[1];
336
stringArgs[0] = s;
337
buffer = buff;
338
}
339
/**
340
* Constructor used to create a command which requires one String argument, one
341
* Object argument, and one long argument.
342
* @param cmd Which command to execute.
343
* @param s The String argument needed to execute this command.
344
* @param o The Object argument needed to execute this command.
345
* @param l The long argument needed to execute this command.
346
*/
347
public CommandObject( int cmd, String s, Object o, long l )
348
{
349
Command = cmd;
350
stringArgs = new String[1];
351
stringArgs[0] = s;
352
objectArgs = new Object[1];
353
objectArgs[0] = o;
354
longArgs = new long[1];
355
longArgs[0] = l;
356
}
357
/**
358
* Constructor used to create a command which requires one String argument, one
359
* Object argument, and two long arguments.
360
* @param cmd Which command to execute.
361
* @param s The String argument needed to execute this command.
362
* @param o The Object argument needed to execute this command.
363
* @param l1 The first long argument needed to execute this command.
364
* @param l2 The second long argument needed to execute this command.
365
*/
366
public CommandObject( int cmd, String s, Object o, long l1, long l2 )
367
{
368
Command = cmd;
369
stringArgs = new String[1];
370
stringArgs[0] = s;
371
objectArgs = new Object[1];
372
objectArgs[0] = o;
373
longArgs = new long[2];
374
longArgs[0] = l1;
375
longArgs[1] = l2;
376
}
377
/**
378
* Constructor used to create a command which requires two String arguments.
379
* @param cmd Which command to execute.
380
* @param s1 The first String argument needed to execute this command.
381
* @param s2 The second String argument needed to execute this command.
382
*/
383
public CommandObject( int cmd, String s1, String s2 )
384
{
385
Command = cmd;
386
stringArgs = new String[2];
387
stringArgs[0] = s1;
388
stringArgs[1] = s2;
389
}
390
/**
391
* Constructor used to create a command which requires a String and an int as
392
* arguments.
393
* @param cmd Which command to execute.
394
* @param s The String argument needed to execute this command.
395
* @param i The integer argument needed to execute this command.
396
*/
397
public CommandObject( int cmd, String s, int i )
398
{
399
Command = cmd;
400
intArgs = new int[1];
401
stringArgs = new String[1];
402
intArgs[0] = i;
403
stringArgs[0] = s;
404
}
405
/**
406
* Constructor used to create a command which requires a String and a float as
407
* arguments.
408
* @param cmd Which command to execute.
409
* @param s The String argument needed to execute this command.
410
* @param f The float argument needed to execute this command.
411
*/
412
public CommandObject( int cmd, String s, float f )
413
{
414
Command = cmd;
415
floatArgs = new float[1];
416
stringArgs = new String[1];
417
floatArgs[0] = f;
418
stringArgs[0] = s;
419
}
420
/**
421
* Constructor used to create a command which requires a String and a boolean
422
* as arguments.
423
* @param cmd Which command to execute.
424
* @param s The String argument needed to execute this command.
425
* @param b The boolean argument needed to execute this command.
426
*/
427
public CommandObject( int cmd, String s, boolean b )
428
{
429
Command = cmd;
430
boolArgs = new boolean[1];
431
stringArgs = new String[1];
432
boolArgs[0] = b;
433
stringArgs[0] = s;
434
}
435
/**
436
* Constructor used to create a command which requires three float arguments.
437
* @param cmd Which command to execute.
438
* @param f1 The first float argument needed to execute this command.
439
* @param f2 The second float argument needed to execute this command.
440
* @param f3 The third float argument needed to execute this command.
441
*/
442
public CommandObject( int cmd, float f1, float f2, float f3 )
443
{
444
Command = cmd;
445
floatArgs = new float[3];
446
floatArgs[0] = f1;
447
floatArgs[1] = f2;
448
floatArgs[2] = f3;
449
}
450
/**
451
* Constructor used to create a command which a String and three float
452
* arguments.
453
* @param cmd Which command to execute.
454
* @param s The String argument needed to execute this command.
455
* @param f1 The first float argument needed to execute this command.
456
* @param f2 The second float argument needed to execute this command.
457
* @param f3 The third float argument needed to execute this command.
458
*/
459
public CommandObject( int cmd, String s, float f1, float f2, float f3 )
460
{
461
Command = cmd;
462
floatArgs = new float[3];
463
stringArgs = new String[1];
464
floatArgs[0] = f1;
465
floatArgs[1] = f2;
466
floatArgs[2] = f3;
467
stringArgs[0] = s;
468
}
469
/**
470
* Constructor used to create a command which requires six float arguments.
471
* @param cmd Which command to execute.
472
* @param f1 The first float argument needed to execute this command.
473
* @param f2 The second float argument needed to execute this command.
474
* @param f3 The third float argument needed to execute this command.
475
* @param f4 The fourth float argument needed to execute this command.
476
* @param f5 The fifth float argument needed to execute this command.
477
* @param f6 The sixth float argument needed to execute this command.
478
*/
479
public CommandObject( int cmd, float f1, float f2, float f3, float f4,
480
float f5, float f6 )
481
{
482
Command = cmd;
483
floatArgs = new float[6];
484
floatArgs[0] = f1;
485
floatArgs[1] = f2;
486
floatArgs[2] = f3;
487
floatArgs[3] = f4;
488
floatArgs[4] = f5;
489
floatArgs[5] = f6;
490
}
491
/**
492
* Constructor used to create a command which requires several arguments.
493
* @param cmd Which command to execute.
494
* @param b1 The first boolean argument needed to execute this command.
495
* @param b2 The second boolean argument needed to execute this command.
496
* @param b3 The third boolean argument needed to execute this command.
497
* @param s The String argument needed to execute this command.
498
* @param o The Object argument needed to execute this command.
499
* @param f1 The first float argument needed to execute this command.
500
* @param f2 The second float argument needed to execute this command.
501
* @param f3 The third float argument needed to execute this command.
502
* @param i The integer argument needed to execute this command.
503
* @param f4 The fourth float argument needed to execute this command.
504
*/
505
public CommandObject( int cmd,
506
boolean b1, boolean b2, boolean b3,
507
String s, Object o,
508
float f1, float f2, float f3,
509
int i, float f4 )
510
{
511
Command = cmd;
512
intArgs = new int[1];
513
floatArgs = new float[4];
514
boolArgs = new boolean[3];
515
stringArgs = new String[1];
516
objectArgs = new Object[1];
517
intArgs[0] = i;
518
floatArgs[0] = f1;
519
floatArgs[1] = f2;
520
floatArgs[2] = f3;
521
floatArgs[3] = f4;
522
boolArgs[0] = b1;
523
boolArgs[1] = b2;
524
boolArgs[2] = b3;
525
stringArgs[0] = s;
526
objectArgs[0] = o;
527
}
528
/**
529
* Constructor used to create a command which requires several arguments.
530
* @param cmd Which command to execute.
531
* @param b1 The first boolean argument needed to execute this command.
532
* @param b2 The second boolean argument needed to execute this command.
533
* @param b3 The third boolean argument needed to execute this command.
534
* @param s The String argument needed to execute this command.
535
* @param o The Object argument needed to execute this command.
536
* @param f1 The first float argument needed to execute this command.
537
* @param f2 The second float argument needed to execute this command.
538
* @param f3 The third float argument needed to execute this command.
539
* @param i The integer argument needed to execute this command.
540
* @param f4 The fourth float argument needed to execute this command.
541
* @param b4 The fourth boolean argument needed to execute this command.
542
*/
543
public CommandObject( int cmd,
544
boolean b1, boolean b2, boolean b3,
545
String s,
546
Object o,
547
float f1, float f2, float f3,
548
int i, float f4, boolean b4 )
549
{
550
Command = cmd;
551
intArgs = new int[1];
552
floatArgs = new float[4];
553
boolArgs = new boolean[4];
554
stringArgs = new String[1];
555
objectArgs = new Object[1];
556
intArgs[0] = i;
557
floatArgs[0] = f1;
558
floatArgs[1] = f2;
559
floatArgs[2] = f3;
560
floatArgs[3] = f4;
561
boolArgs[0] = b1;
562
boolArgs[1] = b2;
563
boolArgs[2] = b3;
564
boolArgs[3] = b4;
565
stringArgs[0] = s;
566
objectArgs[0] = o;
567
}
568
/**
569
* Constructor used to create a command which requires several arguments.
570
* @param cmd Which command to execute.
571
* @param o The Object argument needed to execute this command.
572
* @param b The first boolean argument needed to execute this command.
573
* @param s The String argument needed to execute this command.
574
* @param f1 The first float argument needed to execute this command.
575
* @param f2 The second float argument needed to execute this command.
576
* @param f3 The third float argument needed to execute this command.
577
* @param i The integer argument needed to execute this command.
578
* @param f4 The fourth float argument needed to execute this command.
579
*/
580
public CommandObject( int cmd,
581
Object o,
582
boolean b,
583
String s,
584
float f1, float f2, float f3,
585
int i,
586
float f4 )
587
{
588
Command = cmd;
589
intArgs = new int[1];
590
floatArgs = new float[4];
591
boolArgs = new boolean[1];
592
stringArgs = new String[1];
593
objectArgs = new Object[1];
594
intArgs[0] = i;
595
floatArgs[0] = f1;
596
floatArgs[1] = f2;
597
floatArgs[2] = f3;
598
floatArgs[3] = f4;
599
boolArgs[0] = b;
600
stringArgs[0] = s;
601
objectArgs[0] = o;
602
}
603
}
604
605