use of org.lwjgl.openal.OpenALException in project Terasology by MovingBlocks.
the class LwjglAudio method initialise.
@Override
public void initialise(GameEngine engine, Context rootContext) {
Config config = rootContext.get(Config.class);
try {
audioManager = new OpenALManager(config.getAudio());
} catch (LWJGLException | OpenALException e) {
logger.warn("Could not load OpenAL manager - sound is disabled", e);
audioManager = new NullAudioManager();
}
rootContext.put(AudioManager.class, audioManager);
}
use of org.lwjgl.openal.OpenALException in project lwjgl by LWJGL.
the class SourceLimitTest method CreateAllSources.
/**
* Tests the creation of n sources in on go
*/
protected void CreateAllSources() {
int lastError;
//make bytbuffer that can hold sourcesToCreate sources
IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);
//Create sourcesToCreate sources in one fell swoop
try {
sources.position(0).limit(sourcesToCreate);
AL10.alGenSources(sources);
//delete sources
sources.position(0).limit(sourcesToCreate);
AL10.alDeleteSources(sources);
System.out.println("created " + sourcesToCreate + " sources successfully!");
} catch (OpenALException oale) {
System.out.println("Unable to create " + sourcesToCreate + " sources");
}
}
use of org.lwjgl.openal.OpenALException in project lwjgl by LWJGL.
the class ALCCaptureTest method execute.
/**
* Runs the actual test, using supplied arguments
*/
protected void execute(String[] args) {
int lastError = ALC10.ALC_NO_ERROR;
IntBuffer sampleCount = BufferUtils.createIntBuffer(1);
int state = AL10.AL_PLAYING;
int FMT = AL10.AL_FORMAT_MONO16;
int FMTSIZE = 16 / 8;
int FREQ = 44100;
int TIME = 5;
int SAMPS = (FREQ * TIME);
ByteBuffer buf = BufferUtils.createByteBuffer(SAMPS * FMTSIZE);
// check that capture is available
if (!ALC10.alcIsExtensionPresent(AL.getDevice(), "ALC_EXT_CAPTURE")) {
throw new OpenALException("ALC_EXT_CAPTURE extension not available");
}
// get list of devices
String[] captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER).split("\0");
System.out.println("Available Capture Devices: ");
for (int i = 0; i < captureDevices.length; i++) {
System.out.println(i + ": " + captureDevices[i]);
}
String defaultRecorder = ALC10.alcGetString(AL.getDevice(), ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
System.out.println("Default capture device: " + defaultRecorder);
ALCdevice device = ALC11.alcCaptureOpenDevice(null, FREQ, FMT, SAMPS);
if (device != null) {
// record some sound
// =====================================
System.out.print("Recording using " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER) + "...");
ALC11.alcCaptureStart(device);
while (sampleCount.get(0) < SAMPS) {
pause(1000);
ALC10.alcGetInteger(device, ALC11.ALC_CAPTURE_SAMPLES, sampleCount);
}
System.out.println("done");
ALC11.alcCaptureStop(device);
// capure the samples
ALC11.alcCaptureSamples(device, buf, SAMPS);
ALC11.alcCaptureCloseDevice(device);
// -------------------------------------
// play back recording
// ===================
IntBuffer buffers = BufferUtils.createIntBuffer(1);
IntBuffer sources = BufferUtils.createIntBuffer(1);
buffers.position(0).limit(1);
AL10.alGenBuffers(buffers);
sources.position(0).limit(1);
AL10.alGenSources(sources);
System.out.print("Playing...");
AL10.alBufferData(buffers.get(0), FMT, buf, FREQ);
AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_FALSE);
AL10.alSourcePlay(sources.get(0));
while (state == AL10.AL_PLAYING) {
pause(100);
state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
}
System.out.println("done");
AL10.alDeleteSources(sources);
AL10.alDeleteBuffers(buffers);
}
alExit();
}
Aggregations