Results 1 to 1 of 1
Thread: Cutting .wav file
- 06-27-2010, 09:50 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
Cutting .wav file
Hi, everyone .
The following code works perfectly for playing audio files.
I'd like to add another functionality .
While playing , if I press the stop button I want the already played
part of the file to get saved in another file.
Any help , especially in terms of code, will be highly appreciated.
thank you!
.................................................. .........
private void playAudio() {
try{
File soundFile = new File("555.wav");
audioInputStream = AudioSystem.
getAudioInputStream(soundFile);
audioFormat = audioInputStream.getFormat();
System.out.println(audioFormat);
DataLine.Info dataLineInfo =
new DataLine.Info(
SourceDataLine.class,
audioFormat);
sourceDataLine =
(SourceDataLine)AudioSystem.getLine(
dataLineInfo);
new PlayThread().start();
}catch (Exception e) {
e.printStackTrace();
System.exit(0);
}//end catch
}//end playAudio
//Inner class to play back the data from the audio file.
class PlayThread extends Thread{
byte tempBuffer[] = new byte[10000];
public void run(){
try{
sourceDataLine.open(audioFormat);
sourceDataLine.start();
int cnt;
while((cnt = audioInputStream.read(
tempBuffer,0,tempBuffer.length)) != -1){
if(cnt > 0){
sourceDataLine.write(
tempBuffer, 0, cnt);
}//end if
}//end while
sourceDataLine.drain();
sourceDataLine.close();
}
.................................................. .........
Similar Threads
-
how to change the layout of an input file and write to an output file
By renu in forum New To JavaReplies: 8Last Post: 05-12-2010, 07:19 PM -
Sending a File from Server to Client and saving the file to Clients computer
By al_Marshy_1981 in forum NetworkingReplies: 8Last Post: 02-18-2010, 12:54 PM -
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 09:53 AM -
Cutting parts of an image and reordering them
By pedjacar in forum Java 2DReplies: 2Last Post: 10-16-2008, 09:46 AM -
How to parse the CSV(Comma separation values)file and validate the file using java
By padmajap13 in forum Advanced JavaReplies: 7Last Post: 05-23-2008, 03:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks