Recording for time determined by volume of input

This question already has an answer here:


Whilst I'm not overly familiar with the Java Sound API, a quick google search of Java Sound API provides a lot of information and code snippets.

You could use something like this

In order to start or stop the recording based on volume level, you could call the getLevel() method on the DataLine Object as a condition prior to line.Start() and line.stop() methods to check current volume from your mic.


if(line.getLevel() < 0.3){

description of getLevel() method from javadocs Obtains the current volume level for the line. This level is a measure of the signal's current amplitude,The range is from 0.0 (silence) to 1.0 (maximum possible amplitude for the sound waveform). The units measure linear amplitude, not decibels.


 ? sawtooth generator wave simple. java
 ? PDFBox creating Sound object with link/reference to external mp3 or wav file
 ? Home directory not accessible: Permission denied java.lang.IllegalArgumentException: No line matching interface SourceDataLine
 ? javasound minim processing
 ? Java sound doesn't work on Windows, but work on OS X
 ? How to keep track of audio playback position?
 ? How to clear the `TargetDatatLine` read buffer
 ? square wave frequency doesn't change smoothly
 ? What is a MIDI soundbank?
 ? Play variable tone with Java?