sclass StreamingSoundSource extends VF1 { bool enabled; L chunks = synchroLinkedList(); int minChunksToPlay = 2; short[] samples; int sampleIndex; public void get(double[] pair) { pair[0] = pair[1] = 0; if (!enabled) ret; if (samples == null) { if (l(chunks) < minChunksToPlay) { minChunksToPlay = 2; ret; } minChunksToPlay = 1; samples = syncPopFirst(chunks); sampleIndex = 0; } pair[0] = samples[sampleIndex]; pair[1] = samples[sampleIndex+1]; sampleIndex += 2; if (sampleIndex >= l(samples)) samples = null; } void addChunk(short[] chunk) { chunks.add(chunk); } void setEnabled(bool b) { enabled = b; if (!b) chunks.clear(); } }