private void initialize(){ device = alcOpenDevice((ByteBuffer)null); if(device == 0L){ Application.error("Unable to open default audio device"); return; } ALCCapabilities deviceCaps = ALC.createCapabilities(device); if(!deviceCaps.OpenALC10){ Application.error("OpenALC10 Unsupported"); return; } context = alcCreateContext(device, (IntBuffer)null); if(context == 0L){ Application.error("Unable to create ALC Context"); return; } ALC10.alcMakeContextCurrent(context); AL.createCapabilities(deviceCaps); }
/** * Initialise OpenAL LWJGL styley */ public void init() { try { AL.create(); soundWorks = true; } catch (LWJGLException e) { System.err.println("Failed to initialise LWJGL OpenAL"); soundWorks = false; return; } if (soundWorks) { IntBuffer sources = BufferUtils.createIntBuffer(1); AL10.alGenSources(sources); if (AL10.alGetError() != AL10.AL_NO_ERROR) { System.err.println("Failed to create sources"); soundWorks = false; } else { source = sources.get(0); } } }
@Override public void init() { if (!AL.isCreated()) { try { AL.create(); } catch (LWJGLException e) { e.printStackTrace(); } allSources = new IntArray(SIMULTANEOUS_SOURCES_COUNT); for (int i = 0; i < SIMULTANEOUS_SOURCES_COUNT; i++) { int sourceID = AL10.alGenSources(); if (AL10.alGetError() == AL10.AL_NO_ERROR) { allSources.add(sourceID); } } idleSources = new IntArray(allSources); recentSounds = new SoundPoolImpl[SIMULTANEOUS_SOURCES_COUNT]; AL10.alListener(AL10.AL_ORIENTATION, orientation); AL10.alListener(AL10.AL_VELOCITY, velocity); AL10.alListener(AL10.AL_POSITION, position); } }
/** * Initializes the SoundManager * * @param channels Number of channels to create */ public void initialize(int channels) { try { AL.create(); // allocate sources scratchBuffer.limit(channels); AL10.alGenSources(scratchBuffer); scratchBuffer.rewind(); scratchBuffer.get(sources = new int[channels]); // could we allocate all channels? if(AL10.alGetError() != AL10.AL_NO_ERROR) { throw new LWJGLException("Unable to allocate " + channels + " sources"); } // we have sound soundOutput = true; } catch (LWJGLException le) { le.printStackTrace(); System.out.println("Sound disabled"); } }
/** * Destroy this SoundManager */ public void destroy() { if(soundOutput) { // stop playing sounds scratchBuffer.position(0).limit(sources.length); scratchBuffer.put(sources).flip(); AL10.alSourceStop(scratchBuffer); // destroy sources AL10.alDeleteSources(scratchBuffer); // destroy buffers scratchBuffer.position(0).limit(bufferIndex); scratchBuffer.put(buffers, 0, bufferIndex).flip(); AL10.alDeleteBuffers(scratchBuffer); // destory OpenAL AL.destroy(); } }
/** * Creates an instance of PlayTest */ protected BasicTest() { try { AL.create(); System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) { String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0"); System.out.println("Available devices: "); for(int i=0; i<devices.length; i++) { System.out.println(i +": " + devices[i]); } } } catch (Exception e) { System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e); return; } }
/** * Runs the actual test, using supplied arguments */ protected void execute(String[] args) { try { AL.create(null, -1, 60, false); checkForErrors(); } catch (LWJGLException le) { die("Init", le.getMessage()); } printALCInfo(); printALInfo(); printEFXInfo(); checkForErrors(); AL.destroy(); }
public OpenAL() throws LWJGLException { try { AL.create(); } catch (Exception e) { System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e); return; } Thread t = new Thread() { public void run() { while (true) { if (isVisible()) repaint(); Display.sync(60); } } }; t.setDaemon(true); t.start(); }
public void stop() { int lastError; //stop source 0 AL10.alSourceStop(sources.get(0)); if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { exit(lastError); } //delete buffers and sources sources.position(0).limit(1); AL10.alDeleteSources(sources); if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { exit(lastError); } buffers.position(0).limit(1); AL10.alDeleteBuffers(buffers); if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { exit(lastError); } AL.destroy(); }
public void cleanupInThread(){ if (audioDisabled){ AL.destroy(); return; } // delete channel-based sources ib.clear(); ib.put(channels); ib.flip(); alDeleteSources(ib); if (supportEfx){ ib.position(0).limit(1); ib.put(0, reverbFx); EFX10.alDeleteEffects(ib); ib.position(0).limit(1); ib.put(0, reverbFxSlot); EFX10.alDeleteAuxiliaryEffectSlots(ib); } // XXX: Delete other buffers/sources AL.destroy(); }
public void dispose () { if (noDevice) return; for (int i = 0, n = allSources.size; i < n; i++) { int sourceID = allSources.get(i); int state = alGetSourcei(sourceID, AL_SOURCE_STATE); if (state != AL_STOPPED) alSourceStop(sourceID); alDeleteSources(sourceID); } sourceToSoundId.clear(); soundIdToSource.clear(); AL.destroy(); while (AL.isCreated()) { try { Thread.sleep(10); } catch (InterruptedException e) { } } }
@Override public void loop() { while(!Display.isCloseRequested()) { final long time = System.nanoTime(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearDepth(1.0f); getInput(); glPushMatrix(); currentStage.beginStep(emptyList()); currentStage.onStep(); currentStage.processAddStack(); currentStage.processRemoveStack(); Renderer.getCamera().lookThrough(); currentStage.render(); currentStage.endStep(); glPopMatrix(); Display.update(); timeDelta = System.nanoTime()-time; } AL.destroy(); Display.destroy(); }
public static final void init() throws InstantiationException { if (init) { throw new InstantiationException("[WARNING] Jumbo Audio Player was already initialized!"); //$NON-NLS-1$ } try { AL.create(); } catch (LWJGLException le) { le.printStackTrace(); return; } buffer = BufferUtils.createIntBuffer(SOUND_NUM); AL10.alGenSources(source); AL10.alGenBuffers(buffer); buffer.limit(1); AL10.alDopplerFactor(1.0f); AL10.alDopplerVelocity(1.0f); check(); init = true; }
public void cleanUp() { Set<String> keys = sourcesMap.keySet(); Iterator<String> iter = keys.iterator(); String name; IntBuffer buffer, source; while (iter.hasNext()) { name = iter.next(); source = sourcesMap.get(name); System.out.println("Stopping " + name); AL10.alSourceStop(source); AL10.alDeleteSources(source); buffer = buffersMap.get(name); AL10.alDeleteBuffers(buffer); } AL.destroy(); }
public Sound() { System.out.print("SFX initialisation"); try { AL.create(); IntSource = alGenSources(); } catch (LWJGLException e) { e.printStackTrace(); } System.out.println("."); }
private void init() throws LWJGLException { this.executeInAudio(new Callable<Object>(){ public Object call() throws Exception { try { AL.create(); } catch (LWJGLException e) { StateManager.logError(e); } return null; } }); }
public void close() { if(!closed.compareAndSet(false, true)) return; try{ for(AudioStateListener listener:audioStateListeners) { try{ listener.close(); }catch(Exception e) { StateManager.logError(e); } } }finally{ this.exec.shutdown(); if(AL.isCreated()) { AL.destroy(); } } }
private void Run(){ CurrentState.GetState().Launch(); while (CurrentState.GetState().LaunchMe) { try { if(CurrentState.GetState().LaunchMe){ CurrentState.GetState().Toggle(true); } } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } } AL.destroy(); Display.destroy(); System.exit(0); }
private void Run() { CurrentState.GetState().Launch(); while (CurrentState.GetState().LaunchMe) { try { if (CurrentState.GetState().LaunchMe) { CurrentState.GetState().Toggle(true); } } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } } AL.destroy(); Display.destroy(); System.exit(0); }
public GameCo(){ //My initialization code initGL(); initFont(); lastFPS = getTime(); //if(gamesave = found) loadgame; else newGame(); newGame(); BackgroundTex = loadTexture("grass"); conWind = new Window(100, 100, 800, 600, this); buyWind = new Window(8, 180, 128, 256, this); //gameLoop(); while (!Display.isCloseRequested()){ gameLoop(); } Display.destroy(); AL.destroy(); System.exit(0); }
public void dispose() { if (noDevice) { return; } for (int i = 0, n = allSources.size; i < n; i++) { int sourceID = allSources.get(i); int state = alGetSourcei(sourceID, AL_SOURCE_STATE); if (state != AL_STOPPED) { alSourceStop(sourceID); } alDeleteSources(sourceID); } sourceToSoundId.clear(); soundIdToSource.clear(); AL.destroy(); while (AL.isCreated()) { try { Thread.sleep(10); } catch (InterruptedException e) { } } }