List of utility methods to do Sound File
int | durationMillis(String audioPath) Returns the duration in milliseconds of the audio file whose path is specified. int durationMillis = -1; File file = new File(audioPath); try (AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file)) { AudioFormat format = audioInputStream.getFormat(); long frames = audioInputStream.getFrameLength(); durationMillis = (int) Math.ceil((frames + 0.0) / format.getFrameRate() * 1000); } catch (Exception e) { e.printStackTrace(); ... |
byte[] | sliceWav(InputStream is, long starttime, long duration) slice Wav AudioInputStream sourceStream = AudioSystem.getAudioInputStream(is); AudioFormat format = sourceStream.getFormat(); int bytesPerSecond = format.getFrameSize() * (int) format.getFrameRate(); sourceStream.skip(starttime * bytesPerSecond / 1000); long framesOfAudioToCopy = duration * (int) format.getFrameRate() / 1000; if (duration == 0) { framesOfAudioToCopy = sourceStream.getFrameLength() * format.getFrameSize() - starttime * bytesPerSecond / 1000; ... |
double | getAudioDuration(final URI wavFile) get Audio Duration return getAudioDuration(new File(wavFile)); |
double | getAudioDuration(final URI wavFile) get Audio Duration return getAudioDuration(new File(wavFile)); |