public void StopMicrophone() { if (rt != null) { rt.pause(); rt.interrupt(); rt = null; } }
/** * Start recording. The stop method will give us the clip. * * @see #stop */ public void start() { synchronized (lock) { if (recorder != null) { recorder.stopRecording(); } recorder = new RecordThread(); recorder.start(); } }
/** * Stop recording and give us the clip. * * @return the clip that was recorded since the last time start was called * @see #start */ public short[] stop() { synchronized (lock) { if (recorder == null) { return new short[0]; } ByteArrayOutputStream out = recorder.stopRecording(); microphone.close(); recorder = null; byte audioBytes[] = out.toByteArray(); ByteArrayInputStream in = new ByteArrayInputStream(audioBytes); try { short[] samples = RawReader.readAudioData(in, inFormat); if (downsample) { samples = Downsampler.downsample( samples, (int) (inFormat.getSampleRate() / 1000.0f), (int) (outFormat.getSampleRate() / 1000.0f)); } return samples; } catch (IOException e) { e.printStackTrace(); return new short[0]; } } }
public void StartMicrophone() { if (rt == null) { rt = new RecordThread(); rt.start(); } }