use of org.terasology.audio.StaticSoundData in project Terasology by MovingBlocks.
the class OggSoundFormat method load.
@Override
public StaticSoundData load(ResourceUrn urn, List<AssetDataFile> inputs) throws IOException {
try (OggReader reader = new OggReader(inputs.get(0).openStream())) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ByteStreams.copy(reader, bos);
ByteBuffer data = BufferUtils.createByteBuffer(bos.size()).put(bos.toByteArray());
data.flip();
return new StaticSoundData(data, reader.getChannels(), reader.getRate(), 16);
} catch (IOException e) {
throw new IOException("Failed to load sound: " + e.getMessage(), e);
}
}
Aggregations