我正在尝试使用 BASS.NET 库中的音频创建应用程序,但在“我的第一个 BASS 应用程序”示例中出现了一些错误。我按照http://bass.radio42.com/help/上的给定说明进行操作,但是当我尝试运行粘贴的代码时,此行出现错误:
if ( Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero) )
我收到的错误是:
An unhandled exception of type 'System.TypeInitializationException' occurred in Bass Test.exe
我尝试按照所有指示进行操作,但对于 #4,我没有添加 bass.dll,而是添加了 bass.net.dll,认为这是错字。
4.Copy the 'bass.dll' to your executable directory (e.g. .\bin\Debug).
示例代码是:
using System;
using Un4seen.Bass;
namespace MyFirstBass
{
class Program
{
static void Main(string[] args)
{
// init BASS using the default output device
if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{
// create a stream channel from a file
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_DEFAULT);
if (stream != 0)
{
// play the stream channel
Bass.BASS_ChannelPlay(stream, false);
}
else
{
// error creating the stream
Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode());
}
// wait for a key
Console.WriteLine("Press any key to exit");
Console.ReadKey(false);
// free the stream
Bass.BASS_StreamFree(stream);
// free BASS
Bass.BASS_Free();
}
}
}
}
我猜代码很好,但我的计算机的输出设备是导致错误的原因。