×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    23

    Will there be Lag in playing Recorded voice??

    Hi,

    I have been working on an application which can record voice and play it back.I am using the example given in series 60 SDk(Sound Example).I am able to record voice but when I play it back the recorded voice is not clear.There is a pause and then the voice is heard.There is a lag in the voice.Can anyone tell me what could be the problem?Do I need to install or set any environment for the voice to play back?Please help

    Regards
    Dimple

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    2
    Hi Tippu,

    I guess it has to do with the available memory in the phone. Can I take a look at your codes to see what may be the issue?

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    23
    Hi,
    I havent tried my application on the phone but I have tried only on the series 60 emulator.the foll is the code.I have sent only 2 cpp files where I felt could be the problem.If u want the rest then I will send the rest

    Regards
    Dimple

    //**** CRecorderAdapter.cpp **********//


    #include <eikmenup.h>
    #include "sound.pan"
    #include "sound.hrh"
    #include "recorderadapter.h"
    #include "soundappui.h"

    // Identifying string for this audio utility
    _LIT(KAudioRecorder, "Recorder");

    // An existing sound sample file
    _LIT(KRecorderFile, "C:\\System\\Apps\\Sound\\record.wav");


    CRecorderAdapter::CRecorderAdapter(CSoundAppUi& aAppUi) :
    iAppUi(aAppUi)
    {
    }

    CRecorderAdapter* CRecorderAdapter::NewL(CSoundAppUi& aAppUi)
    {
    CRecorderAdapter* self = NewLC(aAppUi);
    CleanupStack::Pop(); // self
    return self;
    }

    CRecorderAdapter* CRecorderAdapter::NewLC(CSoundAppUi& aAppUi)
    {
    CRecorderAdapter* self = new (ELeave) CRecorderAdapter(aAppUi);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }


    void CRecorderAdapter::ConstructL()
    {
    iMdaAudioRecorderUtility = CMdaAudioRecorderUtility::NewL(*this);

    // Open an existing sample file for playback or recording
    // causes MMdaObjectStateChangeObserver::MoscoStateChangeEvent to be called
    iMdaAudioRecorderUtility->OpenFileL(KRecorderFile);
    }

    CRecorderAdapter::~CRecorderAdapter()
    {
    delete iMdaAudioRecorderUtility;
    iMdaAudioRecorderUtility = NULL;
    }

    void CRecorderAdapter::UpdateMenuL(CEikMenuPane* aMenuPane)
    {
    aMenuPane->SetItemDimmed(ESoundCmdPlay, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdRecord, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdStop, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdChange, ETrue);

    switch (iMdaAudioRecorderUtility->State())
    {
    case CMdaAudioRecorderUtility::ENotReady:
    aMenuPane->SetItemDimmed(ESoundCmdChange, EFalse);
    break;
    case CMdaAudioRecorderUtility::EOpen:
    aMenuPane->SetItemDimmed(ESoundCmdPlay, EFalse);
    aMenuPane->SetItemDimmed(ESoundCmdRecord, EFalse);
    aMenuPane->SetItemDimmed(ESoundCmdChange, EFalse);
    break;
    case CMdaAudioRecorderUtility::EPlaying:
    aMenuPane->SetItemDimmed(ESoundCmdStop, EFalse);
    break;
    case CMdaAudioRecorderUtility::ERecording:
    aMenuPane->SetItemDimmed(ESoundCmdStop, EFalse);
    break;
    default:
    __ASSERT_ALWAYS(EFalse, User::Panic(KRecorderAdapter, KSoundPanicInvalidMdaState));
    break;
    }
    }

    void CRecorderAdapter::PlayL()
    {

    TTimeIntervalMicroSeconds start;
    // TInt maxVolume;

    if (iMdaAudioRecorderUtility != NULL)
    {
    // Play through the device speaker
    iMdaAudioRecorderUtility->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);

    // Set maximum volume for playback
    iMdaAudioRecorderUtility->SetVolume(iMdaAudioRecorderUtility->MaxVolume());

    // Set the playback position to the start of the file
    //iMdaAudioRecorderUtility->SetPosition(start);
    //
    start = 0;
    iMdaAudioRecorderUtility->SetPosition(start);

    start = 1000000;
    iMdaAudioRecorderUtility->SetRepeats(3, start);


    iMdaAudioRecorderUtility->PlayL();
    }
    }
    void CRecorderAdapter::StopL()
    {
    iMdaAudioRecorderUtility->Stop();
    }

    void CRecorderAdapter::RecordL()
    {
    TTimeIntervalMicroSeconds start;
    // TInt maxGain;

    // TInt maxVolume;

    if (iMdaAudioRecorderUtility != NULL)
    {
    // Record from the device microphone
    iMdaAudioRecorderUtility->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);

    // Set maximum gain for recording
    iMdaAudioRecorderUtility->SetGain(iMdaAudioRecorderUtility->MaxGain());

    // Delete current audio sample from beginning of file
    start = 0;
    iMdaAudioRecorderUtility->SetPosition(start);
    iMdaAudioRecorderUtility->CropL();


    iMdaAudioRecorderUtility->RecordL();
    }
    }


    const TDesC& CRecorderAdapter::Identify()
    {
    return KAudioRecorder;
    }


    // from MMdaObjectStateChangeObserver
    void CRecorderAdapter::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt /*aErrorCode*/)
    {
    }
    ****************************************************


    //********* CPlayerAdapter.cpp *****************/


    #include <eikmenup.h>

    #include "sound.pan"
    #include "sound.hrh"
    #include "playeradapter.h"
    #include "soundappui.h"

    // Identifying string for this audio utility
    _LIT(KAudioPlayer, "Player");


    CPlayerAdapter::CPlayerAdapter(CSoundAppUi& aAppUi) :
    iState(ENotReady),
    iAppUi(aAppUi)
    {
    }

    CPlayerAdapter* CPlayerAdapter::NewL(const TDesC& aFileName, CSoundAppUi& aAppUi)
    {
    CPlayerAdapter* self = NewLC(aFileName, aAppUi);
    CleanupStack::Pop(); // self
    return self;
    }

    CPlayerAdapter* CPlayerAdapter::NewLC(const TDesC& aFileName, CSoundAppUi& aAppUi)
    {
    CPlayerAdapter* self = new (ELeave) CPlayerAdapter(aAppUi);
    CleanupStack::PushL(self);
    self->ConstructL(aFileName);
    return self;
    }


    void CPlayerAdapter::ConstructL(const TDesC& aFileName)
    {
    // Create an audio player utility instance for playing sample data from a file
    // causes MMdaAudioPlayerCallback::MapcInitComplete to be called
    iMdaAudioPlayerUtility = CMdaAudioPlayerUtility::NewFilePlayerL(aFileName, *this);
    }

    CPlayerAdapter::~CPlayerAdapter()
    {
    delete iMdaAudioPlayerUtility;
    iMdaAudioPlayerUtility = NULL;
    }


    // Note that this implementation of the virtual function does not leave.
    void CPlayerAdapter::UpdateMenuL(CEikMenuPane* aMenuPane)
    {
    aMenuPane->SetItemDimmed(ESoundCmdPlay, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdRecord, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdStop, ETrue);
    aMenuPane->SetItemDimmed(ESoundCmdChange, ETrue);

    switch (iState)
    {
    case ENotReady:
    aMenuPane->SetItemDimmed(ESoundCmdChange, EFalse);
    break;
    case EReadyToPlay:
    aMenuPane->SetItemDimmed(ESoundCmdPlay, EFalse);
    aMenuPane->SetItemDimmed(ESoundCmdChange, EFalse);
    break;
    case EPlaying:
    aMenuPane->SetItemDimmed(ESoundCmdStop, EFalse);
    break;
    default:
    __ASSERT_ALWAYS(EFalse, User::Panic(KPlayerAdapter, KSoundPanicInvalidMdaState));
    break;
    }
    }


    // Note that this implementation of the virtual function does not leave.
    void CPlayerAdapter::PlayL()
    {
    iMdaAudioPlayerUtility->Play();
    iState = EPlaying;
    }


    // CMdaAudioPlayerUtility is not able to record
    void CPlayerAdapter::RecordL()
    {
    }


    // Note that this implementation of the virtual function does not leave.
    void CPlayerAdapter::StopL()
    {
    iMdaAudioPlayerUtility->Stop();
    iState = EReadyToPlay;
    }



    const TDesC& CPlayerAdapter::Identify()
    {
    return KAudioPlayer;
    }


    // from MMdaAudioPlayerCallback
    void CPlayerAdapter::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
    {
    iState = aError ? ENotReady : EReadyToPlay;
    }


    void CPlayerAdapter::MapcPlayComplete(TInt aError)
    {
    iState = aError ? ENotReady : EReadyToPlay;
    }

    ****************************************************

Posting Permissions

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