×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    CMMFDevSound Recording problem

    Hi,
    How can i write the recorded data in CMMFDevSound API.I have tried with below code but not getting Proper recorded data. I have used this function in
    BufferToBeEmptied(CMMFBuffer* aBuffer).Please help me on this.


    CMMFDataBuffer* buffer = static_cast<CMMFDataBuffer*>(aBuffer);

    HBufC8* iStreamBuffer=HBufC8::NewMaxL(buffer->BufferSize());
    TPtr8 bufferPtr = iStreamBuffer->Des();//
    bufferPtr=buffer->Data();

    audiofile.WriteL(bufferPtr);
    delete iStreamBuffer;
    iMMFDevSound->RecordData();


    Thanks,
    Last edited by goldenlife; 2009-06-08 at 15:23.

  2. #2
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi All,
    Please help me on above problem.I have recorder the data but not getting play using above code.

    thanks.

  3. #3
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,957

    Re: CMMFDevSound Recording problem

    hey use the following code:



    User::LeaveIfError(iTargetFile.Write(((CMMFDataBuffer*)aBuffer)->Data()));

    // continue recording
    User::After(15000000);
    iDevSound->RecordData();


    some delay is required before you can again start recording.

    also iTargetFile contains a file with extension .raw

  4. #4
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi vineet,
    thx for a reply. i have tried your solution but not get play the file.i am trying for amr recording and also tried with raw but issue is not solved.

  5. #5
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,347

    Re: CMMFDevSound Recording problem

    Hi goldenlife,
    How you trying to record audion and play the file? Which codec you are used while record an audio?

    Some useful links:

  6. #6
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi,
    I am recording a audio file in
    TRAP(initError,iMMFDevSound->InitializeL(*this,KMMFFourCCCodeAMR1,EMMFStateRecording));
    this is my intialization part of CMMFDevSound api.
    below is
    if(aError == KErrNone)
    {
    // ClassLog(_L("\n Start Recording "));
    TMMFPrioritySettings iPrioritySettings;
    //CEikonEnv::InfoWinL(_L("InitializeComplete(TInt aError)"),_L(""));
    // priority and preference settings
    iPrioritySettings.iPref = (TMdaPriorityPreference)0x05210001;
    iPrioritySettings.iPriority = TMdaPriority(80);
    iPrioritySettings.iState = EMMFStateRecording;
    iMMFDevSound->SetPrioritySettings(iPrioritySettings);
    // ClassLog(_L("\n Stop Recording "));
    TMMFCapabilities conf;
    conf = iMMFDevSound->Config();
    conf.iBufferSize = 160;
    conf.iRate = EMMFSampleRate8000Hz;
    conf.iChannels = EMMFMono;
    conf.iEncoding = EMMFSoundEncoding16BitPCM;
    // CEikonEnv::InfoWinL(_L("2 InitializeComplete(TInt aError)"),_L(""));
    iMMFDevSound->SetConfigL(conf);

    }

    and i have used RFileWriteStream to write the audio data
    audiofile.WriteL(((CMMFDataBuffer*)aBuffer)->Data());
    Please let me know what is wrong in above code.

    thanks for a reply

  7. #7
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,347

    Re: CMMFDevSound Recording problem

    Check that you don't forgot to write amr header (AMR header is #!AMR\n) into audiofile.

  8. #8
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi,
    I have done that also

    const TUint8 KAMRNBHeader[KAMRHeaderLength] = { 0x23, 0x21, 0x41, 0x4d, 0x52, 0x0a };
    TInt err = audiofile.Open(fs,iFileName,EFileWrite|EFileStream);
    for (int i = 0; i < KAMRHeaderLength; i++)
    audiofile.WriteUint8L(KAMRNBHeader[i]);
    is there problem while recording data into the file? I am getting 4096 buffer size data each callback of BufferToBeEmptied(CMMFBuffer* aBuffer) .

    thanks

  9. #9
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,347

    Re: CMMFDevSound Recording problem

    Quote Originally Posted by goldenlife View Post
    iMMFDevSound->InitializeL(*this,KMMFFourCCCodeAMR1,EMMFStateRecording
    ? May be you mean KMMFFourCCCodeAMR...

    Try to replace
    Code:
    iPrioritySettings.iPref = (TMdaPriorityPreference)0x05210001;
    ...
    conf.iBufferSize = 160;
    with
    Code:
    iPrioritySettings.iPref = (TMdaPriorityPreference)2;
    ...
    conf.iBufferSize = 0x1024;

  10. #10
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi
    thanks once again but still not get sloved the issue.when i try to start playing by native player it immediately stop it means there is something wrong when i write the recorded data.

    Thanks,

  11. #11
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,347

    Re: CMMFDevSound Recording problem

    Try to use this code for recording audio:
    Code:
    const TUint8 KAmrHeader[] = {'#', '!', 'A', 'M', 'R', 0xA};
    
    iFs = CEikonEnv::Static()->FsSession();
      
    TInt errFile = audiofile.Open(iFs, aRecordFileName, EFileStream | EFileWrite);
    User::LeaveIfError(errFile);
    
    audiofile.WriteL(TPtrC8(KAmrHeader, sizeof(KAmrHeader)));
    
    iMMFDevSound = CMMFDevSound::NewL();
      
    User::After(500);
     
    TRAPD(err, iMMFDevSound->InitializeL(*this, KMMFFourCCCodeAMR, EMMFStateRecording));
    
    .....
    
    TMMFPrioritySettings settings;
    settings.iPriority = 0x46;
    settings.iPref = (TMdaPriorityPreference)2;
      
    iMMFDevSound->SetPrioritySettings(settings);
    
    .....
    
    TMMFCapabilities conf;
    conf = iMMFDevSound->Config();
    conf.iRate = EMMFSampleRate44100Hz;
    conf.iEncoding = EMMFSoundEncoding16BitPCM;
    conf.iChannels = EMMFMono;
    conf.iBufferSize = 0x1024;
                   
    TRAPD(error, iMMFDevSound->SetConfigL(conf));
    
    iMMFDevSound->SetGain(iMMFDevSound->MaxGain());
    TRAPD(err, iMMFDevSound->RecordInitL());
    
    .....
    
    void C***::BufferToBeEmptied(CMMFBuffer* aBuffer)
       {
        CMMFDataBuffer* buffer = static_cast<CMMFDataBuffer*>(aBuffer);
       
        TRAPD(err, audiofile.WriteL(buffer->Data()));
        
        if (err != KErrNone)
           {
           ///
           }
        }
    Last edited by A.A.M.; 2009-06-10 at 14:30.

  12. #12
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    62

    Re: CMMFDevSound Recording problem

    Hi A.A.M,
    Thanks it works.

  13. #13
    Registered User
    Join Date
    Feb 2010
    Location
    India
    Posts
    281

    Thumbs up Re: CMMFDevSound Recording problem

    Quote Originally Posted by A.A.M. View Post
    Try to use this code for recording audio:
    Code:
    const TUint8 KAmrHeader[] = {'#', '!', 'A', 'M', 'R', 0xA};
    
    iFs = CEikonEnv::Static()->FsSession();
      
    TInt errFile = audiofile.Open(iFs, aRecordFileName, EFileStream | EFileWrite);
    User::LeaveIfError(errFile);
    
    audiofile.WriteL(TPtrC8(KAmrHeader, sizeof(KAmrHeader)));
    
    iMMFDevSound = CMMFDevSound::NewL();
      
    User::After(500);
     
    TRAPD(err, iMMFDevSound->InitializeL(*this, KMMFFourCCCodeAMR, EMMFStateRecording));
    
    .....
    
    TMMFPrioritySettings settings;
    settings.iPriority = 0x46;
    settings.iPref = (TMdaPriorityPreference)2;
      
    iMMFDevSound->SetPrioritySettings(settings);
    
    .....
    
    TMMFCapabilities conf;
    conf = iMMFDevSound->Config();
    conf.iRate = EMMFSampleRate44100Hz;
    conf.iEncoding = EMMFSoundEncoding16BitPCM;
    conf.iChannels = EMMFMono;
    conf.iBufferSize = 0x1024;
                   
    TRAPD(error, iMMFDevSound->SetConfigL(conf));
    
    iMMFDevSound->SetGain(iMMFDevSound->MaxGain());
    TRAPD(err, iMMFDevSound->RecordInitL());
    
    .....
    
    void C***::BufferToBeEmptied(CMMFBuffer* aBuffer)
       {
        CMMFDataBuffer* buffer = static_cast<CMMFDataBuffer*>(aBuffer);
       
        TRAPD(err, audiofile.WriteL(buffer->Data()));
        
        if (err != KErrNone)
           {
           ///
           }
        }
    when opened the output amr file -12003 error occured.

    The following code is not working for me..please point out error


    const TUint8 KAmrHeader[] = {'#', '!', 'A', 'M', 'R', 0xA};

    iFs = CEikonEnv::Static()->FsSession();

    TInt errFile = writerStream.Replace(iFs, KAMR , EFileStream | EFileWrite);
    User::LeaveIfError(errFile);

    writerStream.WriteL(TPtrC8(KAmrHeader, sizeof(KAmrHeader)));


    //
    // iFs.Connect();
    //
    // //fs is ur file session and fileName is name of ur file.
    // writerStream.Replace(iFs, KAMR, EFileWrite);
    //
    // // Write the six-byte AMR header, so that the file can be used by other
    // // applications as well.
    // for (int i = 0; i < KAMRHeaderLength; i++)
    // writerStream.WriteUint8L(KAMRNBHeader[i]);

    Dev = CMMFDevSound::NewL();
    User::After(500);
    Dev->InitializeL(*this, KMMFFourCCCodeAMR, EMMFStateRecording);

    //Dev->SetRecordBalanceL(Dev->80,80);
    TMMFPrioritySettings settings;
    settings.iPriority = 0x46;
    settings.iPref = (TMdaPriorityPreference)2;
    Dev->SetPrioritySettings(settings);

    TMMFCapabilities conf;
    conf = Dev->Config();
    conf.iRate = EMMFSampleRate44100Hz;
    conf.iEncoding = EMMFSoundEncoding16BitPCM;
    conf.iChannels = EMMFMono;
    conf.iBufferSize = 0x1024;

    TRAPD(error, Dev->SetConfigL(conf));

    Dev->SetGain(Dev->MaxGain());
    Dev->RecordInitL();

    Dev->RecordData();


    ----------------

    void CMDevRecordContainer::BufferToBeEmptied(CMMFBuffer* aBuffer)
    {

    buffer = static_cast<CMMFDataBuffer*>(aBuffer);
    TRAPD(err, writerStream.WriteL(buffer->Data()));
    if (err != KErrNone)
    {
    CEikonEnv::InfoWinL(_L(""), _L("Error writing data"));
    }
    //CEikonEnv::InfoWinL(_L(""), _L("Buffer emptied"));
    Dev->RecordData();

    }

  14. #14
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: CMMFDevSound Recording problem

    Although I do not know the answer, for those who could reply, it may be useful telling if you have modified anything in A.A.M.'s code (or just re-posted it), and the device model you are using.

Similar Threads

  1. How to solve this recording problem??
    By vivekuv in forum Audio
    Replies: 1
    Last Post: 2008-09-12, 08:25
  2. problem recording
    By vrnreddy84 in forum Symbian
    Replies: 2
    Last Post: 2008-07-14, 09:59
  3. recording problem
    By vrnreddy84 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2008-07-14, 09:55
  4. problem while recording and playing audia simultaneously
    By srivvivek in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2008-07-09, 15:02
  5. Sound example in Series 60 SDK: Recording format problem
    By jjesus in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-03-11, 06:15

Posting Permissions

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