System.out.println("format? :" + sourceDataLine.getFormat());
if (line instanceof DataLine) { DataLine dataLine = (DataLine)line; AudioFormat audioFormat = dataLine.getFormat(); data = new Object[7+controls.length][2];
dataLine = AudioSystem.getSourceDataLine( clip.getFormat() ); return (frames/(long)dataLine.getFormat().getSampleRate())*1000; return (int)(milliseconds/dataLine.getFormat().getSampleRate()); int size = dataLine.getBufferSize()*(format.getChannels()/2)/bufferUpdateFactor; int framesSinceLast = (int)((timeSinceLastPositionSet/1000f)* dataLine.getFormat().getFrameRate()); int framesRemainingTillTime = size - framesSinceLast; return framePosition int frameSize = dataLine.getFormat().getFrameSize(); int bufSize = dataLine.getBufferSize(); boolean startOrMove = true; } else { framesRead = bytesRead/ dataLine.getFormat().getFrameSize(); tempData = Arrays.copyOfRange(data, 0, bytesRead);
import javax.sound.sampled.*; import java.io.*; import javax.swing.*; public class Tester { static Thread th; public static void main(String[] args) throws Exception { Clip clip = AudioSystem.getClip(); AudioInputStream ais = AudioSystem.getAudioInputStream(new File("d:/UnderTest/wavtester.wav")); clip.open(ais); clip.loop(0); // Calculate totalFrames long totalFrames = (long)(clip.getFrameLength() * clip.getFormat().getFrameRate()); Thread.sleep( ( totalFrames* 1000 )); // pause the thread till the sound plays System.out.println(clip.getFrameLength()); System.out.println(clip.getFormat().getFrameRate()); } }
if (line instanceof DataLine) { DataLine dataLine = (DataLine)line; AudioFormat audioFormat = dataLine.getFormat(); data = new Object[7+controls.length][2];