Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Smile 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..:)

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

    Default

    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.

  3. #3
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    Sorry i haven't mentioned about it.. i have just given only that function.. i have a GUI to start and stop recording and it is working fine..

Similar Threads

  1. playing audio in J-App??
    By ashton in forum New To Java
    Replies: 3
    Last Post: 01-30-2009, 08:50 AM
  2. Control audio sound
    By Masuka in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 08-05-2008, 10:24 AM
  3. Download audio tracks for films
    By jSarK0Y in forum Forum Lobby
    Replies: 0
    Last Post: 04-30-2008, 01:06 AM
  4. Please help Transmitting Audio and Video using RTP
    By pedaramanareddy in forum New To Java
    Replies: 0
    Last Post: 01-03-2008, 02:39 PM
  5. Audio Recorder
    By elizabeth in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 09:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •