It's been a while and I got it working beautifully on a single VSTi on a single channel, switching from VSTi to soundfont and back again. I have since been working to make it general, allowing multiple tracks, a list of VSTi's. To do this I've created classes to hold information about listed VSTi's, and as much as my old brain has struggled, it is holding together quite well. However I'm concerned about the DSP callback and VSTi on multiple channels. Ian, you supplied me with ...
vst_guitar = BASS_VST_ChannelCreate(44100, 2, "C:\\Program Files\\Cakewalk\\VstPlugins\\AGM2.dll", BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE); // load the VSTi
midichanstream = BASS_MIDI_StreamGetChannel(midistream, vst_channel); // get a stream for the MIDI channel to be handled by the VSTi
BASS_ChannelSetDSP(midichanstream, VSTiDSP, 0, 0); // set a DSP function on it to feed-in the VSTi output
...
void CALLBACK VSTiDSP(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user)
{
BASS_ChannelGetData(vst_guitar, buffer, length); // get data from the VSTi
}
The callback receives the handle returned from BASS_ChannelSetDSP (param1) and the channel (param2). Because BASS_MIDI_StreamGetChannel is called for each channel that is running VSTi, I either need a different callback function for every possible channel (ie 16 callback functions), or there must be a different way to handle it. Have you any advice on that?
I'm still only testing it on one channel, and sadly there is a crackle and some distortion in the VSTi playing which I'm yet to understand (the simpler version played cleanly), but as I go through checking the validity of all my BASS calls, I can see a logical flaw in calling BASS_ChannelSetDSP for each VSTi channel, pointing to the one callback function.
I hope that makes sense.