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
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