📄 mmdsetyp.pas
字号:
{========================================================================}
{= (c) 1995-98 SwiftSoft Ronald Dittrich =}
{========================================================================}
{= All Rights Reserved =}
{========================================================================}
{= D 01099 Dresden = Tel.: +0351-8012255 =}
{= Loewenstr.7a = info@swiftsoft.de =}
{========================================================================}
{= Actual versions on http://www.swiftsoft.de/mmtools.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: 20.01.1998 - 18:00:00 $ =}
{========================================================================}
unit MMDSETyp;
interface
uses
MMDSMix,
MMUtils,
MMWave,
MM3D;
type
PMMDSEDMixerParams = ^TMMDSEDMixerParams;
TMMDSEDMixerParams = record
BitLength : TMMBits;
DeviceId : Integer;
Level : TMMDSLevel;
SampleRate : LongInt;
SpeakerConfig : TMMDSSpeakerConfig
end;
PMMDSEDListenerParams = ^TMMDSEDListenerParams;
TMMDSEDListenerParams = record
DistanceFactor : TMM3DValue;
DopplerFactor : TMM3DValue;
OrientFront : TMM3DVector;
OrientTop : TMM3DVector;
Position : TMM3DVector;
RollOffFactor : TMM3DValue;
Velocity : TMM3DVector;
end;
PMMDSEDSourceParams = ^TMMDSEDSourceParams;
TMMDSEDSourceParams = record
ConeOrientation : TMM3DVector;
ConeOutsideVolume : LongInt;
InsideConeAngle : LongInt;
MaxDistance : TMM3DValue;
MinDistance : TMM3DValue;
Mode : TMMDS3DBufferMode;
OutsideConeAngle : LongInt;
Position : TMM3DVector;
Velocity : TMM3DVector;
end;
PMMDSEDBufferParams = ^TMMDSEDBufferParams;
TMMDSEDBufferParams = record
Frequency : LongInt;
Panning : LongInt;
Volume : LongInt;
end;
PMMDSEDWaveRecord = ^TMMDSEDWaveRecord;
TMMDSEDWaveRecord = record
Data : Pointer;
Size : LongInt;
end;
procedure MMDSEDRecordFromMixer(Mix: TMMDSWaveMixer; var MixPar: TMMDSEDMixerParams);
procedure MMDSEDRecordFromBuffer(Ch: TMMDSMixChannel; var BufPar: TMMDSEDBufferParams);
procedure MMDSEDMixerFromRecord(Mix: TMMDSWaveMixer; const MixPar: TMMDSEDMixerParams);
procedure MMDSEDBufferFromRecord(Ch: TMMDSMixChannel; const BufPar: TMMDSEDBufferParams);
procedure MMDSEDRecordFromListener(Mix: TMMDSWaveMixer; var ListPar: TMMDSEDListenerParams);
procedure MMDSEDRecordFromSource(Ch: TMMDSMixChannel; var SrcPar: TMMDSEDSourceParams);
procedure MMDSEDListenerFromRecord(Mix: TMMDSWaveMixer; const ListPar: TMMDSEDListenerParams);
procedure MMDSEDSourceFromRecord(Ch: TMMDSMixChannel; const SrcPar: TMMDSEDSourceParams);
function MMDSEDCreateWaveRecord(Wave: TMMWave): TMMDSEDWaveRecord;
procedure MMDSEDFreeWaveRecord(R: TMMDSEDWaveRecord);
procedure MMDSEDLoadWaveFromRecord(R: TMMDSEDWaveRecord; Wave: TMMWave);
implementation
uses
Windows,
Classes;
procedure MMDSEDRecordFromMixer(Mix: TMMDSWaveMixer; var MixPar: TMMDSEDMixerParams);
begin
with Mix do
begin
MixPar.BitLength := BitLength;
MixPar.DeviceId := DeviceId;
MixPar.Level := Level;
MixPar.SampleRate := SampleRate;
MixPar.SpeakerConfig := SpeakerConfiguration;
end;
end;
procedure MMDSEDRecordFromBuffer(Ch: TMMDSMixChannel; var BufPar: TMMDSEDBufferParams);
begin
with Ch do
begin
BufPar.Frequency := Frequency;
BufPar.Panning := Panning;
BufPar.Volume := Volume;
end;
end;
procedure MMDSEDMixerFromRecord(Mix: TMMDSWaveMixer; const MixPar: TMMDSEDMixerParams);
begin
with Mix do
begin
BitLength := MixPar.BitLength;
DeviceId := MixPar.DeviceId;
Level := MixPar.Level;
SampleRate := MixPar.SampleRate;
SpeakerConfiguration:= MixPar.SpeakerConfig;
end;
end;
procedure MMDSEDBufferFromRecord(Ch: TMMDSMixChannel; const BufPar: TMMDSEDBufferParams);
begin
with Ch do
begin
Frequency := BufPar.Frequency;
Panning := BufPar.Panning;
Volume := BufPar.Volume;
end;
end;
procedure MMDSEDRecordFromListener(Mix: TMMDSWaveMixer; var ListPar: TMMDSEDListenerParams);
begin
with Mix.Sound3D do
begin
ListPar.DistanceFactor := DistanceFactor;
ListPar.DopplerFactor := DopplerFactor;
ListPar.OrientFront := OrientFront.AsVector;
ListPar.OrientTop := OrientTop.AsVector;
ListPar.Position := Position.AsVector;
ListPar.RollOffFactor := RollOffFactor;
ListPar.Velocity := Velocity.AsVector;
end;
end;
procedure MMDSEDRecordFromSource(Ch: TMMDSMixChannel; var SrcPar: TMMDSEDSourceParams);
begin
with Ch.Sound3D do
begin
SrcPar.ConeOrientation := ConeOrientation.AsVector;
SrcPar.ConeOutsideVolume := ConeOutsideVolume;
SrcPar.InsideConeAngle := InsideConeAngle;
SrcPar.MaxDistance := MaxDistance;
SrcPar.MinDistance := MinDistance;
SrcPar.Mode := Mode;
SrcPar.OutsideConeAngle := OutsideConeAngle;
SrcPar.Position := Position.AsVector;
SrcPar.Velocity := Velocity.AsVector;
end;
end;
procedure MMDSEDListenerFromRecord(Mix: TMMDSWaveMixer; const ListPar: TMMDSEDListenerParams);
begin
with Mix.Sound3D do
begin
DistanceFactor := ListPar.DistanceFactor;
DopplerFactor := ListPar.DopplerFactor;
OrientFront.AsVector:= ListPar.OrientFront;
OrientTop.AsVector := ListPar.OrientTop;
Position.AsVector := ListPar.Position;
RollOffFactor := ListPar.RollOffFactor;
Velocity.AsVector := ListPar.Velocity;
end;
end;
procedure MMDSEDSourceFromRecord(Ch: TMMDSMixChannel; const SrcPar: TMMDSEDSourceParams);
begin
with Ch.Sound3D do
begin
ConeOrientation.AsVector := SrcPar.ConeOrientation;
ConeOutsideVolume := SrcPar.ConeOutsideVolume;
InsideConeAngle := SrcPar.InsideConeAngle;
MaxDistance := SrcPar.MaxDistance;
MinDistance := SrcPar.MinDistance;
Mode := SrcPar.Mode;
OutsideConeAngle := SrcPar.OutsideConeAngle;
Position.AsVector := SrcPar.Position;
Velocity.AsVector := SrcPar.Velocity;
end;
end;
type
TStreamHack = class(TMemoryStream)
public
procedure SetPtr(Ptr: Pointer; Size: LongInt);
end;
procedure TStreamHack.SetPtr(Ptr: Pointer; Size: LongInt);
begin
SetPointer(Ptr,Size);
end;
function MMDSEDCreateWaveRecord(Wave: TMMWave): TMMDSEDWaveRecord;
var
S : TMemoryStream;
begin
FillChar(Result,SizeOf(Result),0);
S := TMemoryStream.Create;
try
if Wave <> nil then
begin
Wave.SaveToStream(S);
Result.Data := S.Memory;
Result.Size := S.Size;
TStreamHack(S).SetPtr(nil,0);
end;
finally
S.Free;
end;
end;
procedure MMDSEDFreeWaveRecord(R: TMMDSEDWaveRecord);
begin
if R.Data <> nil then
GlobalFreePtr(R.Data);
end;
procedure MMDSEDLoadWaveFromRecord(R: TMMDSEDWaveRecord; Wave: TMMWave);
var
S: TMemoryStream;
begin
S := TMemoryStream.Create;
try
if R.Data <> nil then
begin
TStreamHack(S).SetPtr(R.Data,R.Size);
try
Wave.LoadFromStream(S);
finally
TStreamHack(S).SetPtr(nil,0);
end;
end;
finally
S.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -