📄 dynamic_bass.pas
字号:
fWetDryMix: FLOAT;
fDepth: FLOAT;
fFeedback: FLOAT;
fFrequency: FLOAT;
lWaveform: DWORD; // 0=triangle, 1=sine
fDelay: FLOAT;
lPhase: DWORD; // BASS_DX8_PHASE_xxx
end;
BASS_DX8_GARGLE = record
dwRateHz: DWORD; // Rate of modulation in hz
dwWaveShape: DWORD; // 0=triangle, 1=square
end;
BASS_DX8_I3DL2REVERB = record
lRoom: Longint; // [-10000, 0] default: -1000 mB
lRoomHF: Longint; // [-10000, 0] default: 0 mB
flRoomRolloffFactor: FLOAT; // [0.0, 10.0] default: 0.0
flDecayTime: FLOAT; // [0.1, 20.0] default: 1.49s
flDecayHFRatio: FLOAT; // [0.1, 2.0] default: 0.83
lReflections: Longint; // [-10000, 1000] default: -2602 mB
flReflectionsDelay: FLOAT; // [0.0, 0.3] default: 0.007 s
lReverb: Longint; // [-10000, 2000] default: 200 mB
flReverbDelay: FLOAT; // [0.0, 0.1] default: 0.011 s
flDiffusion: FLOAT; // [0.0, 100.0] default: 100.0 %
flDensity: FLOAT; // [0.0, 100.0] default: 100.0 %
flHFReference: FLOAT; // [20.0, 20000.0] default: 5000.0 Hz
end;
BASS_DX8_PARAMEQ = record
fCenter: FLOAT;
fBandwidth: FLOAT;
fGain: FLOAT;
end;
BASS_DX8_REVERB = record
fInGain: FLOAT; // [-96.0,0.0] default: 0.0 dB
fReverbMix: FLOAT; // [-96.0,0.0] default: 0.0 db
fReverbTime: FLOAT; // [0.001,3000.0] default: 1000.0 ms
fHighFreqRTRatio: FLOAT; // [0.001,0.999] default: 0.001
end;
// callback function types
STREAMPROC = function(handle: HSTREAM; buffer: Pointer; length: DWORD; user: Pointer): DWORD; stdcall;
{
User stream callback function. NOTE: A stream function should obviously be as
quick as possible, other streams (and MOD musics) can't be mixed until
it's finished.
handle : The stream that needs writing
buffer : Buffer to write the samples in
length : Number of bytes to write
user : The 'user' parameter value given when calling BASS_StreamCreate
RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end
the stream.
}
const
// special STREAMPROCs
STREAMPROC_DUMMY : STREAMPROC = STREAMPROC(0); // "dummy" stream
STREAMPROC_PUSH : STREAMPROC = STREAMPROC(-1); // push stream
type
DOWNLOADPROC = procedure(buffer: Pointer; length: DWORD; user: Pointer); stdcall;
{
Internet stream download callback function.
buffer : Buffer containing the downloaded data... NULL=end of download
length : Number of bytes in the buffer
user : The 'user' parameter value given when calling BASS_StreamCreateURL
}
SYNCPROC = procedure(handle: HSYNC; channel, data: DWORD; user: Pointer); stdcall;
{
Sync callback function. NOTE: a sync callback function should be very
quick as other syncs cannot be processed until it has finished. If the
sync is a "mixtime" sync, then other streams and MOD musics can not be
mixed until it's finished either.
handle : The sync that has occured
channel: Channel that the sync occured in
data : Additional data associated with the sync's occurance
user : The 'user' parameter given when calling BASS_ChannelSetSync
}
DSPPROC = procedure(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: Pointer); stdcall;
{
DSP callback function. NOTE: A DSP function should obviously be as quick
as possible... other DSP functions, streams and MOD musics can not be
processed until it's finished.
handle : The DSP handle
channel: Channel that the DSP is being applied to
buffer : Buffer to apply the DSP to
length : Number of bytes in the buffer
user : The 'user' parameter given when calling BASS_ChannelSetDSP
}
RECORDPROC = function(handle: HRECORD; buffer: Pointer; length: DWORD; user: Pointer): BOOL; stdcall;
{
Recording callback function.
handle : The recording handle
buffer : Buffer containing the recorded sample data
length : Number of bytes
user : The 'user' parameter value given when calling BASS_RecordStart
RETURN : TRUE = continue recording, FALSE = stop
}
// Vars that will hold our dynamically loaded functions...
var BASS_SetConfig:function(option, value: DWORD): BOOL; stdcall;
var BASS_GetConfig:function(option: DWORD): DWORD; stdcall;
var BASS_SetConfigPtr:function(option: DWORD; value: Pointer): BOOL; stdcall;
var BASS_GetConfigPtr:function(option: DWORD): Pointer; stdcall;
var BASS_GetVersion:function: DWORD; stdcall;
var BASS_ErrorGetCode:function: Integer; stdcall;
var BASS_GetDeviceInfo:function(device: DWORD; var info: BASS_DEVICEINFO): BOOL; stdcall;
var BASS_Init:function(device: Integer; freq, flags: DWORD; win: HWND; clsid: PGUID): BOOL; stdcall;
var BASS_SetDevice:function(device: DWORD): BOOL; stdcall;
var BASS_GetDevice:function: DWORD; stdcall;
var BASS_Free:function: BOOL; stdcall;
var BASS_GetDSoundObject:function(obj: DWORD): Pointer; stdcall;
var BASS_GetInfo:function(var info: BASS_INFO): BOOL; stdcall;
var BASS_Update:function(length: DWORD): BOOL; stdcall;
var BASS_GetCPU:function: FLOAT; stdcall;
var BASS_Start:function: BOOL; stdcall;
var BASS_Stop:function: BOOL; stdcall;
var BASS_Pause:function: BOOL; stdcall;
var BASS_SetVolume:function(volume: FLOAT): BOOL; stdcall;
var BASS_GetVolume:function: FLOAT; stdcall;
var BASS_PluginLoad:function(filename: PChar; flags: DWORD): HPLUGIN; stdcall;
var BASS_PluginFree:function(handle: HPLUGIN): BOOL; stdcall;
var BASS_PluginGetInfo:function(handle: HPLUGIN): PBASS_PLUGININFO; stdcall;
var BASS_Set3DFactors:function(distf, rollf, doppf: FLOAT): BOOL; stdcall;
var BASS_Get3DFactors:function(var distf, rollf, doppf: FLOAT): BOOL; stdcall;
var BASS_Set3DPosition:function(var pos, vel, front, top: BASS_3DVECTOR): BOOL; stdcall;
var BASS_Get3DPosition:function(var pos, vel, front, top: BASS_3DVECTOR): BOOL; stdcall;
var BASS_Apply3D:procedure; stdcall;
var BASS_SetEAXParameters:function(env: Integer; vol, decay, damp: FLOAT): BOOL; stdcall;
var BASS_GetEAXParameters:function(var env: DWORD; var vol, decay, damp: FLOAT): BOOL; stdcall;
var BASS_MusicLoad:function(mem: BOOL; f: Pointer; offset: QWORD; length, flags, freq: DWORD): HMUSIC; stdcall;
var BASS_MusicFree:function(handle: HMUSIC): BOOL; stdcall;
var BASS_SampleLoad:function(mem: BOOL; f: Pointer; offset: QWORD; length, max, flags: DWORD): HSAMPLE; stdcall;
var BASS_SampleCreate:function(length, freq, chans, max, flags: DWORD): HSAMPLE; stdcall;
var BASS_SampleFree:function(handle: HSAMPLE): BOOL; stdcall;
var BASS_SampleSetData:function(handle: HSAMPLE; buffer: Pointer): BOOL; stdcall;
var BASS_SampleGetData:function(handle: HSAMPLE; buffer: Pointer): BOOL; stdcall;
var BASS_SampleGetInfo:function(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; stdcall;
var BASS_SampleSetInfo:function(handle: HSAMPLE; var info: BASS_SAMPLE): BOOL; stdcall;
var BASS_SampleGetChannel:function(handle: HSAMPLE; onlynew: BOOL): HCHANNEL; stdcall;
var BASS_SampleGetChannels:function(handle: HSAMPLE; channels: Pointer): DWORD; stdcall;
var BASS_SampleStop:function(handle: HSAMPLE): BOOL; stdcall;
var BASS_StreamCreate:function(freq, chans, flags: DWORD; proc: STREAMPROC; user: Pointer): HSTREAM; stdcall;
var BASS_StreamCreateFile:function(mem: BOOL; f: Pointer; offset, length: QWORD; flags: DWORD): HSTREAM; stdcall;
var BASS_StreamCreateURL:function(url: PAnsiChar; offset: DWORD; flags: DWORD; proc: DOWNLOADPROC; user: Pointer):HSTREAM; stdcall;
var BASS_StreamCreateFileUser:function(system, flags: DWORD; var procs: BASS_FILEPROCS; user: Pointer): HSTREAM; stdcall;
var BASS_StreamFree:function(handle: HSTREAM): BOOL; stdcall;
var BASS_StreamGetFilePosition:function(handle: HSTREAM; mode: DWORD): QWORD; stdcall;
var BASS_StreamPutData:function(handle: HSTREAM; buffer: Pointer; length: DWORD): DWORD; stdcall;
var BASS_StreamPutFileData:function(handle: HSTREAM; buffer: Pointer; length: DWORD): DWORD; stdcall;
var BASS_RecordGetDeviceInfo:function(device: DWORD; var info: BASS_DEVICEINFO): BOOL; stdcall;
var BASS_RecordInit:function(device: Integer): BOOL; stdcall;
var BASS_RecordSetDevice:function(device: DWORD): BOOL; stdcall;
var BASS_RecordGetDevice:function: DWORD; stdcall;
var BASS_RecordFree:function: BOOL; stdcall;
var BASS_RecordGetInfo:function(var info: BASS_RECORDINFO): BOOL; stdcall;
var BASS_RecordGetInputName:function(input: Integer): PAnsiChar; stdcall;
var BASS_RecordSetInput:function(input: Integer; flags: DWORD; volume: FLOAT): BOOL; stdcall;
var BASS_RecordGetInput:function(input: Integer; var volume: FLOAT): DWORD; stdcall;
var BASS_RecordStart:function(freq, chans, flags: DWORD; proc: RECORDPROC; user: Pointer): HRECORD; stdcall;
var BASS_ChannelBytes2Seconds:function(handle: DWORD; pos: QWORD): Double; stdcall;
var BASS_ChannelSeconds2Bytes:function(handle: DWORD; pos: Double): QWORD; stdcall;
var BASS_ChannelGetDevice:function(handle: DWORD): DWORD; stdcall;
var BASS_ChannelSetDevice:function(handle, device: DWORD): BOOL; stdcall;
var BASS_ChannelIsActive:function(handle: DWORD): DWORD; stdcall;
var BASS_ChannelGetInfo:function(handle: DWORD; var info: BASS_CHANNELINFO):BOOL;stdcall;
var BASS_ChannelGetTags:function(handle: HSTREAM; tags: DWORD): PAnsiChar; stdcall;
var BASS_ChannelFlags:function(handle, flags, mask: DWORD): DWORD; stdcall;
var BASS_ChannelUpdate:function(handle, length: DWORD): BOOL; stdcall;
var BASS_ChannelLock:function(handle: DWORD; lock: BOOL): BOOL; stdcall;
var BASS_ChannelPlay:function(handle: DWORD; restart: BOOL): BOOL; stdcall;
var BASS_ChannelStop:function(handle: DWORD): BOOL; stdcall;
var BASS_ChannelPause:function(handle: DWORD): BOOL; stdcall;
var BASS_ChannelSetAttribute:function(handle, attrib: DWORD; value: FLOAT): BOOL; stdcall;
var BASS_ChannelGetAttribute:function(handle, attrib: DWORD; var value: FLOAT): BOOL; stdcall;
var BASS_ChannelSlideAttribute:function(handle, attrib: DWORD; value: FLOAT; time: DWORD): BOOL; stdcall;
var BASS_ChannelIsSliding:function(handle, attrib: DWORD): BOOL; stdcall;
var BASS_ChannelSet3DAttributes:function(handle: DWORD; mode: Integer; min, max: FLOAT; iangle, oangle, outvol: Integer): BOOL; stdcall;
var BASS_ChannelGet3DAttributes:function(handle: DWORD; var mode: DWORD; var min, max: FLOAT; var iangle, oangle, outvol: DWORD): BOOL; stdcall;
var BASS_ChannelSet3DPosition:function(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; stdcall;
var BASS_ChannelGet3DPosition:function(handle: DWORD; var pos, orient, vel: BASS_3DVECTOR): BOOL; stdcall;
var BASS_ChannelGetLength:function(handle, mode: DWORD): QWORD; stdcall;
var BASS_ChannelSetPosition:function(handle: DWORD; pos: QWORD; mode: DWORD): BOOL; stdcall;
var BASS_ChannelGetPosition:function(handle, mode: DWORD): QWORD; stdcall;
var BASS_ChannelGetLevel:function(handle: DWORD): DWORD; stdcall;
var BASS_ChannelGetData:function(handle: DWORD; buffer: Pointer; length: DWORD): DWORD; stdcall;
var BASS_ChannelSetSync:function(handle: DWORD; type_: DWORD; param: QWORD; proc: SYNCPROC; user: Pointer): HSYNC; stdcall;
var BASS_ChannelRemoveSync:function(handle: DWORD; sync: HSYNC): BOOL; stdcall;
var BASS_ChannelSetDSP:function(handle: DWORD; proc: DSPPROC; user: Pointer; priority: Integer): HDSP; stdcall;
var BASS_ChannelRemoveDSP:function(handle: DWORD; dsp: HDSP): BOOL; stdcall;
var BASS_ChannelSetLink:function(handle, chan: DWORD): BOOL; stdcall;
var BASS_ChannelRemoveLink:function(handle, chan: DWORD): BOOL; stdcall;
var BASS_ChannelSetFX:function(handle, type_: DWORD; priority: Integer): HFX; stdcall;
var BASS_ChannelRemoveFX:function(handle: DWORD; fx: HFX): BOOL; stdcall;
var BASS_FXSetParameters:function(handle: HFX; par: Pointer): BOOL; stdcall;
var BASS_FXGetParameters:function(handle: HFX; par: Pointer): BOOL; stdcall;
var BASS_FXReset:function(handle: HFX): BOOL; stdcall;
{ok, now we need something that loads our DLL and gets rid of it as well...}
var BASS_Handle:Thandle=0; // this will hold our handle for the dll; it functions nicely as a mutli-dll prevention unit as well...
Function Load_BASSDLL (const dllfilename:string) :boolean; // well, this functions uses sub-space field harmonics to erase all your credit cards in a 30 meter area...look at it's name, what do you think it does ?
Procedure Unload_BASSDLL; // another mystery function ???
{
This function frees the dynamically linked-in functions from memory...don't forget to call it once you're done !
Best place to put this is probably the OnDestroy of your Main-Form;
suggested use in OnDestroy :
- Call BASS_Free to get rid of everything that's eating memory (automatically called, but just to be on the safe-side !),
- Then call this function.
}
function BASS_SPEAKER_N(n: DWORD): DWORD;
function BASS_SetEAXPreset(env: Integer): BOOL;
{
This function is defined in the implementation part of this unit.
It is not part of BASS.DLL but an extra function which makes it easier
to set the predefined EAX environments.
env : a EAX_ENVIRONMENT_xxx constant
}
implementation
Function Load_BASSDLL (const dllfilename:string) :boolean;
const szBassDll = 'bass.dll' + #0;
var
oldmode:integer;
P: PAnsiChar;
s: string;
dllfile: array[0..MAX_PATH + 1] of Char;
begin
Result := False;
if BASS_Handle<>0 then result:=true {is it already there ?}
else begin {go & load the dll}
s := dllfilename;
if Length(s) = 0 then begin
P := nil;
if SearchPath(nil, PAnsiChar(szBassDll), nil, MAX_PATH, dllfile, P) > 0 then
s := StrPas(dllfile)
else exit;
end;
oldmode:=SetErrorMode($8001);
s := s + #0;
BASS_Handle:=LoadLibrary(PAnsiChar(s)); // obtain the handle we want
SetErrorMode(oldmode);
if BASS_Handle<>0 then
begin {now we tie the functions to the VARs from above}
@BASS_SetConfig:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_SetConfig'));
@BASS_GetConfig:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetConfig'));
@BASS_SetConfigPtr:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_SetConfigPtr'));
@BASS_GetConfigPtr:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetConfigPtr'));
@BASS_GetVersion:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetVersion'));
@BASS_ErrorGetCode:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_ErrorGetCode'));
@BASS_GetDeviceInfo:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetDeviceInfo'));
@BASS_Init:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Init'));
@BASS_SetDevice:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_SetDevice'));
@BASS_GetDevice:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetDevice'));
@BASS_Free:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Free'));
@BASS_GetDSoundObject:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetDSoundObject'));
@BASS_GetInfo:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetInfo'));
@BASS_Update:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Update'));
@BASS_GetCPU:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_GetCPU'));
@BASS_Start:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Start'));
@BASS_Stop:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Stop'));
@BASS_Pause:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_Pause'));
@BASS_SetVolume:=GetProcAddress(BASS_Handle,PAnsiChar('BASS_SetVolume'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -