📄 mmdspobj.pas
字号:
Output := nil;
PWaveFormat := nil;
DSPList.Remove(Self);
if DSPList.Count = 0 then
begin
DSPList.Free;
DSPList := nil;
end;
inherited Destroy;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Operation = opRemove then
begin
if AComponent = FInput then
Input := nil
else if AComponent = FOutput then
Output := nil;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.CanConnectInput(aComponent: TComponent): Boolean;
begin
Result := False;
if (aComponent <> Self) and (aComponent is TMMDSPComponent) and
((GetPropInfo(TMMDSPComponent(aComponent).ClassInfo, 'Output') <> nil) or
TMMDSPComponent(aComponent).FOutputValid) then
begin
{ don't allow ring connection }
if (Output <> nil) then
Result := Output.CanConnectInput(aComponent)
else
Result := True;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.CanConnectOutput(aComponent: TComponent): Boolean;
begin
Result := False;
if (aComponent <> Self) and (aComponent is TMMDSPComponent) and
((GetPropInfo(TMMDSPComponent(aComponent).ClassInfo, 'Input') <> nil) or
TMMDSPComponent(aComponent).FInputValid) then
begin
{ don't allow ring connection }
if (Input <> nil) then
Result := Input.CanConnectOutput(aComponent)
else
Result := True;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.DeconnectNotification(C: TComponent; Port: TMMPort; PortName: string);
var
PropInfo: PPropInfo;
begin
if (Port = poInput) then
begin
if (Output = C) and (FOutPropName = PortName) then
begin
PropInfo := GetPropInfo(C.ClassInfo, FOutPropName);
if (PropInfo <> nil) and (GetOrdProp(C,PropInfo) = Longint(Self)) then
SetOutputPort(nil,'');
end;
end
else
begin
if (Input = C) and (FInpPropName = PortName) then
begin
PropInfo := GetPropInfo(C.ClassInfo, FInpPropName);
if (PropInfo <> nil) and (GetOrdProp(C,PropInfo) = Longint(Self)) then
SetInputPort(nil,'');
end;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.SetInputPort(aValue: TMMDSPComponent; PropName: TPropString);
begin
FInput := aValue;
FInpPropName := PropName;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.SetOutputPort(aValue: TMMDSPComponent; PropName: TPropString);
begin
FOutput := aValue;
FOutPropName := PropName;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.SetInput(aValue: TMMDSPComponent);
begin
if (aValue <> FInput) and ((aValue = nil) or CanConnectInput(aValue)) then
begin
Stopped;
if (FInput <> nil) then
begin
GlobalDeconnectNotification(Self,poInput,'Input');
SetInputPort(nil,'');
ChangePWaveFormat(nil);
end;
if (aValue <> nil) then
begin
GlobalDeconnectNotification(aValue,poOutput,'Output');
SetInputPort(aValue,'Output');
FInput.SetOutputPort(Self,'Input');
UpdateParams;
end;
end;
{$IFDEF WIN32}
{$IFDEF TRIAL}
{$DEFINE _HACK1}
{$I MMHACK.INC}
{$ENDIF}
{$ENDIF}
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.GetInput: TMMDSPComponent;
begin
Result := FInput;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.SetOutput(aValue: TMMDSPComponent);
begin
if (aValue <> FOutput) and ((aValue = nil) or CanConnectOutput(aValue)) then
begin
Stopped;
if (FOutput <> nil) then
begin
GlobalDeconnectNotification(Self,poOutput,'Output');
FOutput.ChangePWaveFormat(nil);
SetOutputPort(nil,'');
end;
if (aValue <> nil) then
begin
GlobalDeconnectNotification(aValue,poInput,'Input');
SetOutputPort(aValue,'Input');
FOutput.SetInputPort(Self,'Output');
UpdateParams;
end;
end;
{$IFDEF WIN32}
{$IFDEF TRIAL}
{$DEFINE _HACK2}
{$I MMHACK.INC}
{$ENDIF}
{$ENDIF}
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.GetOutput: TMMDSPComponent;
begin
Result := FOutput;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.UpdateParams;
begin
if (csLoading in ComponentState) or
(csReading in ComponentState) or
(csDestroying in ComponentState) then exit;
if (Input <> nil) then
begin
ChangePWaveFormat(Input.PWaveFormat);
end
else if (Output <> nil) then
begin
Output.ChangePWaveFormat(PWaveFormat);
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Loaded;
begin
inherited Loaded;
PWaveFormat := FPWaveFormat;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.ChangePWaveFormat(aValue: PWaveFormatEx);
begin
PWaveFormat := aValue;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.SetPWaveFormat(aValue: PWaveFormatEx);
begin
if (aValue <> FPWaveFormat) then
begin
if FStarted then Stopped;
GlobalFreeMem(Pointer(FPWaveFormat));
FPWaveFormat := wioCopyWaveFormat(aValue);
end;
if not (csLoading in ComponentState) and
not (csReading in ComponentState) and
not (csDestroying in ComponentState) then
if (Output <> nil) then
Output.ChangePWaveFormat(PWaveFormat);
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.GetPWaveFormat: PWaveFormatEx;
begin
Result := FPWaveFormat;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
Procedure TMMDSPComponent.SetBufferSize(aValue: Longint);
begin
if (aValue <> FOrigBufferSize) then
begin
if FStarted then Stopped;
FOrigBufferSize := aValue;
end;
{$IFDEF WIN32}
{$IFDEF TRIAL}
{$DEFINE _HACK3}
{$I MMHACK.INC}
{$ENDIF}
{$ENDIF}
end;
{-- TMMDSPComponent -----------------------------------------------------------}
function TMMDSPComponent.GetBufferSize: Longint;
begin
if FOpen then
Result := FBufferSize
else
Result := FOrigBufferSize;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Opened;
begin
if not FOpen then
begin
if (PWaveFormat <> nil) then
{ make the wave buffer size a multiple of the block align... }
FBufferSize := Max(FOrigBufferSize-(FOrigBufferSize mod PWaveFormat^.nBlockAlign),PWaveFormat^.nBlockAlign)
else
FBufferSize := FOrigBufferSize;
FOpen := True;
FStarted := False;
FPaused := False;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Closed;
begin
if FOpen then
begin
FOpen := False;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Started;
begin
if not FStarted and FOpen then
begin
FStarted := True;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Paused;
begin
if not FPaused then
FPaused := True;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Restarted;
begin
if FPaused then
FPaused := False;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Reseting;
begin
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Looped;
begin
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.Stopped;
begin
if FStarted then
begin
FStarted := False;
FPaused := False;
end;
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.BufferReady(lpwh: PWaveHdr);
begin
if assigned(FOnBufferReady) then FOnBufferReady(Self, lpwh);
if (Output <> nil) then Output.BufferReady(lpwh);
end;
{-- TMMDSPComponent -----------------------------------------------------------}
procedure TMMDSPComponent.BufferLoad(lpwh: PWaveHdr; var MoreBuffers: Boolean);
begin
if assigned(FOnBufferLoad) then FOnBufferLoad(Self, lpwh, MoreBuffers);
if (Input <> nil) then Input.BufferLoad(lpwh, MoreBuffers);
if assigned(FOnBufferFilled) and (lpwh^.dwBytesRecorded > 0) then FOnBufferFilled(Self,lpwh);
end;
{== TMMDSPInterface ===========================================================}
procedure TMMDSPInterface.Opened;
begin
if not FOpen then
begin
inherited Opened;
if assigned(FOnOpen) then FOnOpen(Self);
end;
end;
{-- TMMDSPInterface -----------------------------------------------------------}
procedure TMMDSPInterface.Closed;
begin
if FOpen then
begin
inherited Closed;
if assigned(FOnClose) then FOnClose(Self);
end;
end;
{-- TMMDSPInterface -----------------------------------------------------------}
procedure TMMDSPInterface.Started;
begin
if not FStarted and FOpen then
begin
inherited Started;
if assigned(FOnStart) then FOnStart(Self);
end;
end;
{-- TMMDSPInterface -----------------------------------------------------------}
procedure TMMDSPInterface.Paused;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -