Java GSM encoding from mic
Hi
I'm trying to encode a microphone stream into GSM using
org.tritonus.lowlevel.gsm.Encoder but I am receiving just static noise -
I've checked the raw PCM output and it's fine. Is there anything obvious
that's missing here?
Thanks
__________________________
The mic is opened as:
AudioInputStream ais=null;
DataLine.Info info_mic = new DataLine.Info(TargetDataLine.class,
new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000.0f, 16, 1, 2,
8000.0f, false)
);
TargetDataLine mic = (TargetDataLine) AudioSystem.getLine(info_mic);
mic.open();
mic.start();
ais = new AudioInputStream(mic);
_____________________
And the GSM frame encoder is:
/*------*/
byte [] gsmframe(AudioInputStream ais){
byte [] encd = new byte[33];
try{
byte [] b = new byte[320];
ais.read(b,0,b.length);
DataInputStream di = new DataInputStream(new ByteArrayInputStream(b));
short [] buf = new short[160];
short j=0;
for(int k=0; k<buf.length; k++){
j=di.readShort();
buf[k]=j;
}
org.tritonus.lowlevel.gsm.Encoder enc = new
org.tritonus.lowlevel.gsm.Encoder();
enc.encode(buf, encd);
}catch(Exception e){
System.out.println("error with microphone reading "+e);
return null;
}
return encd;
}
/*-------*/