Warning: session_start(): open(/var/lib/php/sessions/sess_s54i2blqb5hjhspn2hc2n52b4r, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass StreamSoundToAPlay implements AutoCloseable {
Process process;
InputStream in;
OutputStream out;
int sampleRate = 44100, channels = 2, bits = 16;
int bufSizeMS = 0; // 0 = default
double duration = yearsToSeconds(1); // max seconds
GSWavFile wavStream;
long frameCounter = 0;
void start ctex {
assertOnPATH("aplay");
Process process = Runtime.getRuntime().exec("aplay"
+ (bufSizeMS == 0 ? "" : " -B " + bufSizeMS));
// should probably print those instead
drainStreamInNewThread(process.getInputStream());
drainStreamInNewThread(process.getErrorStream());
out = process.getOutputStream();
long numFrames = (long)(duration * sampleRate);
wavStream = GSWavFile.newWavFile(out, null, channels, numFrames, bits, sampleRate);
}
void writeSamples(short[] samples) ctex {
if (samples != null) for (short x : samples) {
wavStream.writeSample(x);
++frameCounter;
}
}
public void close {
dispose wavStream; // also closes the stream & thereby ends the process
}
}