Author Topic: How to use BASS_ChannelGetData in a mixer while playing  (Read 132 times)

MoHamMad

  • Posts: 7
I wanted to send data in Linux to devices that are not supported by bass. Currently, I have a code that creates a stream from a file, puts it in a mixer and sends it to icecast through an encoder. All these tasks are done automatically. I want to send the same thing that is decoding to an output device. I have code that sends data to an output device, but I don't know how to get the data so that I don't overload the device and receive what is playing in the mixer and send it to the output device.
I know that I should use getData but I don't know how to make it not go to the next data until the playback of a certain data is finished.
Any examples and help would be appreciated

Ian @ un4seen

  • Administrator
  • Posts: 25725
It sounds like you want to play a clone of the mixer? You could use a DSP function and "push" stream to do that, ie. the DSP function feeds the mixer output to the push stream. Something like this:

Code: [Select]
HSTREAM clone = BASS_StreamCreate(freq, chans, flags, STREAMPROC_PUSH, 0); // create push stream with same format as the mixer
BASS_ChannelSetDSP(mixer, CloneDSP, 0, (void*)clone, -1); // set cloning function on mixer
BASS_ChannelPlay(clone, 0); // start the clone

...

void CALLBACK CloneDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user)
{
HSTREAM clone = (HSTREAM)user;
BASS_StreamPutData(clone, buffer, length); // pass the data to the clone
}

Please see the documentation for details on the mentioned functions.