Ok. Now I'm having trouble getting ASIO output. Here's my ASIOPROC callback at the moment:
private int AsioProcessor(bool input, int channel, IntPtr buffer, int length, IntPtr user)
{
if (input)
{
// Get the ASIO data and copy it to the associated stream
// Note: 'user' is not actually a pointer in this instance, it's being used to store an Int32 value
Bass.BASS_StreamPutData(user.ToInt32(), buffer, length);
if (channel == Info.InputChannels[Info.InputChannels.Count - 1]) // All channels processed for this cycle
{
// Pull data from the mixer to force processing (because these are all decoder streams)
//byte[] temp = new byte[20000];
//Bass.BASS_ChannelGetData(m_MixerHandle, temp, temp.Length);
}
}
else
{
if (Bass.BASS_ChannelGetData(m_MixerHandle, buffer, length) < 1)
Info.WriteDebug("Bass Error: " + Bass.BASS_ErrorGetCode());
}
return 0;
}
Is it incorrect to attempt to copy the mixer output stream to the ASIO output? The mixer output stream is stereo and the ASIO output is two-channel, created like so:
// Enable ASIO output(s)
HandleBassAsioError(BassAsio.BASS_ASIO_ChannelEnable(false, 0, m_AsioProcessor, new IntPtr(m_MixerHandle)));
HandleBassAsioError(BassAsio.BASS_ASIO_ChannelJoin(false, 1, 0));
HandleBassAsioError(BassAsio.BASS_ASIO_ChannelSetFormat(false, 0, BASSASIOFormat.BASS_ASIO_FORMAT_FLOAT));
HandleBassAsioError(BassAsio.BASS_ASIO_ChannelSetRate(false, 0, Info.SampleRate));
HandleBassAsioError(BassAsio.BASS_ASIO_ChannelSetVolume(false, 0, 1f));
I've tried changing the order of everything and changing sample formats to no avail. I can see that the ChannelGetData call is actually being made to transfer data from the mixer stream to the ASIO output buffer, and it returns the correct number of bytes. I do notice the ASIOPROC is being called with length = 48 samples. The ASIO buffer should be 192 samples, is this normal? Also, if I have the ASIO channels set to a format the device doesn't support (i.e. 32-bit float), will it be resampled before output or just break?