• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I cannot find my microphone- Java Media Framework Query

 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My microphone is not detected by the code that is supposed to do exactly that:
import javax.media.*;
import javax.media.format.*;
import java.io.*;
import java.util.*;
public class Test{
public static void main(String a[]) throws Exception{
CaptureDeviceInfo di = null;
Player p = null;
Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat("linear", 44100, 16, 2));
System.out.println(deviceList.size());
}
}
The deviceList.size() should return 1 if the program finds the mic (my mic is installed). The classpath and JMFHOME is set properly. I am using cross-platform version of JMF.
Should I check something else with this code? Can you folks out there suggest anything?
Thanx in advance,
Maki Jav
[ September 09, 2003: Message edited by: Maki Jav ]
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your program yields 2 in my computer with the Windows implementation.
Looking at Supported capturer devices it seems that the cross platform implementation should support JavaSound.
Try being less specific with the format like this:
CaptureDeviceManager.getDeviceList( new AudioFormat(AudioFormat.LINEAR));
And let me know if it works because I am also interested in closs-platform implementation of JMF.
By the way, the url above is for the the last JMF version: JMF2.1.1e
A previous one might not have the ability for capturing audio in the cross platform version.
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jose!
I have two codes to test the concept, but first of all let me tell you that I have the latest JMF pack ie 2.1.1. And I am using JSDK 1.3 along with it.
The code for checking this support without being very specific is :
import java.io.*;
import java.awt.*;
import javax.media.*;
import javax.media.format.AudioFormat;
import javax.media.format.*;
import java.util.*;
public class TestRecorder{
public static void main(String args[]){
String audioformats[]={AudioFormat.LINEAR,
AudioFormat.TRUESPEECH,
AudioFormat.MPEG,
AudioFormat.ALAW,
AudioFormat.ULAW,
AudioFormat.DOLBYAC3,
AudioFormat.DVI,
AudioFormat.DVI,
AudioFormat.G723,
AudioFormat.G728,
AudioFormat.G729,
AudioFormat.GSM,
AudioFormat.MAC3,
AudioFormat.MAC6,
AudioFormat.MPEGLAYER3,
AudioFormat.MSADPCM,
AudioFormat.MSNAUDIO,
AudioFormat.MSRT24,
AudioFormat.VOXWAREAC8,
AudioFormat.VOXWAREAC10,
AudioFormat.VOXWAREAC16,
AudioFormat.VOXWAREAC20,
AudioFormat.VOXWAREMETASOUND,
AudioFormat.VOXWAREMETAVOICE,
AudioFormat.VOXWARERT29H,
AudioFormat.VOXWARETQ40,
AudioFormat.VOXWARETQ60,
AudioFormat.VOXWAREVR12,
AudioFormat.VOXWAREVR18};
try {
FileWriter fr=new FileWriter("Supportedformats.txt",true);
BufferedWriter bwr=new BufferedWriter(fr,1000);
String ft="";
for (int i=0;i<audioformats.length;i++){
AudioFormat af=new AudioFormat(audioformats[i]);
ft=af.toString();
System.out.println(ft);
bwr.write(ft);
bwr.newLine();
Vector v=CaptureDeviceManager.getDeviceList(af);
int a=v.size();
System.out.println(a);
bwr.write(""+a);
bwr.newLine();
bwr.newLine();
}
bwr.close();
fr.close();
}
catch (Exception e) {
System.out.println(e.toString());
}
}
}
The above program yield Zero for all.
And now the other program for more specific searching for supported formats:
import javax.media.format.AudioFormat;
import java.util.Vector;
import javax.media.*;
import java.io.*;
import jmapps.util.StateHelper;
import javax.media.protocol.FileTypeDescriptor;
import javax.media.protocol.DataSource;
import javax.media.control.StreamWriterControl;
public class Test {
public static void main(String args[]){
CaptureDeviceInfo di = null;
Processor p = null;
StateHelper sh = null;
String formats[]={AudioFormat.LINEAR,
AudioFormat.ALAW,
AudioFormat.DOLBYAC3,
AudioFormat.DVI,
AudioFormat.DVI_RTP,
AudioFormat.G723,
AudioFormat.G723_RTP,
AudioFormat.G728,
AudioFormat.G728_RTP,
AudioFormat.G729,
AudioFormat.G729_RTP,
AudioFormat.G729A,
AudioFormat.G729A_RTP,
AudioFormat.GSM,
AudioFormat.GSM_MS,
AudioFormat.GSM_RTP,
AudioFormat.IMA4,
AudioFormat.MAC3,
AudioFormat.MAC6,
AudioFormat.MPEG,
AudioFormat.MPEGLAYER3,
AudioFormat.MSADPCM,
AudioFormat.MSNAUDIO,
AudioFormat.MSRT24,
AudioFormat.TRUESPEECH,
AudioFormat.ULAW,
AudioFormat.ULAW_RTP,
};
int [] kilohtz={48000,44100,32000,24000,22050,16000,12000,11025,8000};
int bit[]={16,8,4};
int monostereo[]={2,1};
int calc=0;
Vector deviceList =new Vector();
String ms="";
for (int g=0;g<formats.length;g++)
for (int i=0;i<kilohtz.length;i++){
for (int j=0;j<bit.length;j++){
for (int k=0;k<monostereo.length;k++){
calc++;
deviceList= CaptureDeviceManager.getDeviceList(new
AudioFormat(formats[g], kilohtz[i], bit[j], monostereo[k]));
if (deviceList.size() > 0){
di = (CaptureDeviceInfo)deviceList.firstElement();
if(monostereo[k]==1)ms="Mono";
else ms="Stereo";
System.out.println("GOT ONE "+formats[g]+" "+ kilohtz[i]+"htz "+bit[j]+"bit "+ms);
System.out.println(di);
}
}
}
}
System.out.println("Checked "+calc);
}
}
The above program acts the same... no result!!!

Let me have something on this plz!
Thanks for your reply !
Thanx in Advance
Maki Jav
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maki,
Your program prints two for the first line in my computer. I am using the latest jsdk (1.4.2_01) and jmf (2.1.1e) for windows. Take notice is "e" not "jmf 2.1.1.c", which was the previous one.
I guess the microphone is not likely to capture other format than linear.
did you test it with a non Java program?
[ September 13, 2003: Message edited by: Jose Botella ]
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Jose,
You are quite right in saying that mic can only capture linear.

I downloaded the Windows implementation of JMF 2.1.1e and it is running fine ie giving me two for the first program of mine. This I did on my office computer. The computer has jdk1.3 installed on it. So, I think that the JSDK version is not the issue. Please note that this very computer was not yielding results with JMF 2.1.1e (cross-platform).
I just happened to look at the descriptions given for each at the page:
http://java.sun.com/products/java-media/jmf/2.1.1/setup.html
and noticed that:
JMF 2.1.1 -- A cross-platform version of JMF for Java clients. To set up on a Java client, you need to download the Cross-platform Java install package, which contains only Java bytecodes (no native code).Note the Java Sound API reference implementation is not included with the cross-platform version of JMF.
For other implementations, native libraries and the Java Sound API reference implementation is included.

Could it the reason behind this strange 'behavioural' difference between the two implementations? Or is it a bug that we have discovered?
How to go about it now? should we include something ourselves in the classpath or what?
RSVP
Thanx in Advance
Maki Jav
 
Maki Jav
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am still waiting for a reply!
Can someone tell me why the methods are not woking in the alljava (cross- platform) api while they do work windows performance pack.
Do any one else has a similar problem?
Thanx,
Maki Jav
 
reply
    Bookmark Topic Watch Topic
  • New Topic