Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2009

    Problem in sending audio from a phone to server


    I am making a phone application(on Nokia N79) in J2ME which records a 10-second audio and then send it to the server(apache-tomcat). The problem is that when I see the audio(in Audacity) received at the server, the audio appears broken, ie, its correct for some seconds and then shows zero amplitude for the next few seconds and so on. You can also see the screenshot at http://www.cse.iitb.ac.in/~ankushjai...Screenshot.png.

    The sampling rate of the mic is 8000 Hz. Also, when I extract the header information, it shows me the that there is 159Kb of data but the file size as shown in the file Properties is 222 Kb.

    Can someone suggest me how to properly get the audio file on the server ??

    Thanks in advance.

  2. #2
    Super Contributor
    Join Date
    Feb 2006

    Re: Problem in sending audio from a phone to server

    Did u try with the simulator.If so whats the outcome.


  3. #3
    Registered User
    Join Date
    Jul 2009

    Re: Problem in sending audio from a phone to server

    The simulator shows an error that there is no recording input available. I tried to record and and save it on the phone itself using RecordControl.setRecordLocation(). The audio was perfectly recorded. I think there is a problem at the server side, particularly, with the writing of the data into the .wav file.

    This is the part of my J2ME code :

    //bos is the ByteArrayOutputStream into which the recordControl sets its record stream.
    bis = new ByteArrayInputStream(bos.toByteArray());

    HttpConnection c = null;
    c = (HttpConnection)Connector.open(url);

    OutputStream is = null;
    is = c.openDataOutputStream();

    byte[] data = new byte [8];
    int readbytes = 0;
    while( (readbytes = bis.read(data)) != -1) {

    This is how I receive the data at the server side :

    String fileName = "file.wav";

    String mp3Dir = ".";

    BufferedInputStream buf = null;
    try {

    File mp3 = new File(mp3Dir + "/" + fileName);
    FileOutputStream stream = new FileOutputStream(mp3);

    response.addHeader("Content-Disposition", "attachment; filename="
    + fileName);

    response.setContentLength((int) mp3.length());

    FileInputStream input = new FileInputStream(mp3);
    buf = new BufferedInputStream(request.getInputStream());
    int readBytes = 0;
    byte[] data = new byte[8];

    int i=0; //for debugging purpose

    while ((readBytes = buf.read(data)) != -1) {

    //String asd = new String(data);
    //out1.write(i+" "+data.toString()+"\n");


    Also, I would like to bring to your notice that the value of "i" I get, is consistent. This means that the data is received but not written correctly.

  4. #4
    Super Contributor
    Join Date
    Feb 2006

    Re: Problem in sending audio from a phone to server

    have u tried with c.setRequestMethod(HttpConnection.POST);


Similar Threads

  1. Nokia Gamer (GamR) - concept phone
    By tgm91 in forum General Development Questions
    Replies: 4
    Last Post: 2008-10-01, 21:34
  2. Replies: 3
    Last Post: 2008-09-09, 04:53
  3. How to initiate a GPRS connection to the mobile phone from a remote server?
    By VigenIssahhanjan in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2004-11-22, 08:50
  4. which nokia phone captures audio and sends it via BT?
    By mistay in forum Bluetooth Technology
    Replies: 5
    Last Post: 2004-10-03, 19:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts