MMDSPOBJ.INT 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMDSPObj;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. {$ELSE}
  32. WinTypes,
  33. WinProcs,
  34. {$ENDIF}
  35. SysUtils,
  36. Messages,
  37. Classes,
  38. Controls,
  39. Forms,
  40. DsgnIntf,
  41. MMSystem,
  42. MMObj,
  43. MMWaveIO,
  44. MMRegs,
  45. MMUtils,
  46. MMString;
  47. const
  48. READ_SIZE : Longint = 2*32768; { used for queue-auto-read operations }
  49. WRITE_SIZE: Longint = 2*32768; { used for queue-auto-write operations }
  50. type
  51. TMMBufferEvent = procedure(Sender: TObject; lpWaveHdr: PWaveHdr) of object;
  52. TMMBufferLoadEvent = procedure(Sender: TObject; lpWaveHdr: PWaveHdr; var MoreBuffers: Boolean) of object;
  53. TMMPort = (poInput,poOutput);
  54. TPropString = string[20];
  55. {$IFDEF WIN32}
  56. {-- TMMDSPThread -----------------------------------------------------------}
  57. TMMDSPThread = class(TThread)
  58. public
  59. constructor CreateSuspended; virtual;
  60. destructor Destroy; override;
  61. end;
  62. {$ENDIF}
  63. {-- TMMDSPComponent --------------------------------------------------------}
  64. TMMDSPComponent = class(TMMComponent)
  65. public
  66. constructor Create(aOwner: TComponent); override;
  67. destructor Destroy; override;
  68. procedure Opened; virtual;
  69. procedure Closed; virtual;
  70. procedure Started; virtual;
  71. procedure Paused; virtual;
  72. procedure Restarted; virtual;
  73. procedure Stopped; virtual;
  74. procedure BufferReady(lpwh: PWaveHdr); virtual;
  75. procedure BufferLoad(lpwh: PWaveHdr; var MoreBuffers: Boolean); virtual;
  76. procedure SetInputPort(aValue: TMMDSPComponent; PropName: TPropString); virtual;
  77. procedure SetOutputPort(aValue: TMMDSPComponent; PropName: TPropString); virtual;
  78. function CanConnectInput(aComponent: TComponent): Boolean; virtual;
  79. function CanConnectOutput(aComponent: TComponent): Boolean; virtual;
  80. property IsOpen: Boolean read FOpen;
  81. property Input : TMMDSPComponent read FInput write SetInput;
  82. property Output: TMMDSPComponent read FOutput write SetOutput;
  83. property PWaveFormat: PWaveFormatEx read GetPWaveFormat write SetPWaveFormat;
  84. property BufferSize: Longint read GetBufferSize write SetBufferSize default 2048;
  85. end;
  86. {-- TMMDSPInterface --------------------------------------------------------}
  87. TMMDSPInterface = class(TMMDSPComponent)
  88. public
  89. property OnOpen: TNotifyEvent read FOnOpen write FOnOpen;
  90. property OnStart: TNotifyEvent read FOnStart write FOnStart;
  91. property OnPause: TNotifyEvent read FOnPause write FOnPause;
  92. property OnRestart: TNotifyEvent read FOnRestart write FOnRestart;
  93. property OnStop: TNotifyEvent read FOnStop write FOnStop;
  94. property OnClose: TNotifyEvent read FOnClose write FOnClose;
  95. property OnBufferReady;
  96. property OnBufferLoad;
  97. property Input;
  98. property Output;
  99. end;
  100. {-- internal for loop handling ---------------------------------------------}
  101. PMMLoopRec = ^TMMLoopRec;
  102. TMMLoopRec = record
  103. dwLoop : LongBool; { is Loop enabled ? }
  104. dwLoopCnt : Longint; { number of loops required }
  105. dwLoopTmpCnt: Longint; { temp loop counter }
  106. dwLooping : LongBool; { End is reached Loop it or not }
  107. end;
  108. {-- internal WaveHdr -------------------------------------------------------}
  109. PMMWaveHdr = ^TMMWaveHdr;
  110. TMMWaveHdr = record
  111. wh : TWaveHdr;
  112. dwUser1 : Longint; { private user data }
  113. dwUser2 : Longint; { private user data }
  114. LoopRec : TMMLoopRec; { internal for loop handling }
  115. end;
  116. {-- TMMCustomSoundComponent ------------------------------------------------}
  117. TMMCustomSoundComponent = class(TMMDSPComponent)
  118. public
  119. constructor Create(AOwner: TComponent); override;
  120. destructor Destroy; override;
  121. end;
  122. {-- TMMDSPComponentInputEditor ---------------------------------------------}
  123. TMMDSPComponentInputEditor = class(TComponentProperty)
  124. public
  125. procedure GetValues(Proc: TGetStrProc); override;
  126. end;
  127. {-- TMMDSPComponentOutputEditor --------------------------------------------}
  128. TMMDSPComponentOutputEditor = class(TComponentProperty)
  129. public
  130. procedure GetValues(Proc: TGetStrProc); override;
  131. end;
  132. function DSPOutConnectCheck(C1, C2: TComponent): Boolean; far;
  133. function DSPInpConnectCheck(C1, C2: TComponent): Boolean; far;
  134. procedure GlobalDeconnectNotification(C: TComponent; Port: TMMPort; PortName: string);
  135. procedure GlobalSynchronize(VCLProc: TThreadMethod);
  136. const
  137. DSPList : TList = nil;
  138. ThreadList: TList = nil;
  139. implementation