MMPCX.INT 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Fax.: +49 (0)351-8037944 =}
  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: 08.03.98 - 21:15:14 $ =}
  24. {========================================================================}
  25. unit MMPCX;
  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. Graphics,
  39. Controls,
  40. Forms,
  41. Dialogs,
  42. DsgnIntf,
  43. MMObj,
  44. MMUtils,
  45. MMMath,
  46. MMPropEd,
  47. MMObsrv,
  48. MMPCXTol,
  49. MMPCXLib;
  50. const
  51. IOAuto = 0;
  52. type
  53. EMMPCXError = class(Exception);
  54. {-- TMMPCXVersion ---------------------------------------------------------}
  55. TMMPCXVersion = class(TMMObject)
  56. published
  57. property DriverMajor: Word read FDriverVersion write FWDummy stored False;
  58. property DriverMinor: Word read FDriverRelease write FWDummy stored False;
  59. property DriverState: Word read FDriverState write FWDummy stored False;
  60. property ToolMajor : Word read FToolVersion write FWDummy stored False;
  61. property ToolMinor : Word read FToolRelease write FWDummy stored False;
  62. property ToolState : Word read FToolState write FWDummy stored False;
  63. end;
  64. {-- TMMPCXFormat Types ----------------------------------------------------}
  65. TMMPCXFMTMode = TMMMode;
  66. TMMPCXFrequency = 8000..48000;
  67. TMMPCXFileFormat = (ftRAW,ftWAV,ftMUSI);
  68. TMMPCXCompression = (cMPEG,cPCM8,cPCM16,cPCM24);
  69. TMMPCXMPEGLayer = (mLayer1,mLayer2);
  70. TMMPCXPCMEndian = (enIntel,enMotorola);
  71. TMMPCXExtraStereo = (esNormal,esDualChannels,esJointStereo);
  72. {-- TMMPCXFormat ----------------------------------------------------------}
  73. TMMPCXFormat = class(TMMObject)
  74. public
  75. constructor Create;
  76. procedure Assign(Source: TPersistent); override;
  77. procedure InitFormat;
  78. published
  79. property Mode : TMMPCXFMTMode read FMode write FMode;
  80. property Frequency : TMMPCXFrequency read FFrequency write FFrequency;
  81. property FileFormat : TMMPCXFileFormat read FFileFormat write FFileFormat;
  82. property Compression: TMMPCXCompression read FCompression write FCompression;
  83. property MPEGBitrate: integer read FMPEGBitrate write FMPEGBitrate;
  84. property MPEGLayer : TMMPCXMPEGLayer read FMPEGLayer write FMPEGLayer;
  85. property PCMEndian : TMMPCXPCMEndian read FPCMEndian write FPCMEndian;
  86. property ExtraStereo: TMMPCXExtraStereo read FExtraStereo write FExtraStereo;
  87. end;
  88. {-- TMMPCXCard Types ------------------------------------------------------}
  89. TMMPCXPipeMode = (pmOutput,pmInput);
  90. TMMPCXIOChannel = type integer;
  91. TMMPCXClockMode = (cmBoard,cmDigitalData,cmDigitalSynchro);
  92. TMMPCXDataInMode = (imAnalog,imDigital,imDigitalSynchro);
  93. TMMPCXOutMode = (omProfesional,omConsumer);
  94. TMMPCXAnalogInput = (aiLine,aiMic);
  95. TMMPCXLevelType = (ltDigital,ltAnalog,ltMonitor);
  96. TMMPCXEQBands = (eqBass,eqMedium,eqTreble);
  97. TMMPCXEQ = set of TMMPCXEQBands;
  98. TMMPCXNotify = (nBeforeEndStream,nBeginFile,nCloseFile,nEndFile);
  99. TMMPCXStartCondition = (scASAP,scONSTART,scASAEOF,scSTREAMBEGINREF,
  100. scSTREAMENDREF,scPIPEREF,scAFTERCURRENT);
  101. TMMPCXPipeStatus = (psNotAllocated,psStopped,psStarted,psBusy,psUnderrun,psPaused);
  102. TMMPCXStreamStatus = (ssNotAvailable,ssFree,ssInitialized,ssBusy,ssUnderrun,ssPaused);
  103. TMMPCXPipe = class;
  104. TMMPCXStream = class;
  105. TMMPCXCardNotifyEvent = procedure(Sender: TObject; Pipe: TMMPCXPipe;
  106. Stream: TMMPCXStream; Reason: TMMPCXNotify) of object;
  107. TMMPCXPipeNotifyEvent = procedure(Sender: TObject; Stream: TMMPCXStream;
  108. Reason: TMMPCXNotify) of object;
  109. TMMPCXStreamNotifyEvent = procedure(Sender: TObject; Reason: TMMPCXNotify) of object;
  110. {-- TMMPCXCard ------------------------------------------------------------}
  111. TMMPCXCard = class(TMMComponent)
  112. public
  113. constructor Create(aOwner: TComponent); override;
  114. destructor Destroy; override;
  115. function MaxInputLevel(Input: integer): Float;
  116. function MaxOutputLevel(Output: integer): Float;
  117. function ChannelAvailable(IOChannel: integer; PipeMode: TMMPCXPipeMode): Boolean;
  118. procedure SetDefaultPath(Path: string);
  119. published
  120. property OnNotify : TMMPCXCardNotifyEvent read FOnNotify write FOnNotify;
  121. property Version : TMMPCXVersion read GetVersion write SetVersion stored False;
  122. property NumInputs : integer read GetNumInputs write SetDummyInteger stored False;
  123. property NumOutputs: integer read GetNumOutputs write SetDummyInteger stored False;
  124. end;
  125. {-- TMMCustomPCXPipe ------------------------------------------------------}
  126. TMMCustomPCXPipe = class(TMMComponent);
  127. {-- TMMPCXPipe ------------------------------------------------------------}
  128. TMMPCXPipe = class(TMMCustomPCXPipe)
  129. public
  130. constructor Create(aOwner: TComponent); override;
  131. destructor Destroy; override;
  132. procedure AddObserver(O: TMMObserver);
  133. procedure RemoveObserver(O: TMMObserver);
  134. property Handle: TPIPE_TYPE read FPipeHandle;
  135. property AnalogSupported: Boolean read FAnalogSupported;
  136. property DigitalSupported: Boolean read FDigitalSupported;
  137. { pipe allocation }
  138. procedure Allocate;
  139. procedure Release;
  140. { pipe control }
  141. procedure Start;
  142. procedure Stop;
  143. procedure Pause(PauseState: Boolean);
  144. procedure Mute(MuteState: Boolean);
  145. procedure MuteMonitor(MuteState: Boolean);
  146. { pipe speed control }
  147. property Speed: Float read GetPipeSpeed write SetPipeSpeed;
  148. property Stretch: Float read GetPipeStretch write SetPipeStretch;
  149. { pipe level control }
  150. procedure SetLevel(LevelType: TMMPCXLevelType; LeftValue,RightValue: Float);
  151. procedure GetLevel(LevelType: TMMPCXLevelType; var LeftValue,RightValue: Float);
  152. procedure GetVUMeter(var PeakLeft,PeakRight: Float);
  153. { time code }
  154. procedure SetTimeCodeUnit(FrameBySec: Word; DropFrame: BOOL);
  155. procedure GetTimeCode(var Hour,Min,Sec,Frame: Word; var SamplePackets: DWORD);
  156. { pipe status }
  157. function Status: TMMPCXPipeStatus;
  158. procedure Position(var LowPos, HighPos: DWORD);
  159. published
  160. property OnNotify : TMMPCXPipeNotifyEvent read FOnNotify write FOnNotify;
  161. property OnAllocate : TNotifyEvent read FOnAllocate write FOnAllocate;
  162. property OnRelease : TNotifyEvent read FOnRelease write FOnRelease;
  163. property PCXCard : TMMPCXCard read FPCXCard write SetPCXCard;
  164. property MasterPipe : TMMCustomPCXPipe read GetMasterPipe write SetMasterPipe;
  165. property AutoStart : Boolean read FAutoStart write FAutoStart default False;
  166. property Format : TMMPCXFormat read FFormat write FFormat;
  167. property Mode : TMMPCXPipeMode read FPipeMode write SetPipeMode default pmOutput;
  168. property IOChannel : TMMPCXIOChannel read GetIOChannel write SetIOChannel default 0;
  169. property ClockMode : TMMPCXClockMode read FClockMode write SetClockMode default cmBoard;
  170. property DataInMode : TMMPCXDataInMode read FDataInMode write SetDataInMode default imAnalog;
  171. property DigitalOutMode: TMMPCXOutMode read FOutMode write SetDigitalOutMode default omProfesional;
  172. property AnalogInput : TMMPCXAnalogInput read FAnalogInput write SetAnalogInput default aiLine;
  173. property BoardName : string read GetBoardName write SetBoardName stored False;
  174. property WorkAsMaster : Boolean read FWorkAsMaster write SetWorkAsMaster stored True;
  175. property Enabled : Boolean read GetEnabled write SetEnabled default False;
  176. end;
  177. {-- TMMCustomPCXStream ----------------------------------------------------}
  178. TMMCustomPCXStream = class(TMMComponent);
  179. {-- TMMPCXStream ----------------------------------------------------------}
  180. TMMPCXStream = class(TMMCustomPCXStream)
  181. public
  182. constructor Create(aOwner: TComponent); override;
  183. destructor Destroy; override;
  184. procedure AddObserver(O: TMMObserver);
  185. procedure RemoveObserver(O: TMMObserver);
  186. property Handle: TSTREAM_TYPE read FStreamHandle;
  187. procedure LoadFromFile(const FName: string);
  188. { stream status }
  189. function Status: TMMPCXStreamStatus;
  190. procedure Position(var ElapseTime, RemainTime: DWORD);
  191. published
  192. property OnNotify : TMMPCXStreamNotifyEvent read FOnNotify write FOnNotify;
  193. property PCXPipe : TMMPCXPipe read FPCXPipe write SetPCXPipe;
  194. property MasterStream : TMMCustomPCXStream read GetMasterStream write SetMasterStream;
  195. property Format : TMMPCXFormat read FFormat write FFormat;
  196. property FileName : TFileName read FFileName write SetFileName;
  197. property WorkAsMaster : Boolean read FWorkAsMaster write SetWorkAsMaster stored True;
  198. end;
  199. {-- TMMPCXOutputStream ----------------------------------------------------}
  200. TMMPCXOutputStream = class(TMMPCXStream)
  201. public
  202. constructor Create(aOwner: TComponent); override;
  203. { prepare a stream with a file }
  204. procedure PrepareEx(StartPos,LoopPos,EndPos: Longint;
  205. RefStream: TMMPCXOutputStream;
  206. RefOffsetLow,RefOffsetHigh: Longint);
  207. procedure Prepare(StartPos,EndPos: Longint);
  208. { stream control }
  209. procedure Play;
  210. procedure Stop;
  211. procedure StopFade(FadeOutDuration: Longint);
  212. procedure Pause(PauseState: Boolean);
  213. { stream level control }
  214. procedure SetLevel(LevelValue: Float);
  215. procedure GetLevel(var LevelValue: Float);
  216. procedure SetPanLevel(LeftValue,RightValue: Float);
  217. procedure GetPanLevel(var LeftValue,RightValue: Float);
  218. procedure GoToLevel(Duration: Longint; EndLevel: Float);
  219. { equaliser settings }
  220. procedure SetEQ(Bands: TMMPCXEQ; Level: Float);
  221. procedure GetEQ(Band: TMMPCXEQBands; var Level: Float);
  222. published
  223. property Mute : Boolean read GetMute write SetMute default False;
  224. property Looping : Boolean read FLooping write FLooping default False;
  225. property LoopCount : Longint read FLoopCount write FLoopCount default 0;
  226. property StartCondition: TMMPCXStartCondition read FStartCondition write FStartCondition default scASAP;
  227. property FadeInTime : Longint read FFadeInTime write FFadeInTime default 0;
  228. property FadeOutTime : Longint read FFadeOutTime write FFadeOutTime default 0;
  229. end;
  230. {-- TMMPCXInputStream ----------------------------------------------------}
  231. TMMPCXInputStream = class(TMMPCXStream)
  232. public
  233. procedure Prepare(MaxDuration: Longint);
  234. { stream control }
  235. procedure Recording;
  236. procedure Stop;
  237. procedure Pause(PauseState: Boolean);
  238. end;
  239. implementation
  240. end.