public static void init() { try { SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); } catch (SoundSystemException e) { System.err.println("error linking with the plug-ins"); } soundSystem = new SoundSystem(); }
@SubscribeEvent public void onSoundSetup(SoundSetupEvent event) { Objects.log.info("Replacing default soundsystem library with custom one"); try { SoundSystemConfig.removeLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.addLibrary(LibraryDiscoTek.class); } catch (SoundSystemException e) { Objects.log.error("Failed setting up custom soundsystem", e); } }
public void update() { final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler(); if (this.activeSound != null) { if (handler.isSoundPlaying(this.activeSound)) return; ModLog.debug("FADE: " + this.activeSound.toString()); this.activeSound.fadeAway(); this.activeSound = null; this.repeatDelay = this.effect.getRepeat(RANDOM); if (this.repeatDelay > 0) return; } else if (this.repeatDelay > 0) { if (--this.repeatDelay > 0) return; } // If the volume is turned off don't send // down a sound. if (SoundSystemConfig.getMasterGain() <= 0) return; final PlayerSound theSound = new PlayerSound(effect); if (this.effect.type == SoundType.PERIODIC) { this.repeatDelay = this.effect.getRepeat(RANDOM); } else { this.activeSound = theSound; } try { SoundManager.playSound(theSound); } catch (final Throwable t) {; } }
private void tryToSetLibraryAndCodecs() { try { float f = options.soundVolume; float f1 = options.musicVolume; options.soundVolume = 0.0F; options.musicVolume = 0.0F; options.saveOptions(); SoundSystemConfig.addLibrary(paulscode.sound.libraries.LibraryLWJGLOpenAL.class); SoundSystemConfig.setCodec("ogg", paulscode.sound.codecs.CodecJOrbis.class); SoundSystemConfig.setCodec("mus", CodecMus.class); SoundSystemConfig.setCodec("wav", paulscode.sound.codecs.CodecWav.class); if (Class.forName("paulscode.sound.codecs.CodecIBXM") != null) { SoundSystemConfig.setCodec("xm", paulscode.sound.codecs.CodecIBXM.class); SoundSystemConfig.setCodec("s3m", paulscode.sound.codecs.CodecIBXM.class); SoundSystemConfig.setCodec("mod", paulscode.sound.codecs.CodecIBXM.class); } sndSystem = new SoundSystem(); options.soundVolume = f; options.musicVolume = f1; options.saveOptions(); } catch (Throwable throwable) { throwable.printStackTrace(); System.err.println("error linking with the LibraryJavaSound plug-in"); } loaded = true; }
public SoundManager( ResourceManager par1ResourceManager, GameSettings par2GameSettings, File par3File) { this.ticksBeforeMusic = this.rand.nextInt(MUSIC_INTERVAL); this.options = par2GameSettings; this.fileAssets = par3File; this.soundPoolSounds = new SoundPool(par1ResourceManager, "sound", true); this.soundPoolStreaming = new SoundPool(par1ResourceManager, "records", false); this.soundPoolMusic = new SoundPool(par1ResourceManager, "music", true); try { SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); SoundSystemConfig.setCodec("wav", CodecWav.class); MinecraftForge.EVENT_BUS.post(new SoundSetupEvent(this)); } catch (SoundSystemException soundsystemexception) { soundsystemexception.printStackTrace(); System.err.println("error linking with the LibraryJavaSound plug-in"); } this.loadSounds(); }
public SoundPlayer() { libraryType = LibraryJavaSound.class; try { SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); } catch (SoundSystemException ex) { oggPlaybackSupport = false; } try { SoundSystemConfig.setCodec("wav", CodecWav.class); } catch (SoundSystemException ex) { wavPlaybackSupport = false; } try { soundSystem = new SoundSystem(libraryType); } catch (SoundSystemException ex) { soundSystem = null; } }
private boolean playSound(String sourceName, float x, float y, boolean blocking, int index) { if (index < MAX_SOURCES_PER_SOUND && !isMuted() && hasWavPlaybackSupport()) { String indexedSourceName = sourceName + index; if (!loaded.contains(indexedSourceName)) { soundSystem.newSource( false, indexedSourceName, SoundPlayer.class.getResource(sourceName), sourceName, false, x, y, 0, SoundSystemConfig.ATTENUATION_ROLLOFF, SoundSystemConfig.getDefaultRolloff()); loaded.add(indexedSourceName); } else if (isPlaying(indexedSourceName)) { if (blocking) { return false; } // Source already playing, create new source for same sound // effect. return playSound(sourceName, x, y, false, index + 1); } soundSystem.stop(indexedSourceName); soundSystem.setPriority(indexedSourceName, false); soundSystem.setPosition(indexedSourceName, x, y, 0); soundSystem.setAttenuation(indexedSourceName, SoundSystemConfig.ATTENUATION_ROLLOFF); soundSystem.setDistOrRoll(indexedSourceName, SoundSystemConfig.getDefaultRolloff()); soundSystem.setPitch(indexedSourceName, 1.0f); soundSystem.play(indexedSourceName); return true; } return false; }