Yes!, I have SB Audigy ( full-duplex ). This is the code:
I have Error 41 when I try to Create the Stream.
// resetea valores
char *_recBuffer = NULL;
DWORD _recLength = 0;
char *_inputName = NULL;
bool SoundManager::recordInit( int input, int level ) {
//Inicializa Record System
BASS_RecordInit( -1 ); //Inicializa el dispositivo de grabación
_inputName = BASS_RecordGetInputName( input );
_input = input;
// enable the selected input
for ( int i = 0; BASS_RecordSetInput( i, BASS_INPUT_OFF ); ++i ); // 1st disable all inputs, then...
BASS_RecordSetInput( _input, BASS_INPUT_ON ); // enable the selected
BASS_RecordSetInput( _input, BASS_INPUT_LEVEL | level );
//UpdateInputInfo(); // update info
return TRUE;
}
// update the recording/playback counter
void UpdateRecording( ) {
/*
if ( _recBuffer ) {
if ( BASS_ChannelIsActive( _recordStream ) ) // playing
//Ejecutar VUMeter
//sprintf(text,"%I64d / %d",BASS_ChannelGetPosition(chan),reclen);
*/
}
//Recibe las grabaciones del microfono
BOOL CALLBACK recordProc( void * data, DWORD len, DWORD user ) {
// increase buffer size if needed
if ( ( _recLength % BUFSTEP ) + len >= BUFSTEP ) {
_recBuffer = ( char* )realloc( _recBuffer,( ( _recLength + len ) / BUFSTEP + 1 ) * BUFSTEP );
if ( !_recBuffer ) {
MessageBox( NULL, "Bass recording Error! Out of Memory", "Voice Recognition", MB_OK | MB_ICONSTOP );
UpdateRecording();
return FALSE; // stop recording
}
}
// buffer the data
memcpy( _recBuffer + _recLength , data, len );
_recLength += len;
//UpdateRecording( );
return TRUE; // continue recording
}
// Actualiza la informacion de la entrada de grabación
void SoundManager::UpdateInputInfo( ) {
/*
char *type;
int it = BASS_RecordGetInput( _input ); // get info on the input
switch ( it & BASS_INPUT_TYPE_MASK ) {
case BASS_INPUT_TYPE_DIGITAL:
type="digital";
break;
case BASS_INPUT_TYPE_LINE:
type="line-in";
break;
case BASS_INPUT_TYPE_MIC:
type="microphone";
break;
case BASS_INPUT_TYPE_SYNTH:
type="midi synth";
break;
case BASS_INPUT_TYPE_CD:
type="analog cd";
break;
case BASS_INPUT_TYPE_PHONE:
type="telephone";
break;
case BASS_INPUT_TYPE_SPEAKER:
type="pc speaker";
break;
case BASS_INPUT_TYPE_WAVE:
type="wave/pcm";
break;
case BASS_INPUT_TYPE_AUX:
type="aux";
break;
case BASS_INPUT_TYPE_ANALOG:
type="analog";
break;
default:
type="undefined";
}
// display the type */
}
void SoundManager::recordStop( ) {
BASS_ChannelStop( RECORDCHAN );
// create a stream from the recording
_recordStream = BASS_StreamCreateFile( TRUE, _recBuffer, 0, _recLength, 0 );
if( int error = BASS_ErrorGetCode( ) ) {
MessageBox( NULL, "Error al grabar sonido!", "Error!", MB_OK | MB_ICONSTOP );
}
_recording = FALSE;
//BASS_Start( );
}
void SoundManager::playRecordStream( ) {
BASS_StreamPlay( _recordStream, TRUE, 0 );
}
void SoundManager::recordStart( ) {
if( !_recording ) {
// clear any old recording
if ( _recBuffer ) {
BASS_Stop();
BASS_StreamFree( _recordStream );
free( _recBuffer );
_recBuffer = NULL;
//UpdateRecording( );
}
// allocate initial buffer and length
_recBuffer = ( char* ) malloc( BUFSTEP );
_recLength = 0;
// start recording
if ( !BASS_RecordStart( 11025, BASS_SAMPLE_8BITS, &recordProc, 0 ) ) {
MessageBox( NULL, "Error al iniciar la grabación!", "Voice Recognition!", MB_OK | MB_ICONSTOP );
free( _recBuffer );
_recBuffer = 0;
}
if( int error = BASS_ErrorGetCode( ) ) {
MessageBox( NULL, "No furula la grabacion!", "Error!", MB_OK | MB_ICONSTOP );
}
_recording = TRUE;
}
}
Thank You!