org.newdawn.slick.openal.AudioLoader Java Examples

The following examples show how to use org.newdawn.slick.openal.AudioLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FEResources.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Load resources.
 */
public static void loadResources() {
	try {
		//Load bitmap fonts
		loadBitmapFonts();
		
		// Textures
		textures.put("whoops", new AnimationData("res/whoops.png"));
		loadTextures();	
		//load audio
		audio.put("miss", AudioLoader.getAudio("WAV",
				ResourceLoader.getResourceAsStream("res/sfx/miss.wav")));
		
	} catch (IOException e) {
		int max = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE);
		System.out.println(max);
		e.printStackTrace();
	}
	System.gc();
}
 
Example #2
Source File: FEResources.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
/**
	 * Gets the audio.
	 *
	 * @param name the name
	 * @return the audio
	 */
	public static Audio getAudio(String name) {
		Audio a = audio.get(name);
		if(a == null) {
//			System.err.println("Warn: " + name + " not explicitly defined");
			try{
				Audio b = AudioLoader.getAudio("WAV",
						ResourceLoader.getResourceAsStream("res/sfx/"+name+".wav"));
				audio.put(name, b);
				return b;
			} catch (Exception e){
				return null;
			}
		} else {
			return a;
		}
	}
 
Example #3
Source File: FEResources.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
public static void loadResources() {
	try {
		//Load bitmap fonts
		loadBitmapFonts();
		
		// Textures
		textures.put("whoops", new AnimationData("res/whoops.png"));
		loadTextures();	
		//load audio
		audio.put("miss", AudioLoader.getAudio("WAV",
				ResourceLoader.getResourceAsStream("res/sfx/miss.wav")));
		
	} catch (IOException e) {
		int max = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE);
		System.out.println(max);
		e.printStackTrace();
	}
	System.gc();
}
 
Example #4
Source File: FEResources.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
public static Audio getAudio(String name) {
		Audio a = audio.get(name);
		if(a == null) {
//			System.err.println("Warn: " + name + " not explicitly defined");
			try{
				Audio b = AudioLoader.getAudio("WAV",
						ResourceLoader.getResourceAsStream("res/sfx/"+name+".wav"));
				audio.put(name, b);
				return b;
			} catch (Exception e){
				return null;
			}
		} else {
			return a;
		}
	}
 
Example #5
Source File: SoundTest.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	SoundStore.get().setMaxSources(32);
	
	myContainer = container;
	sound = new Sound("testdata/restart.ogg");
	charlie = new Sound("testdata/cbrown01.wav");
	try {
		engine = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("testdata/engine.wav"));
	} catch (IOException e) {
		throw new SlickException("Failed to load engine", e);
	}
	music = musica = new Music("testdata/SMB-X.XM");
	//music = musica = new Music("testdata/theme.ogg", true);
	musicb = new Music("testdata/kirby.ogg", true);
	burp = new Sound("testdata/burp.aif");
	
	music.play();
}
 
Example #6
Source File: SoundTrack.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loops the given audio according to settings.
 * 
 * @param name the music category
 */
public static void loop(String name){
	if (FEResources.getAudioVolume() <= 0) return;
	if (name.equals(currentName) && current.isPlaying()) return;
	
	current.stop();
	currentName = name;
	Map<String, ArrayList<String>> songs = loadAudioNames();
	
	try{
		String setting = FEResources.getAudioSetting(name.toUpperCase());
		if(setting.equals("random")){
			Random r = new Random();
			setting = name + "_" + songs.get(name).get(r.nextInt(songs.get(name).size()));
			if(setting.split("_").length<2)
				setting = name;
		}
		current = AudioLoader.getAudio("WAV",
				ResourceLoader.getResourceAsStream("res/music/"+setting+".wav"));
		current.playAsMusic(1.0f, FEResources.getAudioVolume(), true);
	} catch (Exception e){
		e.printStackTrace();
		System.err.println("Warn: Bad sound configuration: "+name);
		try{
			Audio b = AudioLoader.getAudio("WAV",
					ResourceLoader.getResourceAsStream("res/music/"+name+".wav"));
			b.playAsMusic(1.0f, FEResources.getAudioVolume(), true);
		}catch(Exception f){}
	}
}
 
Example #7
Source File: SoundTrack.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
public static void loop(String name){
	if(!enabled) return;
	if(name.equals(current)) return;
	try {
		current = name;
		Audio a = AudioLoader.getStreamingAudio("OGG", 
				ResourceLoader.getResource("res/music/"+name+".ogg"));
		a.playAsMusic(1, 1, true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example #8
Source File: SoundTrack.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
public static void restart(){
	if(!enabled) return;
	try {
		Audio a = AudioLoader.getStreamingAudio("OGG", 
				ResourceLoader.getResource("res/music/"+current+".ogg"));
		a.playAsMusic(1, 1, true);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}