×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    File format for recorded audio is missing

    Hi,

    I am working on a audio recording application. I have referred to the following example for the same:


    // Create a DataSource that captures live audio.
    Player p = Manager.createPlayer("capture://audio");
    p.realize();
    // Get the RecordControl, set the record location, and
    // start the Player and record for 5 seconds.
    RecordControl rc = (RecordControl)p.getControl("RecordControl");
    rc.setRecordLocation("file:/tmp/audio.amr");
    rc.startRecord();
    p.start();
    Thread.currentThread().sleep(5000);
    p.stop();
    rc.stopRecord();
    rc.commit();



    After recording, i find that the file is getting saved as "audio.amr" (0.0 Kb), but if i look in file Details under File Format it says "not available".

    Thus when i try to play the recorded file it says format not supported. But i have other .amr files that are working fine.

    Can someone please help me here.

    Thanks,
    Saket

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: File format for recorded audio is missing

    well it's alos pretty strange that it's size is 0.0 Kb, so even if it would recognize the file formate itw ouldn't play anything because the size is actually emtpy...

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    28

    Re: File format for recorded audio is missing

    Okay, at the peril of appearing foolish i would like to state that after re-writing the same code the app is working fine.

    For anybodys reference i am pasting both the original code that did not work and the re-written one below. I will go thru this again to find out what went wrong the first time. Although at the surface level both appear to be identical.

    Original Code: (File without format)

    try
    {
    //Create a player
    Player p;
    String value1,value2;
    String key="supports.audio.capture";
    //Check if audio capture is supportyed
    value1= System.getProperty(key);
    //Get the types of audio encodings supported
    value2=System.getProperty("audio.encodings");
    //Create a Player
    p = Manager.createPlayer("capture://audio");//?encoding=amr");
    //Initialize
    p.realize();
    //Verify if player is in realized state
    if(p.getState()==Player.REALIZED)
    {
    //Get RecordControl, Set RecordLocation and Record for 5 secs
    RecordControl rc=(RecordControl)p.getControl("RecordControl");

    rc.setRecordLocation("file:///C:/predefgallery/predeftones/Audio.amr");
    //Start Recorder
    rc.startRecord();
    //Open Player application
    p.start();
    //Check current state of the player
    if(p.getState()==Player.STARTED)
    {
    Form frm3=new Form("Player Started");
    Display.getDisplay(this).setCurrent(frm3);

    frm3.append("Going to Sleep");
    Thread.currentThread().sleep(5000);
    frm3.append("Awake");
    //Commit Recording
    rc.commit();
    //recordedSoundArray = output.toByteArray();
    p.close();
    //Check if player has stopped
    if(p.getState()==Player.CLOSED)
    {
    frm3.append("Player Stopped");
    }
    else
    {
    frm3.append("Player Not stopped");
    }
    }
    else
    {
    Form frm4=new Form("Player Unable to Start");
    Display.getDisplay(this).setCurrent(frm4);
    }
    }
    else
    {
    Form frm2=new Form("Player Not Realized");
    Display.getDisplay(this).setCurrent(frm2);
    }

    }
    catch(IOException ex)
    {
    Form frm3=new Form("Record Error");
    frm3.append(ex.getMessage());
    frm3.append(ex.toString());
    Display.getDisplay(this).setCurrent(frm3);
    }
    catch(MediaException ex)
    {
    Form frm3=new Form("Record Error");
    frm3.append(ex.getMessage());
    frm3.append(ex.toString());
    Display.getDisplay(this).setCurrent(frm3);
    }
    catch(InterruptedException ex)
    {
    Form frm3=new Form("Record Error");
    frm3.append(ex.getMessage());
    frm3.append(ex.toString());
    Display.getDisplay(this).setCurrent(frm3);
    }


    Now the revised one:(Baiscally the standard example for audio capture)

    try {
    // Create a DataSource that captures live audio.
    Player p = Manager.createPlayer("capture://audio");
    p.realize();
    // Get the RecordControl, set the record location, and
    // start the Player and record for 5 seconds.
    RecordControl rc = (RecordControl)p.getControl("RecordControl");
    rc.setRecordLocation("file:/tmp/audio.wav");
    rc.startRecord();
    p.start();
    Thread.currentThread().sleep(5000);
    p.stop();
    rc.stopRecord();
    rc.commit();
    } catch (IOException ioe) {
    } catch (MediaException me) {
    } catch (InterruptedException e) { }


    Please let me know if anyone finds anything here......

    Thanks,
    Saket

Similar Threads

  1. To play raw audio data file
    By pawans in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-12-11, 11:38
  2. Record Audio in .AMR format
    By nair.shanker in forum Symbian
    Replies: 1
    Last Post: 2008-09-09, 11:11
  3. S60 2nd to 3rd/ PlatformSecurity / Capabilities
    By jarkoos in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 4
    Last Post: 2007-04-14, 14:08
  4. Half Duplex Audio Streaming
    By subhrajyotisaha in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-05-25, 04:39
  5. 7650 basic audio recording format
    By gamit in forum Symbian
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

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