io.github.mwttg.pixelartillery2d.sound.SoundBuffer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pixel-artillery-2d Show documentation
Show all versions of pixel-artillery-2d Show documentation
A library for 2D OpenGL and OpenAL support based on LWJGL 3
The newest version!
package io.github.mwttg.pixelartillery2d.sound;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL11;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class SoundBuffer {
private static final Logger LOG = LoggerFactory.getLogger(SoundBuffer.class);
private SoundBuffer() {}
static int create(final SoundData soundFileData) {
final var data = BufferUtils.createByteBuffer(soundFileData.data().length);
data.put(soundFileData.data());
data.flip();
final var id = AL11.alGenBuffers();
OpenAlCleanUp.addSoundBufferId(id);
AL11.alBufferData(id, soundFileData.openAlFormat(), data, soundFileData.sampleRate());
LOG.debug("... create SoundBuffer with id='{}'", id);
return id;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy