Audio Effects for Karaoke Software

Started by Gluber,

Gluber

Hi !

I am currently writing a karaoke program. Now i want to add Audio Effects to the recorded input voice. Currently during recording there is a WMA Stream played back, which is then mixed with the live input from Microphone/Line In in my recording procedure and written out using WMA Encoding.

Unfortunatly Settings Effects on "RECORDCHAN" does not work. So how can i enable audio effects only on the recording part ?

Here is my record callback procedure:

#define MIXBUFFER_SIZE 128000

static short s_mixBuffer[MIXBUFFER_SIZE];
static short s_inputBuffer[MIXBUFFER_SIZE];

static BOOL CALLBACK RecordProc( void * data,DWORD len,DWORD user )
{
      // Clear buffers
      ZeroMemory( s_mixBuffer,MIXBUFFER_SIZE );
      ZeroMemory( s_inputBuffer,MIXBUFFER_SIZE );
     
      // Get the input sample buffer
      short * recordData = ( short * )data;
     
      // Check
      if ( len > MIXBUFFER_SIZE )
      {
            Starmaker::Native::Throw("Überlauf des Misch Puffers.");
      }

      // Half length.
      int shortLength = len / 2;

      // If we are playing back.
      if ( s_stream != 0 && s_playing )
      {
            // Get the data.
            if ( BASS_ChannelGetData( s_stream,s_inputBuffer,len ) == -1 )
                  Starmaker::Native::Throw("Konnte Stream Daten nicht lesen.");

            for ( int i = 0; i < shortLength; i++ )
            {      
                  int tempVal = recordData + s_inputBuffer;
                 
                  if ( tempVal > 32767 )
                        tempVal = 32767;
                  else if ( tempVal < -32768)
                        tempVal = -32768;
                 
                  s_mixBuffer = (short)tempVal;
            }
      }
      else
      {
            for ( int i = 0; i < shortLength; i++ )
            {
                  // Just assign
                  s_mixBuffer = recordData;
            }
      }

      // Encode
      if ( !BASS_WMA_EncodeWrite( s_encoder,s_mixBuffer,len ) )
            Starmaker::Native::Throw("Konnte nicht WMA enkodieren.");

      // Set the flag to true
      s_encodeWritten = true;

      // Return
      return TRUE;
}

Any clues on this ( Btw i know of the LIVEFX sample, but creating an additional stream... a bit bad for me.


Ian @ un4seen

#1
You can pass the recorded data through a custom decoding channel, and set effects on that channel. For example, something like this...
HSTREAM fxstream;

DWORD CALLBACK fxstreamproc(HSTREAM handle, void *buffer, DWORD length, DWORD user)
{
// the data is already in "buffer", so just return
      return length;
}

Do this in your "RecordProc"...
static BOOL CALLBACK RecordProc( void * data,DWORD len,DWORD user )
{
      BASS_ChannelGetData(fxstream,data,len);
...

Before you start recording, create the custom stream...
fxstream=BASS_StreamCreate(samplerate,BASS_STREAM_DECODE,&fxstreamproc,0);...and use BASS_ChannelSetFX to set any effects you want on it :)