Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.starshock;
- import paulscode.sound.Library;
- import paulscode.sound.SoundSystem;
- import paulscode.sound.SoundSystemConfig;
- import paulscode.sound.SoundSystemException;
- import paulscode.sound.codecs.CodecJOrbis;
- import paulscode.sound.codecs.CodecWav;
- import paulscode.sound.libraries.LibraryJavaSound;
- import paulscode.sound.libraries.LibraryLWJGLOpenAL;
- public class Sounder {
- public static SoundSystem ss;
- public static boolean dead;
- public static final int MUSIC_AMOUNT = 3;
- public static float masterVolume = 0.2f, musicVolume = 0.9f;
- public static void init() {
- try {
- SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
- SoundSystemConfig.setCodec("wav", CodecWav.class);
- } catch (SoundSystemException e) {
- System.err.println("Error linking with the plug-ins");
- }
- boolean aLCompatible = SoundSystem.libraryCompatible(LibraryLWJGLOpenAL.class);
- boolean jSCompatible = SoundSystem.libraryCompatible(LibraryJavaSound.class);
- Class libraryType;
- if (aLCompatible) {
- libraryType = LibraryLWJGLOpenAL.class; // OpenAL
- } else if (jSCompatible) {
- libraryType = LibraryJavaSound.class; // Java Sound
- } else {
- libraryType = Library.class; // Silent
- }
- try {
- ss = new SoundSystem(libraryType);
- } catch (SoundSystemException sse) {
- sse.printStackTrace();
- return;
- }
- // ss.newStreamingSource(true, "music0", "music0.ogg", true, 0, 0, 0,
- // SoundSystemConfig.ATTENUATION_NONE, 0);
- // ss.setVolume("music0", musicVolume);
- // ss.newStreamingSource(true, "music1", "music1.ogg", true, 0, 0, 0,
- // SoundSystemConfig.ATTENUATION_NONE, 0);
- // ss.setVolume("music1", musicVolume);
- // ss.newStreamingSource(true, "music2", "music2.ogg", true, 0, 0, 0,
- // SoundSystemConfig.ATTENUATION_NONE, 0);
- // ss.setVolume("music2", musicVolume);
- }
- public static void kill() {
- dead = true;
- ss.cleanup();
- }
- public static void startSoundtrack() {
- // Thread stThread = new Thread(new Runnable() {
- //
- // @Override
- // public void run() {
- // int currentSong = Main.rng.nextInt(MUSIC_AMOUNT);
- //
- // System.out.println("Started soundtrack, now at /music" + currentSong
- // + ".ogg");
- //
- // while (!dead) {
- // System.out.println("====================");
- //
- // ss.play("music" + currentSong);
- //
- // try {
- // Thread.sleep(1000 * 10 * 60);
- // } catch (InterruptedException e) {
- // }
- //
- // currentSong = Main.rng.nextInt(MUSIC_AMOUNT);
- //
- // System.out.println("Switched song, now at /music" + currentSong +
- // ".ogg");
- // }
- // }
- // });
- //
- // stThread.start();
- }
- public static void play(String sound) {
- // ss.quickPlay(false, sound, false, 0, 0, 0,
- // SoundSystemConfig.ATTENUATION_NONE, 0);
- }
- public static void playAt(String sound, float x, float y, float z) {
- ss.setListenerPosition(Game.player.pos.x, Game.player.pos.y, Game.player.pos.z);
- ss.setListenerAngle(Game.player.yaw);
- ss.quickPlay(false, sound, false, x, y, z, SoundSystemConfig.ATTENUATION_ROLLOFF, 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement