List of usage examples for com.badlogic.gdx.audio AudioDevice writeSamples
public void writeSamples(float[] samples, int offset, int numSamples);
From source file:com.heartpirates.harthsip.AsapRadio.java
License:Open Source License
public void start() { final ASAP asap = this.asap; final AudioDevice device = this.device; Thread playbackThread = new Thread(new Runnable() { @Override/*w ww. j ava2 s . c o m*/ public void run() { byte[] bytes = new byte[1024 << 2]; int numSamples; while ((numSamples = asap.generate(bytes, bytes.length, 1)) > 0) { short[] shortPCM = getShortPCM(bytes, numSamples); device.writeSamples(shortPCM, 0, shortPCM.length); try { Thread.sleep(14); } catch (InterruptedException e) { e.printStackTrace(); } } } }); playbackThread.setPriority(Thread.NORM_PRIORITY); playbackThread.start(); }