PDA

View Full Version : Record sound/voice


Pi3cH
10-26-2007, 04:09 PM
Hi all,
I went through FMODPASS.ppl. it is very well for sound play. I was wondering if someone can help me to write a code or port from below code to ppc for Recording sound using BASS

Here is a C# code for recording Mp3 sound using BASS library.
http://www.un4seen.com/forum/?board=1
HRECORD channelRec;
HSTREAM channel_L;
HSTREAM channel_R;


BOOL CALLBACK RecordProc(HRECORD handle, void *buf, DWORD len, DWORD user)
{
short *stereo = (short*)buf;
short *left;
short *right;

left = (short*)malloc(len/2); // allocate buffer for left channel
right = (short*)malloc(len/2); // allocate buffer for right channel

for ( int i=0 ; i < len/4 ; i++ )
{
left[i] = stereo[i*2];
right[i] = stereo[i*2+1];
}

BASS_ChannelGetData(leftencoder, left, len/2); // feed left channel to encoder
BASS_ChannelGetData(rightencoder,right,len/2); // feed right channel to encoder

free(left);
free(right);

return TRUE;
}


HRESULT InitBASS()
{
// check the correct BASS was loaded
if ( HIWORD(BASS_GetVersion()) != BASSVERSION )
{
MessageBox(0,"An incorrect version of BASS.DLL was loaded",0,MB_ICONERROR);
return E_FAIL;
}

// initialize BASS recording (default device)
if ( !BASS_RecordInit(-1) )
{
MessageBox(0,"Can't initialize device",0,MB_ICONERROR);
return E_FAIL;
}

// start recording (44100hz, stereo, 16-bit)
if ( !( channelRec = BASS_RecordStart(44100,2,0,(RECORDPROC*)&RecordPro c,0) ) )
{
MessageBox(0,"Can't start recording",0,MB_ICONERROR);
return E_FAIL;
}

// Start encoding
BASS_CHANNELINFO i;
BASS_ChannelGetInfo(channelRec,&i);

channel_L = BASS_StreamCreate( i.freq,1, i.flags|BASS_STREAM_DECODE, NULL, 0 );
channel_R = BASS_StreamCreate( i.freq,1, i.flags|BASS_STREAM_DECODE, NULL, 0 );

BASS_Encode_Start(channel_L, "lame --alt-preset standard - outputL.mp3", BASS_ENCODE_AUTOFREE, NULL, 0);
BASS_Encode_Start(channel_R, "lame --alt-preset standard - outputR.mp3", BASS_ENCODE_AUTOFREE, NULL, 0);

return S_OK;
}


VOID StopRecording()
{
BASS_ChannelStop(channelRec);

BASS_StreamCreateFile(FALSE,"outputL.mp3",0,0,0);
BASS_StreamCreateFile(FALSE,"outputR.mp3",0,0,0);

BASS_StreamFree(channel_L);
BASS_StreamFree(channel_R);
}
for running this code you need:
bass.dll
bassenc.dll
lame.exe
http://www.un4seen.com/bass.html

there is no lame.exe port for pocket pc, so you can use "Shine" insted: http://www.everett9981.freeserve.co.uk/pete.htm

kornalius
10-26-2007, 05:53 PM
I don't think BASS module is ported to the PocketPC yet. I know FMOD is.

Pi3cH
10-27-2007, 07:04 AM
but I found bass.dll file in my PIDE folder. can it be use for this purpose?

I found attached sample code for FMOD, can you help me to port it? or as far as I know, PPL is very similiar to eVC, is there any way to use this code directly in PPL without any porting?
[br]1193468697_678_FT7311_record.zip

kornalius
10-27-2007, 04:02 PM
The Bass.dll is only a PC module. Look at Fmod_pc.dll and FMod_ppc.dll, there are two versions.

I don't have time to help you but I am sure others will find it interesting to port. Yes, PPL is very close to C but it still requires some work to convert sources.