Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Java and Sound

Posted on 2003-03-06
Medium Priority
Last Modified: 2010-03-31
I am writing a program that records phone calls coming in over voice over IP.  The program records sound fine when the voice over IP is not running, however when voice over ip is running my program cannot get access to the audio line.  What makes this problem strange is that if I launch windows sound recorder it records sound fine with the VoIP program running.  I can't use Sound Recorder for this because it only records for 60 seconds at a time.  
Question by:renton13
  • 3
  • 2
LVL 35

Expert Comment

ID: 8082884

do you have any code?

Are you just using Javasound?

Author Comment

ID: 8083310
AudioFormat     audioFormat = null;
          SoundEncryptor encrypt = null;
           // 8 kHz, 8 bit, mono
           audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000.0F, 8, 1, 1, 8000.0F, true);
          // 44.1 kHz, 16 bit, stereo
          //audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 2, 4, 44100.0F, false);
          DataLine.Info     info = new DataLine.Info(TargetDataLine.class, audioFormat);
          TargetDataLine     targetDataLine = null;
               targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
          catch (LineUnavailableException e)
               System.out.println("unable to get a recording line");
          AudioFileFormat.Type     targetType = AudioFileFormat.Type.AU;
          //CallRecorder     recorder = null;
          CallRecorder recorder = new CallRecorder(targetType,targetDataLine);
          //Thread t = new Thread(recorder);
This is the place where problem seems to be occuring.  When I attempt to open the audio line with this command: "targetDataLine.open(audioFormat)"  the try catch block trips throwing a LineUnavailableException.  I have tried to see if the system will still record if I remove the call to open the line and it then creates the file and immediatley closes it.  The start function in call recorder is nothing special all it does is start the audiosystem.write method.  And yes I am using java sound.   Like I said earlier what makes this so interesting is that the sound recorder in windows will run just fine
LVL 35

Expert Comment

ID: 8083929

Not sure if it will help, but there appear to be an implementation of a Voip java thingy here:


Maybe that can point you in the right direction?  I'm stumped :-/
LVL 35

Accepted Solution

TimYates earned 300 total points
ID: 8083940
Damn....wrong link... :-/

Hang on!...


there ;-)

Author Comment

ID: 8087621
Actually, I did a little more testing and I was able to get the program to work with Windows XP but not Windows 2000.  I'm going to start to research what is different in each to see why this only happens in Win2k.  Thanks for the link it may be helpful in the future

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question