Java GSM encoding from mic

C

Crouchinho

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;


}
/*-------*/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top