List of usage examples for java.nio FloatBuffer clear
public final Buffer clear()
From source file:Main.java
public static FloatBuffer createFloatBuffer(final FloatBuffer reuseStore, final float... data) { if (data == null) { return null; }/* w ww . j a va 2 s . c o m*/ final FloatBuffer buff; if (reuseStore == null || reuseStore.capacity() != data.length) { buff = createFloatBuffer(data.length); } else { buff = reuseStore; buff.clear(); } buff.clear(); buff.put(data); buff.flip(); return buff; }
From source file:BufferTest.java
private long singleIndexedPut(float[] data, int elements, FloatBuffer target, int testTime) { long start = System.currentTimeMillis(); long elapsed = 0; int reps = 0; target.clear(); do {// w ww .jav a2s . c o m for (int i = 0; i < elements; i++) { target.put(i, data[i]); } reps++; elapsed = System.currentTimeMillis() - start; } while (elapsed < testTime); long bytes = (long) elements * (long) reps * 4; return bytes / elapsed / 1024; }
From source file:BufferTest.java
private long bulkPut(float[] data, int elements, FloatBuffer target, int testTime) { long start = System.currentTimeMillis(); long elapsed = 0; int reps = 0; target.clear(); do {/*from w w w . j a v a2 s .c om*/ target.put(data, 0, elements); target.flip(); reps++; elapsed = System.currentTimeMillis() - start; } while (elapsed < testTime); long bytes = (long) elements * (long) reps * 4; return bytes / elapsed / 1024; }
From source file:BufferTest.java
private long singlePut(float[] data, int elements, FloatBuffer target, int testTime) { long start = System.currentTimeMillis(); long elapsed = 0; int reps = 0; target.clear(); do {//from w ww . ja v a2 s . co m for (int i = 0; i < elements; i++) { target.put(data[i]); } target.flip(); reps++; elapsed = System.currentTimeMillis() - start; } while (elapsed < testTime); long bytes = (long) elements * (long) reps * 4; return bytes / elapsed / 1024; }
From source file:org.jtrfp.trcl.core.ResourceManager.java
public ResourceManager(final TR tr) { this.tr = tr; try {/*from ww w . j a va 2 s. c o m*/ Class.forName("de.quippy.javamod.multimedia.mod.loader.tracker.ProTrackerMod"); Class.forName("de.quippy.javamod.multimedia.mod.ModContainer"); // ModContainer uses the ModFactory!! } catch (Exception e) { tr.showStopper(e); } gpuResidentMODs = new CachedObjectFactory<String, GPUResidentMOD>() { @Override protected GPUResidentMOD generate(String key) { return new GPUResidentMOD(tr, getMOD(key)); }//end generate(...) }; soundTextures = new CachedObjectFactory<String, SoundTexture>() { @Override protected SoundTexture generate(String key) { try { final AudioInputStream ais = AudioSystem .getAudioInputStream(getInputStreamFromResource("SOUND\\" + key)); final FloatBuffer fb = ByteBuffer.allocateDirect((int) ais.getFrameLength() * 4) .order(ByteOrder.nativeOrder()).asFloatBuffer(); int value; while ((value = ais.read()) != -1) { fb.put(((float) (value - 128)) / 128f); } fb.clear(); return tr.soundSystem.get().newSoundTexture(fb, (int) ais.getFormat().getFrameRate()); } catch (Exception e) { tr.showStopper(e); return null; } } }; setupPODListeners(); }