Results 1 to 3 of 3
- 03-26-2009, 09:56 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Problems with Java Audio Recording
Hi all,
First of all thank you for all for reading this post.. i'm new to this forum and now i need help with java audio recording...
I'm doing a project in java and for that i have to record a particular sound generated on another device and have extract data from the recorded audio signal..
Before startin in java we implemented a prototype of our project in matlab. There its working perfectly fine and the same thing we did using java. i'm using TargetDataLine object for recording it. But while we record it using java with the same audio format and time line we are getting a large number of samples when compared to that recorded using matlab. And also the range of values also differ a lot.We tried out many ways but we were not able to find the bug...
i'm attaching the code hereby
public void recordWhisper()
{
try
{
ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
DataLine.Info dataLine=new DataLine.Info(TargetDataLine.class,audioFormat);
TargetDataLine targetDataLine=(TargetDataLine)AudioSystem.getLine (dataLine);
targetDataLine.open(audioFormat);
targetDataLine.start();
byte tempBuffer[] = new byte[10000];
byteArrayOutputStream =new ByteArrayOutputStream();
byte[] data;
System.out.println("sss");
while(stopCapture==false)
{
int cnt = targetDataLine.read(tempBuffer,0,tempBuffer.length );
if(cnt > 0){
byteArrayOutputStream.write(tempBuffer, 0, cnt);
}//end if
}//end while
byteArrayOutputStream.close();
data =byteArrayOutputStream.toByteArray();
audioData=new double[data.length];
for(int i=0;i<data.length;i++)
{ audioData[i]=new Byte(data[i]).doubleValue();
}
}
catch (Exception e)
{
e.printStackTrace();
System.exit(0);
}//end catch
}
is that is due to buffer overwriting or something..
can anybody suggest a method to correct it..
waiting for your sudden response
Thank you..:)
- 03-26-2009, 09:00 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
It looks like your read/write while loop will never end because the control variable stopCapture is never set true (mind you it is never declared). I don't see how that code ever stops without an exception.
- 03-27-2009, 10:18 AM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
playing audio in J-App??
By ashton in forum New To JavaReplies: 3Last Post: 01-30-2009, 08:50 AM -
Control audio sound
By Masuka in forum Sun Java Wireless ToolkitReplies: 0Last Post: 08-05-2008, 10:24 AM -
Download audio tracks for films
By jSarK0Y in forum Forum LobbyReplies: 0Last Post: 04-30-2008, 01:06 AM -
Please help Transmitting Audio and Video using RTP
By pedaramanareddy in forum New To JavaReplies: 0Last Post: 01-03-2008, 02:39 PM -
Audio Recorder
By elizabeth in forum Java AppletsReplies: 1Last Post: 08-06-2007, 09:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks