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