📄 mmdsmix.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Fax.: +49(0)351-8037944 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/index.html =}
{========================================================================}
{= This code is for reference purposes only and may not be copied or =}
{= distributed in any format electronic or otherwise except one copy =}
{= for backup purposes. =}
{= =}
{= No Delphi Component Kit or Component individually or in a collection=}
{= subclassed or otherwise from the code in this unit, or associated =}
{= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
{= without express permission from SwiftSoft. =}
{= =}
{= For more licence informations please refer to the associated =}
{= HelpFile. =}
{========================================================================}
{= $Date: 17.11.98 - 16:26:10 $ =}
{========================================================================}
unit MMDSMix;
{$I COMPILER.INC}
interface
uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Dialogs,
Forms,
MMOLE2,
MMSystem,
MMObj,
MMUtils,
MMDSound,
MMD3DTyp,
MM3D,
MMRegs,
MMWave,
MMPCMSup,
MMACMSup,
MMADPCM,
MMMulDiv,
MMWaveIO,
MMCCon;
type
EMMDSWaveMixError = class(Exception);
TMMDSSpeakerConfig = (scHeadphone,scMono,scQuad,scStereo,scSurround);
TMMDSLevel = (prNormal, prPriority, prExclusive);
TMMDS3DBufferMode = (bmNormal,bmHeadRelative,bmNo3D);
const
{$IFDEF CBUILDER3} {$EXTERNALSYM defMaxDistance} {$ENDIF}
defMaxDistance = 1e+09; {? Should be inf}
{$IFDEF CBUILDER3} {$EXTERNALSYM defMinDistance} {$ENDIF}
defMinDistance = 1.0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defMode} {$ENDIF}
defMode = bmNormal;
{$IFDEF CBUILDER3} {$EXTERNALSYM defPosX} {$ENDIF}
defPosX = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defPosY} {$ENDIF}
defPosY = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defPosZ} {$ENDIF}
defPosZ = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defInsideConeAngle} {$ENDIF}
defInsideConeAngle = 360;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOutsideConeAngle} {$ENDIF}
defOutsideConeAngle = 360;
{$IFDEF CBUILDER3} {$EXTERNALSYM defConeOrientX} {$ENDIF}
defConeOrientX = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defConeOrientY} {$ENDIF}
defConeOrientY = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defConeOrientZ} {$ENDIF}
defConeOrientZ = 1;
{$IFDEF CBUILDER3} {$EXTERNALSYM defConeOutsideVolume} {$ENDIF}
defConeOutsideVolume = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelX} {$ENDIF}
defVelX = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelY} {$ENDIF}
defVelY = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelZ} {$ENDIF}
defVelZ = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defDistanceFactor} {$ENDIF}
defDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
{$IFDEF CBUILDER3} {$EXTERNALSYM defDopplerFactor} {$ENDIF}
defDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientFrontX} {$ENDIF}
defOrientFrontX = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientFrontY} {$ENDIF}
defOrientFrontY = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientFrontZ} {$ENDIF}
defOrientFrontZ = 1;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientTopX} {$ENDIF}
defOrientTopX = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientTopY} {$ENDIF}
defOrientTopY = 1;
{$IFDEF CBUILDER3} {$EXTERNALSYM defOrientTopZ} {$ENDIF}
defOrientTopZ = 0;
{$IFDEF CBUILDER3} {$EXTERNALSYM defPositionX} {$ENDIF}
defPositionX = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defPositionY} {$ENDIF}
defPositionY = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defPositionZ} {$ENDIF}
defPositionZ = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defRollOffFactor} {$ENDIF}
defRollOffFactor = DS3D_DEFAULTROLLOFFFACTOR;
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelocityX} {$ENDIF}
defVelocityX = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelocityY} {$ENDIF}
defVelocityY = 0; {?}
{$IFDEF CBUILDER3} {$EXTERNALSYM defVelocityZ} {$ENDIF}
defVelocityZ = 0; {?}
type
{-- TMMDS3DControl -----------------------------------------------------}
TMMDS3DControl = class(TMMObject)
private
FDeferred : Boolean;
FUpdate : Integer;
FInApply : Boolean;
protected
function SetDirect: Boolean;
function GetDirect: Boolean;
function ApplyFlags: DWORD;
procedure SetDeferred(Value: Boolean);
destructor Destroy; override;
procedure CreateBuffer(DSBuffer: IDirectSoundBuffer);
procedure FreeBuffer;
procedure ApplySettings;
procedure ObtainControl(DSBuffer: IDirectSoundBuffer); virtual; abstract;
procedure FreeControl; virtual; abstract;
procedure DoApplySettings; virtual; abstract;
function ControlAllocated: Boolean; virtual; abstract;
public
procedure BeginUpdate;
procedure EndUpdate;
published
property Deferred: Boolean read FDeferred write SetDeferred;
end;
{-- TMMDS3DBuffer ------------------------------------------------------}
TMMDS3DBuffer = class(TMMDS3DControl)
private
FDS3DBuffer : IDirectSound3DBuffer;
FMaxDistance : D3DVALUE;
FMinDistance : D3DVALUE;
FMode : TMMDS3DBufferMode;
FPosition : TMMVector3D;
FInsideConeAngle : LongInt;
FOutsideConeAngle : LongInt;
FConeOrientation : TMMVector3D;
FConeOutsideVolume : LongInt;
FVelocity : TMMVector3D;
procedure SetMaxDistance(Value: D3DVALUE);
procedure SetMinDistance(Value: D3DVALUE);
procedure SetMode(Value: TMMDS3DBufferMode);
procedure SetPosition(Value: TMMVector3D);
procedure SetInsideConeAngle(Value: LongInt);
procedure SetOutsideConeAngle(Value: LongInt);
procedure SetConeOrientation(Value: TMMVector3D);
procedure SetConeOutsideVolume(Value: LongInt);
procedure SetVelocity(Value: TMMVector3D);
function GetMaxDistance: D3DVALUE;
function GetMinDistance: D3DVALUE;
function GetMode: TMMDS3DBufferMode;
function GetPosition: TMMVector3D;
function GetInsideConeAngle: LongInt;
function GetOutsideConeAngle: LongInt;
function GetConeOrientation: TMMVector3D;
function GetConeOutsideVolume: LongInt;
function GetVelocity: TMMVector3D;
procedure VectorChanged(Sender: TObject);
protected
procedure ObtainControl(DSBuffer: IDirectSoundBuffer); override;
procedure FreeControl; override;
procedure DoApplySettings; override;
function ControlAllocated: Boolean; override;
public
constructor Create(Loading: Boolean);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property MaxDistance: D3DVALUE read GetMaxDistance write SetMaxDistance;
property MinDistance: D3DVALUE read GetMinDistance write SetMinDistance;
property Mode: TMMDS3DBufferMode read GetMode write SetMode default defMode;
property Position: TMMVector3D read GetPosition write SetPosition;
property InsideConeAngle: LongInt read GetInsideConeAngle write SetInsideConeAngle default defInsideConeAngle;
property OutsideConeAngle: LongInt read GetOutsideConeAngle write SetOutsideConeAngle default defOutsideConeAngle;
property ConeOrientation: TMMVector3D read GetConeOrientation write SetConeOrientation;
property ConeOutsideVolume: LongInt read GetConeOutsideVolume write SetConeOutsideVolume default defConeOutsideVolume;
property Velocity: TMMVector3D read GetVelocity write SetVelocity;
end;
{-- TMMDS3DListener ----------------------------------------------------}
TMMDS3DListener = class(TMMDS3DControl)
private
FDS3DListener : IDirectSound3DListener;
FDistanceFactor : D3DVALUE;
FDopplerFactor : D3DVALUE;
FOrientFront : TMMVector3D;
FOrientTop : TMMVector3D;
FPosition : TMMVector3D;
FRollOffFactor : D3DVALUE;
FVelocity : TMMVector3D;
function GetDistanceFactor: D3DVALUE;
function GetDopplerFactor: D3DVALUE;
function GetOrientFront: TMMVector3D;
function GetOrientTop: TMMVector3D;
function GetPosition: TMMVector3D;
function GetRollOffFactor: D3DVALUE;
function GetVelocity: TMMVector3D;
procedure SetDistanceFactor(Value: D3DVALUE);
procedure SetDopplerFactor(Value: D3DVALUE);
procedure SetOrientFront(Value: TMMVector3D);
procedure SetOrientTop(Value: TMMVector3D);
procedure SetPosition(Value: TMMVector3D);
procedure SetRollOffFactor(Value: D3DVALUE);
procedure SetVelocity(Value: TMMVector3D);
procedure VectorChanged(Sender: TObject);
protected
procedure ObtainControl(DSBuffer: IDirectSoundBuffer); override;
procedure FreeControl; override;
procedure DoApplySettings; override;
function ControlAllocated: Boolean; override;
public
constructor Create(Loading: Boolean);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure Commit;
published
property DistanceFactor: D3DVALUE read GetDistanceFactor write SetDistanceFactor;
property DopplerFactor: D3DVALUE read GetDopplerFactor write SetDopplerFactor;
property OrientFront: TMMVector3D read GetOrientFront write SetOrientFront;
property OrientTop: TMMVector3D read GetOrientTop write SetOrientTop;
property Position: TMMVector3D read GetPosition write SetPosition;
property RollOffFactor: D3DVALUE read GetRollOffFactor write SetRollOffFactor;
property Velocity: TMMVector3D read GetVelocity write SetVelocity;
end;
{-- TMMDSSoundBuffer ---------------------------------------------------}
TMMDSSoundBuffer = class(TMMObject)
private
DirectSoundBuffer: IDirectSoundBuffer;
FName : string;
FWave : TMMWave;
FVolume : Longint;
FPanning : Longint;
FFrequency : Longint;
FPosition : Longint;
FMuted : Boolean;
FPlaying : Boolean;
FPaused : Boolean;
FLooping : Boolean;
FOnBufferEnd: TNotifyEvent;
FOnRelease : TNotifyEvent;
procedure SetMuted(aValue: Boolean);
procedure SetVolume(aValue: Longint);
function GetVolume: Longint;
procedure SetPanning(aValue: Longint);
function GetPanning: Longint;
procedure SetFrequency(aValue: Longint);
function GetFrequency: Longint;
procedure SetPosition(aValue: Longint);
function GetPosition: Longint;
procedure SetLooping(aValue: Boolean);
function GetLooping: Boolean;
function GetPlaying: Boolean;
function GetBufferLength: Longint;
function GetCaps: TDSBCAPS;
protected
procedure Play;
procedure Pause;
procedure Stop;
procedure ReleaseBuffer;
procedure FreeBuffer;
public
FOwned : Boolean;
constructor Create; virtual;
property SoundBuffer: IDirectSoundBuffer read DirectSoundBuffer;
property Caps: TDSBCAPS read GetCaps;
property Wave: TMMWave read FWave;
property Name: string read FName;
property BufferLength: Longint read GetBufferLength;
property Playing: Boolean read GetPlaying;
property Paused: Boolean read FPaused;
property Muted: Boolean read FMuted write SetMuted default False;
property Volume: Longint read GetVolume write SetVolume default 0;
property Panning: Longint read GetPanning write SetPanning default 0;
property Frequency: Longint read GetFrequency write SetFrequency default 0;
property Position: Longint read GetPosition write SetPosition default 0;
property Looping: Boolean read GetLooping write SetLooping default False;
end;
{-- TMMDSSoundCaps ----------------------------------------------------}
TMMDSSoundCaps = class(TMMObject)
private
FBDummy: Boolean;
FLDummy: DWORD;
FContinuousRate: Boolean;
FEmulDriver: Boolean;
FCertified: Boolean;
FPrimary16Bit: Boolean;
FPrimary8Bit: Boolean;
FPrimaryMono: Boolean;
FPrimaryStereo: Boolean;
FSecondary16Bit: Boolean;
FSecondary8Bit: Boolean;
FSecondaryMono: Boolean;
FSecondaryStero: Boolean;
FMin2Sample: DWORD;
FMax2Sample: DWORD;
FPrimaryBuffers: DWORD;
FMaxHWAll: DWORD;
FMaxHWStatic: DWORD;
FMaxHWStream: DWORD;
FFreeHWAlls: DWORD;
FFreeHWStatic: DWORD;
FFreeHWStream: DWORD;
FMaxHW3All: DWORD;
FMaxHW3Static: DWORD;
FMaxHW3Stream: DWORD;
FFreeHW3Alls: DWORD;
FFreeHW3Static: DWORD;
FFreeHW3Stream: DWORD;
FTotalHWMemBytes: DWORD;
FFreeHWMemBytes: DWORD;
FMaxContigFree: DWORD;
FUnlockRate: DWORD;
FPlayCPU: DWORD;
published
property ContinuousRate: Boolean read FContinuousRate write FBDummy stored False;
property EmulDriver: Boolean read FEmulDriver write FBDummy stored False;
property Certified: Boolean read FCertified write FBDummy stored False;
property Primary16Bit: Boolean read FPrimary16Bit write FBDummy stored False;
property Primary8Bit: Boolean read FPrimary8Bit write FBDummy stored False;
property PrimaryMono: Boolean read FPrimaryMono write FBDummy stored False;
property PrimaryStereo: Boolean read FPrimaryStereo write FBDummy stored False;
property Secondary16Bit: Boolean read FSecondary16Bit write FBDummy stored False;
property Secondary8Bit: Boolean read FSecondary8Bit write FBDummy stored False;
property SecondaryMono: Boolean read FSecondaryMono write FBDummy stored False;
property SecondaryStereo: Boolean read FSecondaryStero write FBDummy stored False;
property MinSecondarySampleRate: DWORD read FMin2Sample write FLDummy stored False;
property MaxSecondarySampleRate: DWORD read FMax2Sample write FLDummy stored False;
property PrimaryBuffers: DWORD read FPrimaryBuffers write FLDummy stored False;
property MaxHWMixingAllBuffers: DWORD read FMaxHWAll write FLDummy stored False;
property MaxHWMixingStaticBuffers: DWORD read FMaxHWStatic write FLDummy stored False;
property MaxHWMixingStreamingBuffers: DWORD read FMaxHWStream write FLDummy stored False;
property FreeHWMixingAllBuffers: DWORD read FFreeHWAlls write FLDummy stored False;
property FreeHWMixingStaticBuffers: DWORD read FFreeHWStatic write FLDummy stored False;
property FreeHWMixingStreamingBuffers: DWORD read FFreeHWStream write FLDummy stored False;
property MaxHW3DAllBuffers: DWORD read FMaxHW3All write FLDummy stored False;
property MaxHW3DStaticBuffers: DWORD read FMaxHW3Static write FLDummy stored False;
property MaxHW3DStreamingBuffers: DWORD read FMaxHW3Stream write FLDummy stored False;
property FreeHW3DAllBuffers: DWORD read FFreeHW3Alls write FLDummy stored False;
property FreeHW3DStaticBuffers: DWORD read FFreeHW3Static write FLDummy stored False;
property FreeHW3DStreamingBuffers: DWORD read FFreeHW3Stream write FLDummy stored False;
property TotalHWMemBytes: DWORD read FTotalHWMemBytes write FLDummy stored False;
property FreeHWMemBytes: DWORD read FFreeHWMemBytes write FLDummy stored False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -