!7 static JButton button; static volatile Capturer cap; static File wavFile; p-substance { showControls(jCenteredLine(button = jbutton("Record!", f recordOrStop))); } svoid recordOrStop { if (cap != null) { cap.stop(); byte[] pcm = cap.getPCM(); infoMessage("Got " + l(pcm) + " bytes PCM!"); pcmToWAVE(pcm, cap.format(), wavFile); infoBox("Wrote " + f2s(wavFile) + " (" + wavFile.length() + " bytes)"); cap = null; setText(button, "Record!"); } else { AudioLine line = first(allTargetDataLines()); assertNotNull("Need audio input line!", line); DataLine dataLine = cast line.open(); print("Capturing"); wavFile = prepareProgramFile(ymd_minus_hms() + ".wav"); cap = captureAudioFromLine2(dataLine, sphinxAudioFormat()); setText(button, "Stop"); } }