MMWAVE.INT 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 MMWave;
  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. MMSystem,
  43. MMUtils,
  44. MMObj,
  45. MMString,
  46. MMNotify,
  47. MMDSPObj,
  48. MMRegs,
  49. MMRIFF,
  50. MMWaveIO,
  51. MMPCMSup,
  52. MMFade,
  53. MMEnvelp,
  54. MMPanel;
  55. type
  56. EMMWaveError = class(Exception);
  57. TMMPlayMode = (pmSync, pmAsync, pmLoop);
  58. TMMWaveProgress = procedure(Sender: TObject; CurByte, NumBytes: Longint;
  59. Var Cancel: Boolean) of Object;
  60. {-- TMMWave ------------------------------------------------------------}
  61. TMMWave = class(TMMObject)
  62. public
  63. ChangeList: TList;
  64. procedure Progress(CurByte, NumBytes: Longint; Var Cancel: Boolean);
  65. constructor Create; virtual;
  66. destructor Destroy; override;
  67. procedure Assign(Source: TPersistent); override;
  68. procedure FreeWave;
  69. function PlaySound(aValue: TMMPlayMode): Boolean;
  70. procedure StopSound;
  71. procedure LoadFromStream(Stream: TStream); virtual;
  72. procedure SaveToStream(Stream: TStream); virtual;
  73. procedure LoadFromFile(const FileName: TFileName);
  74. procedure SaveToFile(const Filename: TFileName);
  75. procedure ImportFromRaw(const FileName: TFileName; BitLength,
  76. Channels, SampleRate: Cardinal);
  77. procedure OpenFile;
  78. procedure CloseFile;
  79. procedure CreateFile(const FileName: TFileName; pwfx: PWaveFormatEx);
  80. procedure ConvertFile(const FileName: TFileName; pwfxDst: PWaveFormatEx);
  81. function GetInfoChunk(fcc: String): String;
  82. procedure SetInfoChunk(fcc, Text: String);
  83. function ReadDataBytes(Buffer: PChar; NumBytes: Longint): Longint;
  84. function ReadDataSamples(Buffer: PChar; NumSamples: Longint): Longint;
  85. function WriteDataBytes(Buffer: PChar; NumBytes: Longint): Longint;
  86. function WriteDataSamples(Buffer: PChar; NumSamples: Longint): Longint;
  87. property StartPos: Longint read GetStartPos write SetStartPos;
  88. property EndPos: Longint read GetEndPos write SetEndPos;
  89. property Position: Longint read GetPosition write SetPosition;
  90. property Empty: Boolean read GetEmpty;
  91. property PWaveFormat: PWaveFormatEx read GetPWaveFormat write SetPWaveFormat;
  92. property PWaveIOInfo: PWaveIOCB read FPWAVEIOCB write SetPWaveIOCB;
  93. property PWaveData: Pointer read GetPWaveData;
  94. property BytesLeft: Longint read GetBytesLeft;
  95. published
  96. property OnProgress: TMMWaveProgress read FOnProgress write FOnProgress;
  97. property TimeFormat: TMMTimeFormats read FTimeFormat write SetTimeFormat default tfSample;
  98. property FileMustExist: Boolean read FFileMustExist write SetFileMustExist default True; { must come before FileName ! }
  99. property FileName: TFileName read FFileName write SetFileName;
  100. property BitLength: Word read GetBits write SetBits stored False;
  101. property Mode: TMMMode read GetMode write SetMode stored False;
  102. property FormatTag: Word read GetFormatTag write SetFormatTag stored False;
  103. property FormatString: String read GetFormatString write SetFormatString stored False;
  104. property SampleRate: Longint read GetSampleRate write SetDummy stored False;
  105. property FileSize: LongInt read GetFileSize write SetDummy stored False;
  106. property DataSize: Longint read GetDataSize write SetDummy stored False;
  107. property IOBufferSize: Longint read FIOBufSize write SetIOBufSize default 32768;
  108. end;
  109. {-- TMMCustomWaveFile --------------------------------------------------}
  110. TMMCustomWaveFile = class(TMMDSPComponent)
  111. public
  112. constructor Create(AOwner: TComponent); override;
  113. destructor Destroy; override;
  114. procedure LoadFromFile(const FileName: String);
  115. procedure SaveToFile(const FileName: String);
  116. function PlaySound(aValue: TMMPlayMode): Boolean;
  117. procedure StopSound;
  118. protected
  119. property OnOpen: TNotifyEvent read FOnOpen write FOnOpen;
  120. property OnClose: TNotifyEvent read FOnClose write FOnClose;
  121. property OnChange: TNotifyEvent read FOnChange write FOnChange;
  122. property Enabled: Boolean read FEnabled write FEnabled default True;
  123. property Envelope: TMMEnvelope read FEnvelope write SetEnvelope;
  124. published
  125. property Wave: TMMWave read FWave write SetWave;
  126. end;
  127. {-- TMMWaveFile --------------------------------------------------------}
  128. TMMWaveFile = class(TMMCustomWaveFile)
  129. published
  130. property OnOpen: TNotifyEvent read FOnOpen write FOnOpen;
  131. property OnClose: TNotifyEvent read FOnClose write FOnClose;
  132. property Input;
  133. property Output;
  134. property Enabled;
  135. property Envelope;
  136. end;
  137. {-- TMMCustomMemoryWave ------------------------------------------------}
  138. TMMCustomMemoryWave = class(TMMCustomWaveFile)
  139. public
  140. constructor Create(AOwner: TComponent); override;
  141. destructor Destroy; override;
  142. end;
  143. {-- TMMMemoryWave ------------------------------------------------------}
  144. TMMMemoryWave = class(TMMCustomMemoryWave)
  145. published
  146. property OnOpen: TNotifyEvent read FOnOpen write FOnOpen;
  147. property OnClose: TNotifyEvent read FOnClose write FOnClose;
  148. property Output;
  149. property Enabled;
  150. end;
  151. { TODO: ableiten von TMMCustomMarkerPanel und verschiedene Eigenschaften veröffentlichen }
  152. {-- TMMCustomWaveEditor ------------------------------------------------}
  153. TMMCustomWaveEditor = class(TMMMarkerPanel)
  154. public
  155. property Wave: TMMWave read GetWave write SetWave;
  156. end;
  157. implementation