When i use ASIO and BassVis at the same time, the music becomes fast and has some noise, how can I avoid it?
Are you using the same handle in your ASIOPROC's BASS_ChannelGetData call and in the BassVis calls? If so, the problem will be that the data taken by the vis stuff will then not be available to the ASIOPROC, ie. the output will skip some data and sound fast. To avoid that, you will need to give the vis a copy of the data that the ASIOPROC receives. That could be done via a custom stream, something like this...
HSTREAM visstream; // vis stream handle
void *visbuf=NULL; // buffer for data to feed the vis stream
DWORD visbuflen=0; // buffer length
DWORD visbuffill=0; // current fill level
...
visstream=BASS_StreamCreate(rate, chans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, VisStreamProc, NULL); // create a custom stream with the same format as the ASIO output
...
DWORD CALLBACK VisStreamProc(HSTREAM handle, void *buf, DWORD len, void *user)
{
if (len>visbuffill) len=visbuffill; // limit it to amount available in the vis buffer
memcpy(buf, visbuf, len); // copy the data from the vis buffer
return len;
}
DWORD CALLBACK AsioProc(BOOL input, DWORD channel, void *buf, DWORD len, void *user)
{
DWORD c=BASS_ChannelGetData(decoder, buf, len); // decode some data
if (c==-1) c=0; // an error, no data
if (visbuflen<c) visbuf=realloc(visbuf, visbuflen=c); // enlarge the vis buffer
memcpy(visbuf, buf, c); // copy the data to the vis buffer
visbuffill=c;
return c;
}
You would then use the "visstream" handle in the vis function calls. To be safe, a lock (eg. critical section) should really be added around the vis buffer stuff in the VisStreamProc and AsioProc functions.
Note that the update rate of the vis will be determined by the ASIO buffer length, as that determines how often new data is placed in the vis buffer.