[quote=“vection,post:20,topic:35360”]
Sure.
Step #1 Download the .zip files you want to use. For example:
- The core SoundSystem library
- Library JavaSound plug-in
- CodecWav (you need a codec for each format your sounds are saved in)
Step #2 Unzip them, and pull out the .jar files:
SoundSystem.jar
LibraryJavaSound.jar
CodecWav.jar (or any other codecs that you will be using)
Step #3 Tell the Java compiler about the .jar files from step 2. How to do this step depends entirely on which GUI you are using to develop your project (if you are using one), so I can’t explain that here (google is your friend). I personally use NetBeans, so if that is what you are using, I can explain how to do this in more detail.
Step #4 Place all the audio files you will be using into a package named “Sounds/”. Again, this depends on your GUI.
Step #5 Include the necessary imports at the top of your program. For example:
import paulscode.sound.SoundSystem;
import paulscode.sound.SoundSystemConfig;
import paulscode.sound.SoundSystemException;
import paulscode.sound.libraries.LibraryJavaSound;
import paulscode.sound.codecs.CodecWav;
Step #6 Tell the SoundSystem which plug-ins you plan to use. For example:
try
{
SoundSystemConfig.addLibrary( LibraryJavaSound.class );
SoundSystemConfig.setCodec( "wav", CodecWav.class );
}
catch( SoundSystemException sse )
{
sse.printStackTrace();
}
Step #7 Instantiate the SoundSystem. For example:
mySoundSystem = new SoundSystem();
Step #8 (optional) Pre-load all short sound files. For example:
mySoundSystem.loadSound( "fight.wav" );
mySoundSystem.loadSound( "punch.wav" );
mySoundSystem.loadSound( "kick.wav" );
mySoundSystem.loadSound( "ouch.wav" );
Note: I did not pre-load the music, because that will be streamed directly instead, in order to save memory which is rather limited in applets.
Step #9 (optional) Create a method to simplify quick-playing the sound effects:
public void quickPlay( String filename )
{
mySoundSystem.quickPlay( false, filename, false,
0, 0, 0,
SoundSystemConfig.ATTENUATION_ROLLOFF,
SoundSystemConfig.getDefaultRolloff() );
}
Step #10 Stream the music when it is time to play it:
mySoundSystem.backgroundMusic( "Some cool music!", "song.wav", true );
Step #11 Play the sound effects when it is time to play them. For example:
quickPlay( "fight.wav" );
Thats about it. The SoundSystem library is quite simple as audio libraries go, so you shouldn’t have too much trouble using it once you are comfortable programming in Java.
I recommend reading the tutorial I wrote 3D Sound with SoundSystem if you are serious about using the library, as it will familiarize you with the termonology and walk you through several example programs.