Hi, dont understand, why this simple code alredy give me: BASS_ERROR_ALREADY. Can someone test it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Un4seen.Bass;
using Un4seen.BassAsio;
using System.Threading;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Bass.BASS_Init(-1, 192000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
BassAsio.BASS_ASIO_Init(1, BASSASIOInit.BASS_ASIO_DEFAULT);
BassAsioHandler asio = new BassAsioHandler(false, 1, 0, 2, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT, 192000);
Bass.BASS_RecordInit(0);
//int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
int stream = Bass.BASS_RecordStart(192000, 2, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);
if (stream != 0)
{
// now setup ASIO
_myAsioProc = new ASIOPROC(AsioCallback);
// enable 1st output channel...(0=first)
BassAsio.BASS_ASIO_ChannelEnable(false, 0, _myAsioProc, new IntPtr(stream));
// and join the next channels to it
BassAsio.BASS_ASIO_ChannelJoin(false, 1, 0);
// and start playing it...start output using default buffer/latency
BassAsio.BASS_ASIO_Start(0);
}
else
System.Windows.Forms.MessageBox.Show("Fail " + Bass.BASS_ErrorGetCode());
while (true)
{
Thread.Sleep(10);
}
}
private static ASIOPROC _myAsioProc; // make it global, so that it can not be removed by the Garbage Collector
private static int AsioCallback(bool input, int channel, IntPtr buffer, int length, IntPtr user)
{
// Note: 'user' contains the underlying stream channel (see above)
// We can simply use the bass method to get some data from a decoding channel
// and store it to the asio buffer in the same moment...
return Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length);
}
}
}