以前我曾以为 Bass.dll 是 Windows 系统自带的库, 后来才知道原来是第三方的: http://www.un4seen.com/.
Bass.dll 一直在更新, 现在最新版本是 2.411, 下载地址: http://us2.un4seen.com/files/bass24.zip
在 Delphi 中使用前, 有三步工作要做:
1、复制 Bass.dll 到系统可以识别的文件夹, 譬如: Windows\System32、Windows、Windows\System, 也可以是系统或用户的环境变量 Path 指定的任何目录, 还可以在做程序时放在当前目录, 随便放一个文件夹然后在程序中指定路径也可以.
2、把专为 Delphi 写的头文件 bass.pas 放在某个目录(譬如: C:\Program Files\CodeGear\RAD Studio\6.0\Imports\Bass24).
3、然后从 Delphi 菜单 -> Tools -> Options -> Library-Win32 -> Library path -> 然后 Add 这个目录 ( 例子).
好了, 写几句测试一下:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} uses Bass; procedure TForm1.FormCreate(Sender: TObject); begin ShowMessageFmt('%x', [BASSVERSION]); {204} ShowMessageFmt('%x', [BASS_GetVersion]); {2040101} if HiWord(BASS_GetVersion) <> BASSVERSION then ShowMessage('当前 Bass.dll 版本不可用') else ShowMessage('OK!'); end; end.程序说明:
在使用 Bass 前, 一般要先验证版本(因为不同版本功能有区别);
BASS_GetVersion 函数可以获取系统中 Bass.dll 的版本号, 这里是: $2040101(十六进制数);
BASSVERSION 是 Bass.pas 中的常量, 表示 Bass.pas 文件的版本, 这里是 $204;
只要主版本号(譬如2.4)统一即可, 我们可以用 HiWord 函数 从
BASS_GetVersion 函数的返回值中提前主版本号和 BASSVERSION 对比.
先博览一下 Bass 为我们提供的函数:
BASS_Apply3D BASS_ChannelBytes2Seconds BASS_ChannelFlags BASS_ChannelGet3DAttributes BASS_ChannelGet3DPosition BASS_ChannelGetAttribute BASS_ChannelGetData BASS_ChannelGetDevice BASS_ChannelGetInfo BASS_ChannelGetLength BASS_ChannelGetLevel BASS_ChannelGetPosition BASS_ChannelGetTags BASS_ChannelIsActive BASS_ChannelIsSliding BASS_ChannelLock BASS_ChannelPause BASS_ChannelPlay BASS_ChannelRemoveDSP BASS_ChannelRemoveFX BASS_ChannelRemoveLink BASS_ChannelRemoveSync BASS_ChannelSeconds2Bytes BASS_ChannelSet3DAttributes BASS_ChannelSet3DPosition BASS_ChannelSetAttribute BASS_ChannelSetDevice BASS_ChannelSetDSP BASS_ChannelSetFX BASS_ChannelSetLink BASS_ChannelSetPosition BASS_ChannelSetSync BASS_ChannelSlideAttribute BASS_ChannelStop BASS_ChannelUpdate BASS_ErrorGetCode BASS_Free BASS_FXGetParameters BASS_FXReset BASS_FXSetParameters BASS_Get3DFactors BASS_Get3DPosition BASS_GetConfig BASS_GetConfigPtr BASS_GetCPU BASS_GetDevice BASS_GetDeviceInfo BASS_GetDSoundObject BASS_GetEAXParameters BASS_GetInfo BASS_GetVersion BASS_GetVolume BASS_Init BASS_MusicFree BASS_MusicLoad BASS_Pause BASS_PluginFree BASS_PluginGetInfo BASS_PluginLoad BASS_RecordFree BASS_RecordGetDevice BASS_RecordGetDeviceInfo BASS_RecordGetInfo BASS_RecordGetInput BASS_RecordGetInputName BASS_RecordInit BASS_RecordSetDevice BASS_RecordSetInput BASS_RecordStart BASS_SampleCreate BASS_SampleFree BASS_SampleGetChannel BASS_SampleGetChannels BASS_SampleGetData BASS_SampleGetInfo BASS_SampleLoad BASS_SampleSetData BASS_SampleSetInfo BASS_SampleStop BASS_Set3DFactors BASS_Set3DPosition BASS_SetConfig BASS_SetConfigPtr BASS_SetDevice BASS_SetEAXParameters BASS_SetVolume BASS_Start BASS_Stop BASS_StreamCreate BASS_StreamCreateFile BASS_StreamCreateFileUser BASS_StreamCreateURL BASS_StreamFree BASS_StreamGetFilePosition BASS_StreamPutData BASS_StreamPutFileData BASS_Update