paulscode.sound.utils
Class SoundSystemLoader

java.lang.Object
  extended by paulscode.sound.utils.SoundSystemLoader

public class SoundSystemLoader
extends java.lang.Object

The SoundSystemLoader class allows the SoundSystem to be set up and loaded via external setup files.

SoundSystemLoader License:

You are free to use this class for any purpose, commercial or otherwise. You may modify this class or source code, and distribute it any way you like, provided the following conditions are met:
1) You may not falsely claim to be the author of this class or any unmodified portion of it.
2) You may not copyright this class or a modified version of it and then sue me for copyright infringement.
3) If you modify the source code, you must clearly document the changes made before redistributing the modified source code, so other users know it is not the original code.
4) You are not required to give me credit for this class in any derived work, but if you do, you must also mention my website: http://www.paulscode.com
5) I the author will not be responsible for any damages (physical, financial, or otherwise) caused by the use if this class or any portion of it.
6) I the author do not guarantee, warrant, or make any representations, either expressed or implied, regarding the use of this class or any portion of it.

Author: Paul Lamb
http://www.paulscode.com


Constructor Summary
SoundSystemLoader()
           
 
Method Summary
protected static void errorMessage(java.lang.String message)
          Prints an error message.
static SoundSystem loadXML(java.net.URL xmlFile, SoundSystem s)
          Parses an XML file and executes the commands it contains.
protected static void message(java.lang.String message, int indent)
          Prints a message.
protected static void printStackTrace(java.lang.Exception e)
          Prints an exception's error message followed by the stack trace.
static void setVerbose(boolean val)
          Sets whether or not to print out messages while loading (default = false).
protected static void warningMessage(java.lang.String message)
          Prints a warning message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoundSystemLoader

public SoundSystemLoader()
Method Detail

loadXML

public static SoundSystem loadXML(java.net.URL xmlFile,
                                  SoundSystem s)
Parses an XML file and executes the commands it contains. If a SoundSystem instance is specified, it will be used, otherwise this method will create a SoundSystem instance and return a handle to it if the XML file contains a CREATE tag. XML tags are NOT case sensitive. Parameters must be placed inside whichever tag they belong to (nested PARAMETER tags are not recognized). Parameter values must NOT contain whitespace (this includes filenames and sourcenames). Parameter values must NOT be inside quotes. Parameter names are NOT case sensetive, but parameter values ARE case sensitive. The supported tags and their parameters are listed below. Parameter names in brackets indicate they are optional. Parameter names without brackets are not optional. Whenever optional parameters are not defined, default values will be used instead.

!--
   XML Comment

ADDLIBRARY
   Adds a library plug-in.
   Parameter:
       CLASSNAME

SETCODEC Adds a codec plug-in. Parameters: EXTENSION and CLASSNAME
   Adds a codec plug-in.
   Parameters:
       EXTENSION
       CLASSNAME

CREATE
   Instantiates the SoundSystem.
   Parameter:
       [CLASSNAME]

LOADSOUND
   Loads a clip into memory. SoundSystem MUST be instantiated.
   Parameter:
       FILENAME

NEWSOURCE
   Creates a new source. SoundSystem MUST be instantiated.
   Parameters:
       [PRIORITY]
       [TOSTREAM]
       [TOLOOP]
       SOURCENAME
       FILENAME
       [X]
       [Y]
       [Z]
       [ATTMODEL]
       [DISTORROLL]

Note: Class names and file names ARE case sensitive and can NOT contain spaces.

Parameters:
xmlFile - URL to an XML file.
s - Handle to a SoundSystem instance, or null to create one.
Returns:
Handle to SoundSystem, or null if none was initially specified and a CREATE command was not found in the XML file.

setVerbose

public static void setVerbose(boolean val)
Sets whether or not to print out messages while loading (default = false).

Parameters:
val - True to show debug messages.

message

protected static void message(java.lang.String message,
                              int indent)
Prints a message.

Parameters:
message - Message to print.

errorMessage

protected static void errorMessage(java.lang.String message)
Prints an error message.

Parameters:
message - Error message to print.

warningMessage

protected static void warningMessage(java.lang.String message)
Prints a warning message.

Parameters:
message - Warning message to print.

printStackTrace

protected static void printStackTrace(java.lang.Exception e)
Prints an exception's error message followed by the stack trace.

Parameters:
e - Exception containing the information to print.