how can we know if the microphone is functioning using jmf?

Hi everybody,

This code never output "DataSource Not detected" neither the microphone is connected or not.

CaptureDeviceInfo deviceInfo = (CaptureDeviceInfo) CaptureDeviceManager.getDeviceList(new AudioFormat(AudioFormat.LINEAR, 44100, 16, 1)).get(0);

DataSource inSource=Manager.createDataSource(deviceInfo.getLocator());

if(inSource.equals(null)) {System.out.println("DataSource Not detected");}

why inSource is never null?

how can we notify the user when no data is captured?

thx

[532 byte] By [zinounaa] at [2007-11-27 0:41:57]
# 1

I wanted to add that even with this code handling exceptions, exceptions are not displayed even if the microphone is not connected!

CaptureDeviceInfo deviceInfo = (CaptureDeviceInfo) CaptureDeviceManager.getDeviceList(newAudioFormat(AudioFormat.LINEAR, 44100, 16, 1)).get(0);

DataSource inSource = createDataSource(deviceInfo.getLocator());

protected DataSource createDataSource(MediaLocator locator)

{

try {

try {

return Manager.createDataSource(locator);

}

catch (NoDataSourceException ex) {

{System.out.println("NoDataSourceException: "+ex);

}

//The failure only concens us

return null;

}

catch (IOException ex) {

System.out.println("IOException: "+ex);

//The failure only concens us

return null;

}

}

finally {

}

}

please help if you have an answer

zinounagaina at 2007-7-11 22:56:05 > top of Java-index,Security,Cryptography...
# 2

I am not entirely sure I understand the problem

you are facing, but had some problems detecting

sound signals in an 'oscilloscope' style sound

based application, myself.

(Part of) my solution was to check on the signal

level being received, and ultimately I decided to

paint the signal level over the GUI. You might

get some tips from that example.

You can view the trace itself by following the

'install Audio Trace' link here..

http://www.physci.org/sound/audiotrace.html

The source (fairly recent) of the application can

be viewed/downloaded here..

http://www.physci.org/test/oscilloscope/

..look for the 'averageLevel' attribute, and work

back from there.

Message was edited by:

AndrewThompson64

AndrewThompson64a at 2007-7-11 22:56:05 > top of Java-index,Security,Cryptography...