Author Topic: How I record from one device and play it to another device ?  (Read 146 times)

euflasio

  • Posts: 2
Hi,

I want to record and save to file from one sound card, using Line Input for example,
and simultaneously play it to ANOTHER sound card.

I saw the record example that is included, that already do record and save to file,
but i donīt know how alter that example to play that sound to another card.

I'm using VB6

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 21973
There are a few ways that you can do that. You can create a "push" stream on the output device and have the recording send the captured data to that. Something like this:

Code: [Select]
output = BASS_StreamCreate(44100, 2, STREAMPROC_PUSH, NULL); // create output push stream
BASS_ChannelPlay(output, false); // start it
input = BASS_RecordStart(44100, 2, 0, RecordProc, NULL); // start recording

...

BOOL CALLBACK RecordProc(HRECORD handle, const void *buffer, DWORD length, void *user)
{
BASS_StreamPutData(output, buffer, length); // send the data to the output
return TRUE; // continue recording
}

Or you can create a regular "pull" stream on the output device and have it fetch the captured data from the recording. Something like this:

Code: [Select]
input = BASS_RecordStart(44100, 2, 0, NULL, NULL); // start recording without a RECORDPROC
output = BASS_StreamCreate(44100, 2, StreamProc, NULL); // create output stream
BASS_ChannelPlay(output, false); // start it

...

DWORD CALLBACK StreamProc(HSTREAM handle, void *buffer, DWORD length, void *user)
{
return BASS_ChannelGetData(input, buffer, length); // fetch data from the recording
}

Another option is to use the BASSmix add-on's splitter feature, which you may find nicer because it doesn't require any callback functions. Something like this:

Code: [Select]
input = BASS_RecordStart(44100, 2, 0, NULL, NULL); // start recording without a RECORDPROC
output = BASS_Split_StreamCreate(input, 0, NULL); // create a splitter stream on it
BASS_ChannelPlay(output, false); // start it

Please see the documentation for details on the mentioned functions.

euflasio

  • Posts: 2
Thank you