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); }
/** * 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; } }
public SoundPlayer() { this.device = ALC10.alcOpenDevice((ByteBuffer) null); if (this.device == 0) { throw new IllegalStateException("Failed to open the default device."); } this.context = ALC10.alcCreateContext(this.device, (IntBuffer) null); if (this.context == 0) { throw new IllegalStateException("no context?"); } ALC10.alcMakeContextCurrent(this.context); ALCCapabilities deviceCaps = ALC.createCapabilities(this.device); AL.createCapabilities(deviceCaps); String deviceSpecifier = ALC10.alcGetString(this.device, ALC10.ALC_DEVICE_SPECIFIER); System.err.println("Using device " + deviceSpecifier); System.out.println("ALC_FREQUENCY: " + alcGetInteger(this.device, ALC_FREQUENCY) + "Hz"); System.out.println("ALC_REFRESH: " + alcGetInteger(this.device, ALC_REFRESH) + "Hz"); System.out.println("ALC_SYNC: " + (alcGetInteger(this.device, ALC_SYNC) == ALC_TRUE)); System.out.println("ALC_MONO_SOURCES: " + alcGetInteger(this.device, ALC_MONO_SOURCES)); System.out.println("ALC_STEREO_SOURCES: " + alcGetInteger(this.device, ALC_STEREO_SOURCES)); }
/** * Runs the actual test, using supplied arguments */ protected void execute(String[] args) { //error stuff int lastError = ALC10.ALC_NO_ERROR; //create attribute list for context creation IntBuffer buffer = BufferUtils.createIntBuffer(7); if ((lastError = ALC10.alcGetError(AL.getDevice())) != ALC10.ALC_NO_ERROR) { System.out.println("ALC Error: " + ALC10.alcGetString(AL.getDevice(), lastError)); System.exit(-1); } //query System.out.println( "DEFAULT_DEVICE_SPECIFIER: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); System.out.println( "DEVICE_SPECIFIER: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_DEVICE_SPECIFIER)); System.out.println("EXTENSIONS: " + ALC10.alcGetString(AL.getDevice(), ALC10.ALC_EXTENSIONS)); //mo query buffer.rewind(); buffer.position(0); ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, buffer); ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) buffer.position(1)); System.out.println("ALC_MAJOR_VERSION: " + buffer.get(0)); System.out.println("ALC_MINOR_VERSION: " + buffer.get(1)); //no check for ALC_ALL_ATTRIBUTES / ALC_ATTRIBUTES_SIZE since it //is buggy on win32 - my dev platform //get an enumerstion value System.out.println( "Value of ALC_MAJOR_VERSION: " + ALC10.alcGetEnumValue(AL.getDevice(), "ALC_MAJOR_VERSION")); alExit(); }
private void printALCInfo() { IntBuffer version = BufferUtils.createIntBuffer(2); ALCdevice device; if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) { if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) { printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback"); } else { printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback"); } printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture"); } else { System.out.println("No device enumeration available"); } device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext()); checkForErrors(); System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER)); System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version); ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1)); checkForErrors(); System.out.println("ALC version: " + version.get(0) + "." + version.get(1)); System.out.println("ALC extensions:"); String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" "); for ( String extension : extensions ) { if ( extension.trim().length() == 0 ) { continue; } System.out.println(" " + extension); } checkForErrors(); }
private void printDevices(int which, String kind) { String[] devices = ALC10.alcGetString(null, which).split("\0"); checkForErrors(); System.out.println("Available " + kind + " devices: "); for ( String device : devices ) { System.out.println(" " + device); } }
/** * Loads OpenAL and makes sure ALC_EXT_EFX is supported. */ private static void setupEfx() throws Exception { // Load and create OpenAL if (!AL.isCreated()) { AL.create(); } // Query for Effect Extension if (!ALC10.alcIsExtensionPresent(AL.getDevice(), EFX10.ALC_EXT_EFX_NAME)) { throw new Exception("No ALC_EXT_EFX supported by driver."); } System.out.println("ALC_EXT_EFX found."); }
public static void initAudioEngine(){ device = ALC10.alcOpenDevice((ByteBuffer) null); if (device == NULL) throw new IllegalStateException("Failed to open default audio device"); deviceCaps = ALC.createCapabilities(device); if (!deviceCaps.OpenALC10) throw new IllegalStateException("Device is not OpenALC10 capable."); System.out.println("OpenALC10: " + deviceCaps.OpenALC10); System.out.println("OpenALC11: " + deviceCaps.OpenALC11); System.out.println("caps.ALC_EXT_EFX = " + deviceCaps.ALC_EXT_EFX); if (deviceCaps.OpenALC11){ List<String> devices = ALUtil.getStringList(NULL, ALC_ALL_DEVICES_SPECIFIER); if (devices == null) System.err.println("Whoops, something went wrong with the audio device."); //more specific error else { for (int i = 0; i < devices.size(); i++) System.out.println(i + ": " + devices.get(i)); } } String defaultDeviceSpecifier = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); if (defaultDeviceSpecifier == null) System.err.println("Whoops, something went wrong with the audio device."); //more specific error System.out.println("Default audio device: " + defaultDeviceSpecifier); context = alcCreateContext(device, (IntBuffer) null); alcMakeContextCurrent(context); AL.createCapabilities(deviceCaps); System.out.println("ALC_FREQUENCY: " + alcGetInteger(device, ALC_FREQUENCY) + "Hz"); System.out.println("ALC_REFRESH: " + alcGetInteger(device, ALC_REFRESH) + "Hz"); System.out.println("ALC_SYNC: " + (alcGetInteger(device, ALC_SYNC) == ALC_TRUE)); System.out.println("ALC_MONO_SOURCES: " + alcGetInteger(device, ALC_MONO_SOURCES)); System.out.println("ALC_STEREO_SOURCES: " + alcGetInteger(device, ALC_STEREO_SOURCES)); }
public static ALContext create() { ALContext context = new ALContext(); // AL.createCapabilities(context._device.getID()); context._device = ALH.alhGetDefaultDevice(); if (context._device == null) { return (null); } context._id = ALC10.alcCreateContext(context._device.getID(), (IntBuffer) null); context._listener = new ALListener(); context._capac = ALC.createCapabilities(context._device.getID()); return (context); }
@Override public void onDestroy() { if (ALC10.alcCloseDevice(this._id)) { Logger.get().log(Level.FINE, "Device closed properly: " + this._id); } else { Logger.get().log(Level.ERROR, "Failed to close device: " + this._id); } }
/** get the device with this specifier */ public static ALDevice alhGetDefaultDevice() { try { ALDevice device = new ALDevice(ALC10.alcOpenDevice((ByteBuffer) null)); _objects.add(device); return (device); } catch (Exception e) { Logger.get().log(Logger.Level.ERROR, e.getLocalizedMessage()); return (null); } }