本文整理汇总了Java中org.lwjgl.openal.AL类的典型用法代码示例。如果您正苦于以下问题:Java AL类的具体用法?Java AL怎么用?Java AL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AL类属于org.lwjgl.openal包,在下文中一共展示了AL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.lwjgl.openal.AL; //导入依赖的package包/类
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);
}
示例2: init
import org.lwjgl.openal.AL; //导入依赖的package包/类
/**
* 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);
}
}
}
示例3: init
import org.lwjgl.openal.AL; //导入依赖的package包/类
@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);
}
}
示例4: initialize
import org.lwjgl.openal.AL; //导入依赖的package包/类
/**
* 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");
}
}
示例5: destroy
import org.lwjgl.openal.AL; //导入依赖的package包/类
/**
* 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();
}
}
示例6: BasicTest
import org.lwjgl.openal.AL; //导入依赖的package包/类
/**
* 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;
}
}
示例7: execute
import org.lwjgl.openal.AL; //导入依赖的package包/类
/**
* 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();
}
示例8: OpenAL
import org.lwjgl.openal.AL; //导入依赖的package包/类
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();
}
示例9: stop
import org.lwjgl.openal.AL; //导入依赖的package包/类
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();
}
示例10: cleanupInThread
import org.lwjgl.openal.AL; //导入依赖的package包/类
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();
}
示例11: dispose
import org.lwjgl.openal.AL; //导入依赖的package包/类
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) {
}
}
}
示例12: loop
import org.lwjgl.openal.AL; //导入依赖的package包/类
@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();
}
示例13: init
import org.lwjgl.openal.AL; //导入依赖的package包/类
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;
}
示例14: cleanUp
import org.lwjgl.openal.AL; //导入依赖的package包/类
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();
}
示例15: Sound
import org.lwjgl.openal.AL; //导入依赖的package包/类
public Sound()
{
System.out.print("SFX initialisation");
try
{
AL.create();
IntSource = alGenSources();
}
catch (LWJGLException e)
{
e.printStackTrace();
}
System.out.println(".");
}