Voice Recording | developer.brewmp.com Voice Recording | developer.brewmp.com

Developer

Voice Recording

Forums:

hi,

how we can record voice in brew-mp,

i want to record voice & allredy runing audio file which is playing using ISOUNDPLAYER

how i can recorde both of them simultaneously.

affter recording i want to use this new recorded file......

how it can b done.......................

Sound may be recorded using IMedia or IVocoder. 
For your case:-
1. play the sound using ISoundplayer.
2. AT the same time record using IMedia. sample code below:
 
call both these functions:

playSound(pMe);
recordMedia(pMe);

void playSound(myApp *pMe)
{
AEECLSID cls;

cls = ISHELL_GetHandler(pMe->a.m_pIShell, HTYPE_SOUND, "snd/mp3");

if(!cls) {
return;
}

ISHELL_CreateInstance(pMe->a.m_pIShell, cls, (void**)&pMe->pSoundPlayer);

ISOUNDPLAYER_Set(pMe->pSoundPlayer, SDT_FILE, "test.mp3");
ISOUNDPLAYER_Play(pMe->pSoundPlayer);

void recordMedia(myApp *pMe)
{
AEEMediaData md;
int nErr;

if( ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEDIAQCP, (void**)&pMe->pMedia) != SUCCESS) {
DBGPRINTF("*******MEDIA PCM Instance failed");
return;
}

md.clsData = MMD_FILE_NAME;
md.pData = (void*)"test12.qcp";
md.dwSize = 0;

IMedia_RegisterNotify(pMe->pMedia, (PFNMEDIANOTIFY)c_MediaNotify, pMe);
IMedia_SetMediaData(pMe->pMedia, &md);

IMedia_SetVolume(pMe->pMedia, AEE_MAX_VOLUME);

nErr = IMedia_Record(pMe->pMedia);

if(nErr == SUCCESS) {
DBGPRINTF("*****SUCCESS");
}
else {
DBGPRINTF("*****Error Recording %d", nErr);
}
 
 

Sound may be recorded using IMedia or IVocoder. 
For your case:-
1. play the sound using ISoundplayer.
2. AT the same time record using IMedia. sample code below:
 
call both these functions:

playSound(pMe);
recordMedia(pMe);

void playSound(myApp *pMe)
{
AEECLSID cls;

cls = ISHELL_GetHandler(pMe->a.m_pIShell, HTYPE_SOUND, "snd/mp3");

if(!cls) {
return;
}

ISHELL_CreateInstance(pMe->a.m_pIShell, cls, (void**)&pMe->pSoundPlayer);

ISOUNDPLAYER_Set(pMe->pSoundPlayer, SDT_FILE, "test.mp3");
ISOUNDPLAYER_Play(pMe->pSoundPlayer);

void recordMedia(myApp *pMe)
{
AEEMediaData md;
int nErr;

if( ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MEDIAQCP, (void**)&pMe->pMedia) != SUCCESS) {
DBGPRINTF("*******MEDIA PCM Instance failed");
return;
}

md.clsData = MMD_FILE_NAME;
md.pData = (void*)"test12.qcp";
md.dwSize = 0;

IMedia_RegisterNotify(pMe->pMedia, (PFNMEDIANOTIFY)c_MediaNotify, pMe);
IMedia_SetMediaData(pMe->pMedia, &md);

IMedia_SetVolume(pMe->pMedia, AEE_MAX_VOLUME);

nErr = IMedia_Record(pMe->pMedia);

if(nErr == SUCCESS) {
DBGPRINTF("*****SUCCESS");
}
else {
DBGPRINTF("*****Error Recording %d", nErr);
}
 
 

i am getting md.test12.qcp file size is zero
i have all so change md.dwSize but no change......

i am getting md.test12.qcp file size is zero
i have all so change md.dwSize but no change......

For Media recording the md.dwSize  = 0; is alright.
Its working on simulator for me. where did u try?

For Media recording the md.dwSize  = 0; is alright.
Its working on simulator for me. where did u try?

void PlaySoundPlayer(Recorder *pMe)
{
    if(!pMe->m_pISoundPlayer)
        ISHELL_CreateInstance(pMe->piShell,AEECLSID_SOUNDPLAYER,(void**)&(pMe->m_pISoundPlayer));    //m_pISoundPlayer=ISHELL_LoadSound(piShell,"abc.mid");
    pMe->m_pISoundPlayer=ISHELL_LoadSound(pMe->piShell,SOUND_FILE);
    ISOUNDPLAYER_RegisterNotify(pMe->m_pISoundPlayer,(PFNSOUNDPLAYERSTATUS)PlaySoundPlayerCB,pMe);
    ISOUNDPLAYER_SetVolume(pMe->m_pISoundPlayer,AEE_MAX_VOLUME);
    ISOUNDPLAYER_Play(pMe->m_pISoundPlayer);
    soundrecarding(pMe);
}
 
 
void soundrecarding(Recorder *pMe)
{        AEEMediaData  md;
    int nErr;    if( ISHELL_CreateInstance(pMe->piShell, AEECLSID_MEDIAQCP, (void**)&pMe->m_pMedia) != SUCCESS)
    {
    DBGPRINTF("*******MEDIA PCM Instance failed");    return;
    }    md.clsData = MMD_FILE_NAME;
    md.pData   = (void*)"test12.qcp";
    md.dwSize  = 0;    IMedia_RegisterNotify(pMe->m_pMedia, (PFNMEDIANOTIFY)CB_ForRecorder, pMe);
    IMedia_SetMediaData(pMe->m_pMedia, &md);
    IMedia_SetVolume(pMe->m_pMedia, AEE_MAX_VOLUME);
    nErr = IMedia_Record(pMe->m_pMedia);
    if(nErr == SUCCESS) {
    DBGPRINTF("*****SUCCESS");
    }
    else {
    DBGPRINTF("*****Error Recording %d", nErr);
    }
}
 
void CB_ForRecorder(Recorder * pUser, AEEMediaCmdNotify * pCmdNotify)
{
}
 
i am using this code but call is not come on CB_ForRecorder & test2.qcp file is allso of size zero
plz help me
i want to recorde the sound which is runing playing ISoundPlayer

void PlaySoundPlayer(Recorder *pMe)
{
    if(!pMe->m_pISoundPlayer)
        ISHELL_CreateInstance(pMe->piShell,AEECLSID_SOUNDPLAYER,(void**)&(pMe->m_pISoundPlayer));    //m_pISoundPlayer=ISHELL_LoadSound(piShell,"abc.mid");
    pMe->m_pISoundPlayer=ISHELL_LoadSound(pMe->piShell,SOUND_FILE);
    ISOUNDPLAYER_RegisterNotify(pMe->m_pISoundPlayer,(PFNSOUNDPLAYERSTATUS)PlaySoundPlayerCB,pMe);
    ISOUNDPLAYER_SetVolume(pMe->m_pISoundPlayer,AEE_MAX_VOLUME);
    ISOUNDPLAYER_Play(pMe->m_pISoundPlayer);
    soundrecarding(pMe);
}
 
 
void soundrecarding(Recorder *pMe)
{        AEEMediaData  md;
    int nErr;    if( ISHELL_CreateInstance(pMe->piShell, AEECLSID_MEDIAQCP, (void**)&pMe->m_pMedia) != SUCCESS)
    {
    DBGPRINTF("*******MEDIA PCM Instance failed");    return;
    }    md.clsData = MMD_FILE_NAME;
    md.pData   = (void*)"test12.qcp";
    md.dwSize  = 0;    IMedia_RegisterNotify(pMe->m_pMedia, (PFNMEDIANOTIFY)CB_ForRecorder, pMe);
    IMedia_SetMediaData(pMe->m_pMedia, &md);
    IMedia_SetVolume(pMe->m_pMedia, AEE_MAX_VOLUME);
    nErr = IMedia_Record(pMe->m_pMedia);
    if(nErr == SUCCESS) {
    DBGPRINTF("*****SUCCESS");
    }
    else {
    DBGPRINTF("*****Error Recording %d", nErr);
    }
}
 
void CB_ForRecorder(Recorder * pUser, AEEMediaCmdNotify * pCmdNotify)
{
}
 
i am using this code but call is not come on CB_ForRecorder & test2.qcp file is allso of size zero
plz help me
i want to recorde the sound which is runing playing ISoundPlayer

r u running this on Simulator? which Simulator? or what device?
check if the MIF of App has File privilage. debug into the App & see if IMedia returns any error.

r u running this on Simulator? which Simulator? or what device?
check if the MIF of App has File privilage. debug into the App & see if IMedia returns any error.

ya i am runing it on simulator Candy Bar(1.0.3.800)
i have add file privilage but
IMedia_RegisterNotify return 13
&
IMedia_SetVolume return 1

ya i am runing it on simulator Candy Bar(1.0.3.800)
i have add file privilage but
IMedia_RegisterNotify return 13
&
IMedia_SetVolume return 1

that EBADSTATE, move the call to IMedia_RegisterNotify(pMe->m_pMedia, (PFNMEDIANOTIFY)CB_ForRecorder, pMe); after calling IMedia_SetMediaData(pMe->m_pMedia, &md); in you code.
 
anything else returns error? do u have file privilage in MIF?
put breakpoints & see that the Media record code is called only once.
check the timestamp of the file test12.qcp. does it change each time?

that EBADSTATE, move the call to IMedia_RegisterNotify(pMe->m_pMedia, (PFNMEDIANOTIFY)CB_ForRecorder, pMe); after calling IMedia_SetMediaData(pMe->m_pMedia, &md); in you code.
 
anything else returns error? do u have file privilage in MIF?
put breakpoints & see that the Media record code is called only once.
check the timestamp of the file test12.qcp. does it change each time?

thanks
now test12.qcpsize is changed
i record abc.mid which size is 80.5KB but recordet file  test12.qcp size is 505KB
how i can run this file ....................

thanks
now test12.qcpsize is changed
i record abc.mid which size is 80.5KB but recordet file  test12.qcp size is 505KB
how i can run this file ....................

it seems that you do not call IMedia_Stop(), when you are finished with the recording.
its such that if if u do not call IMedia_Stop(), the data will not get written to the file. hence u see a 0 byte file.
 
create a finction as
void StopRecording(myapp *pMe) {
 IMedia_Stop(pMe->m_pMedia);
}
call this fuinction when u want to stop recording. After that check the file size.

it seems that you do not call IMedia_Stop(), when you are finished with the recording.
its such that if if u do not call IMedia_Stop(), the data will not get written to the file. hence u see a 0 byte file.
 
create a finction as
void StopRecording(myapp *pMe) {
 IMedia_Stop(pMe->m_pMedia);
}
call this fuinction when u want to stop recording. After that check the file size.

just change IMedia_Record() to IMedia_Play() in the MediaRecord code. it will work.

just change IMedia_Record() to IMedia_Play() in the MediaRecord code. it will work.

Thanks for Reply,
abow code work fine.
but when i am trying to store recorded data in Buffer then
IMedia_Record(pMe->m_pMedia) returns 20;
i am using following code
 
    AEEMediaData  md;
    int nErr;
ISHELL_CreateInstance(pMe->piShell, AEECLSID_MEDIAPCM, (void**)&pMe->m_pMedia_for_recording);
 
    ISHELL_CreateInstance(pMe->piShell, AEECLSID_FILEMGR,(void**)&(pMe->m_pIFileMgr));
 
    pMe->m_pIFile=IFILEMGR_OpenFile(pMe->m_pIFileMgr, "sound.mp3",_OFM_READ);
    IFILE_GetInfo(pMe->m_pIFile,&pMe->m_FileInfo);
    pMe->BufferRec=MALLOC(sizeof(char)*pMe->m_FileInfo.dwSize);
    IFILE_Read(pMe->m_pIFile, (void*)pMe->BufferRec,pMe->m_FileInfo.dwSize);
 
    md.clsData = MMD_BUFFER;
    md.pData   = pMe->BufferRec;
    md.dwSize  = pMe->m_FileInfo.dwSize;
    nErr = IMedia_SetMediaData(pMe->m_pMedia_for_recording, &md);
    nErr = IMedia_RegisterNotify(pMe->m_pMedia_for_recording,(PFNMEDIANOTIFY)Media_CB, pMe);
    nErr = IMedia_Record(pMe->m_pMedia_for_recording);/*return 20*/
 
now i want to Store Recorded data in buffer............
 

Thanks for Reply,
abow code work fine.
but when i am trying to store recorded data in Buffer then
IMedia_Record(pMe->m_pMedia) returns 20;
i am using following code
 
    AEEMediaData  md;
    int nErr;
ISHELL_CreateInstance(pMe->piShell, AEECLSID_MEDIAPCM, (void**)&pMe->m_pMedia_for_recording);
 
    ISHELL_CreateInstance(pMe->piShell, AEECLSID_FILEMGR,(void**)&(pMe->m_pIFileMgr));
 
    pMe->m_pIFile=IFILEMGR_OpenFile(pMe->m_pIFileMgr, "sound.mp3",_OFM_READ);
    IFILE_GetInfo(pMe->m_pIFile,&pMe->m_FileInfo);
    pMe->BufferRec=MALLOC(sizeof(char)*pMe->m_FileInfo.dwSize);
    IFILE_Read(pMe->m_pIFile, (void*)pMe->BufferRec,pMe->m_FileInfo.dwSize);
 
    md.clsData = MMD_BUFFER;
    md.pData   = pMe->BufferRec;
    md.dwSize  = pMe->m_FileInfo.dwSize;
    nErr = IMedia_SetMediaData(pMe->m_pMedia_for_recording, &md);
    nErr = IMedia_RegisterNotify(pMe->m_pMedia_for_recording,(PFNMEDIANOTIFY)Media_CB, pMe);
    nErr = IMedia_Record(pMe->m_pMedia_for_recording);/*return 20*/
 
now i want to Store Recorded data in buffer............
 

Plz reply me.........

Plz reply me.........

recording directly to buffer is not possible.
refer
https://developer.brewmp.com/forum/voice-recording-buffer-0

recording directly to buffer is not possible.
refer
https://developer.brewmp.com/forum/voice-recording-buffer-0

Thanks

Thanks

hi,
i am useing IsoundPlayer for playing sound.
&
IMedia for Voice recording.
 
when i use both of this simultaneously on Simulator.
it work fine i.e. soung is all so playing & voice is allso recorded.
 
but when i am useing both of this simultaneously on device.
then only voice is recorded but sound is not playing ( i am unable listen sound).
Device name is "QRD 6270".plz help me........

hi,
i am useing IsoundPlayer for playing sound.
&
IMedia for Voice recording.
 
when i use both of this simultaneously on Simulator.
it work fine i.e. soung is all so playing & voice is allso recorded.
 
but when i am useing both of this simultaneously on device.
then only voice is recorded but sound is not playing ( i am unable listen sound).
Device name is "QRD 6270".plz help me........