ByteBuffer buf = ByteBuffer.wrap(rawSamples);
ShortBuffer shortBuf = buf.asShortBuffer();
while (!terminated) { // Note: sourceDataLine.write seems to clear the interrupted flag, and so Thread.interrupted() doesn't work here.
PdBase.process(ticks, dummy, samples);
shortBuf.rewind();
shortBuf.put(samples);
sourceDataLine.write(rawSamples, 0, rawSamples.length);
}
// Shutdown.