Java GSM encoding from mic

Discussion in 'Java' started by Crouchinho, Aug 18, 2006.

  1. Crouchinho

    Crouchinho Guest

    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;


    }
    /*-------*/
     
    Crouchinho, Aug 18, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dmoniac75
    Replies:
    0
    Views:
    1,226
    dmoniac75
    Mar 4, 2005
  2. =?ISO-8859-1?Q?Jorg_R=F8dsj=F8?=

    recording sound from mic in Windows?

    =?ISO-8859-1?Q?Jorg_R=F8dsj=F8?=, Apr 10, 2004, in forum: Python
    Replies:
    1
    Views:
    534
    Doug Holton
    Apr 10, 2004
  3. NightCrawler
    Replies:
    0
    Views:
    326
    NightCrawler
    Feb 12, 2008
  4. Sandro Paganotti

    Record and analyze sound from mic

    Sandro Paganotti, Oct 18, 2008, in forum: Ruby
    Replies:
    1
    Views:
    119
    Marc Heiler
    Oct 18, 2008
  5. Larry
    Replies:
    6
    Views:
    111
    Larry
    Jan 4, 2005
Loading...

Share This Page