📄 mmmixer.pas
字号:
raise EMMMixerDeviceError.Create('Error requesting all controls');
end;
{-- TMMMixerDevice ------------------------------------------------------}
function TMMMixerDevice.GetControlInfo(var Info: TMixerLineControls; Flags: DWORD): Boolean;
begin
Info.cbStruct:= SizeOf(Info);
Result:= CheckExcl(mixerGetLineControls(MixerId,@Info,MIXER_OBJECTF_MIXER or Flags), [MIXERR_INVALCONTROL,MIXERR_INVALLINE,MMSYSERR_NODRIVER])
= MMSYSERR_NOERROR;
end;
{-- TMMMixerDevice ------------------------------------------------------}
function TMMMixerDevice.GetControlByType(LineId: TMMLineId; ControlType: TMMControlType): TMMControlId;
var
Info: TMixerControl;
begin
if GetControlInfoByType(LineId, ControlType, Info) then
Result:= Info.dwControlId
else
Result:= badControlId;
end;
{-- TMMMixerDevice ------------------------------------------------------}
function TMMMixerDevice.GetDestination(Index: TMMLineIndex): TMMLineId;
var
Info: TMixerLine;
begin
if GetLineInfoByDestination(Index,Info) then
Result:= Info.dwLineId
else
Result:= badLineId;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.SetBooleanControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PBoolean);
var
Buf, P : PMixerControlDetailsBoolean;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
for i:= 0 to N - 1 do
begin
P^.fValue:= Ord(Values^);
Inc(P);
Inc(Values);
end;
SetControlValues(Id, SizeOf(P^), Channels, Items, Buf, MIXER_SETCONTROLDETAILSF_VALUE);
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.GetBooleanControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PBoolean);
var
Buf, P : PMixerControlDetailsBoolean;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
GetControlValues(Id, SizeOf(P^), Channels, Items, P, MIXER_GETCONTROLDETAILSF_VALUE);
for i:= 0 to N - 1 do
begin
Values^:= Boolean(P^.fValue);
Inc(P);
Inc(Values);
end;
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.SetSignedControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PInteger);
var
Buf, P : PMixerControlDetailsSigned;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
for i:= 0 to N - 1 do
begin
P^.lValue:= Values^;
Inc(P);
Inc(Values);
end;
SetControlValues(Id, SizeOf(P^), Channels, Items, Buf, MIXER_SETCONTROLDETAILSF_VALUE);
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.GetSignedControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PInteger);
var
Buf, P : PMixerControlDetailsSigned;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
GetControlValues(Id, SizeOf(P^), Channels, Items, P, MIXER_GETCONTROLDETAILSF_VALUE);
for i:= 0 to N - 1 do
begin
Values^:= P^.lValue;
Inc(P);
Inc(Values);
end;
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.SetUnsignedControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PCardinal);
var
Buf, P : PMixerControlDetailsUnsigned;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
for i:= 0 to N - 1 do
begin
P^.dwValue:= Values^;
Inc(P);
Inc(Values);
end;
SetControlValues(Id, SizeOf(P^), Channels, Items, Buf, MIXER_SETCONTROLDETAILSF_VALUE);
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.GetUnsignedControl(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: PCardinal);
var
Buf, P : PMixerControlDetailsUnsigned;
i : Integer;
N : Integer;
begin
N := Max(Channels,1) * Max(Items,1);
Buf:= GlobalAllocMem(SizeOf(P^) * N);
try
P:= Buf;
GetControlValues(Id, SizeOf(P^), Channels, Items, P, MIXER_GETCONTROLDETAILSF_VALUE);
for i:= 0 to N - 1 do
begin
Values^:= P^.dwValue;
Inc(P);
Inc(Values);
end;
finally
GlobalFreeMem(Pointer(Buf));
end;
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.GetItemsInfo(Id: TMMControlId; Channels: TMMChannelIndex; Items: TMMItemIndex; Infos: PMixerControlDetailsListText);
var
Details: TMixerControlDetails;
begin
FillChar(Details,SizeOf(Details),0);
Details.cbStruct := SizeOf(Details);
Details.cbDetails := SizeOf(Infos^);
Details.paDetails := Infos;
Details.dwControlId := Id;
Details.cMultipleItems := Items;
Details.cChannels := Channels;
Check(mixerGetControlDetails(MixerId, @Details, MIXER_OBJECTF_MIXER or MIXER_GETCONTROLDETAILSF_LISTTEXT));
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.GetControlValues(Id: TMMControlId; ItemSize: DWORD; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: Pointer; Flags: DWORD);
var
Details : TMixerControlDetails;
begin
FillChar(Details,SizeOf(Details),0);
Details.cbStruct := SizeOf(Details);
Details.cbDetails := ItemSize;
Details.paDetails := Values;
Details.dwControlId := Id;
Details.cMultipleItems := Items;
Details.cChannels := Channels;
Check(mixerGetControlDetails(MixerId, @Details, MIXER_OBJECTF_MIXER or Flags));
end;
{-- TMMMixerDevice ------------------------------------------------------}
procedure TMMMixerDevice.SetControlValues(Id: TMMControlId; ItemSize: DWORD; Channels: TMMChannelIndex; Items: TMMItemIndex; Values: Pointer; Flags: DWORD);
var
Details : TMixerControlDetails;
begin
FillChar(Details,SizeOf(Details),0);
Details.cbStruct := SizeOf(Details);
Details.cbDetails := ItemSize;
Details.paDetails := Values;
Details.dwControlId := Id;
Details.cMultipleItems := Items;
Details.cChannels := Channels;
Check(mixerSetControlDetails(MixerId, @Details, MIXER_OBJECTF_MIXER or Flags));
end;
{== TMMLineInfo =========================================================}
procedure TMMLineInfo.SetDummyStr(const Value: string);
begin
;
end;
{-- TMMLineInfo ---------------------------------------------------------}
procedure TMMLineInfo.Clear;
begin
FFlags := [];
FChannels := 0;
FConnections := 0;
FControls := 0;
FShortName := '';
FName := '';
end;
{== TMMAudioLine ========================================================}
constructor TMMAudioLine.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLineInfo := TMMLineInfo.Create;
FObserver := TMMObserver.Create;
FObserver.OnNotify := MixerNotify;
FTargetObserver := TMMObserver.Create;
FTargetObserver.OnNotify:= TargetNotify;
FDestObserver := TMMObserver.Create;
FDestObserver.OnNotify := DestNotify;
FLineId := badLineId;
FObservable := TMMObservable.Create;
end;
{-- TMMAudioLine --------------------------------------------------------}
destructor TMMAudioLine.Destroy;
begin
FObserver.Free;
FTargetObserver.Free;
FDestObserver.Free;
FObservable.Free;
FObservable:= nil;
FLineInfo.Free;
inherited Destroy;
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent,Operation);
if (Operation = opRemove) then
begin
if (AComponent = FMixer) then
Mixer:= nil
else if (AComponent = FTarget) then
Target:= nil
else if (AComponent = FDestLine) then
DestLine := nil
end;
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.SetMixer(Value: TMMMixerDevice);
begin
if (Value <> FMixer) then
begin
if (FMixer <> nil) then
FMixer.RemoveObserver(FObserver);
FMixer:= Value;
if (FMixer <> nil) then
begin
FMixer.AddObserver(FObserver);
FMixer.FreeNotification(Self);
end;
UpdateLine;
end;
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.SetLineId(Value: TMMLineId);
begin
if (Value <> FLineId) then
begin
FLineId := Value;
FLineSetup := lsLineId;
UpdateLine;
end;
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.SetComponentType(Value: TMMComponentType);
begin
if (Value <> FComponentType) then
begin
FComponentType := Value;
FLineSetup := lsCompType;
UpdateLine;
end;
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.SetTarget(Value: TMMCustomAudioDevice);
begin
if (Value <> nil) and (Value.GetDeviceType = dtMixer) then
{ TODO: Should be resource id }
raise EMMMixerDeviceError.Create('Can''t target to mixer');
if Value <> FTarget then
begin
if FTarget <> nil then
FTarget.RemoveObserver(FTargetObserver);
FTarget:= Value;
if FTarget <> nil then
begin
FTarget.AddObserver(FTargetObserver);
FTarget.FreeNotification(Self);
end;
FLineSetup := lsTarget;
UpdateLine;
end;
end;
{-- TMMAudioLine --------------------------------------------------------}
function TMMAudioLine.StoreLineId: Boolean;
begin
Result:= (FLineSetup = lsLineId) and (FLineId <> badLineId);
end;
{-- TMMAudioLine --------------------------------------------------------}
function TMMAudioLine.StoreComponentType: Boolean;
begin
Result := (FLineSetup = lsCompType) and (FComponentType <> Low(TMMComponentType));
end;
{-- TMMAudioLine --------------------------------------------------------}
function TMMAudioLine.StoreTarget: Boolean;
begin
Result := (FLineSetup = lsTarget) and (FTarget <> nil);
end;
{-- TMMAudioLine --------------------------------------------------------}
procedure TMMAudioLine.SetLineInfo(const Info: TMMLineInfo);
begin
;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -