MMWAVEIO.INT 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 MMWaveIO;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. {$ELSE}
  32. WinTypes,
  33. WinProcs,
  34. {$ENDIF}
  35. SysUtils,
  36. MMSystem,
  37. MMRegs,
  38. MMRiff,
  39. MMUtils,
  40. MMAbout;
  41. const
  42. { file open flags for waveio functions }
  43. RIFF_FILE = $0001;
  44. RIFF_RESOURCE = $0002;
  45. RIFF_MEMORY = $0004;
  46. { get the extra Info only }
  47. RIFF_INFO_ONLY = $0008;
  48. type
  49. PWAVEIOCB = ^TWAVEIOCB;
  50. TWAVEIOCB = record { do not change the first items !!!! }
  51. dwSize : Longint; { size for the structure }
  52. dwFlags : Longint; { flags used to open the file }
  53. hmmio : THMMIO; { handle to open file }
  54. ckRIFF,ckDATA : TMMCKINFO; { the current RIFF and data chunk }
  55. hMem : THandle; { <> 0 if we have a res. file, free it !}
  56. dwFileSize : Longint; { the filesize for the actual file }
  57. dwDataBytes : Longint; { the data size for the actual file }
  58. dwDataOffset : Longint; { offset from data chunk }
  59. dwDataSamples : Longint; { how much samples in the file }
  60. dwFirstSample : Longint; { the first sample to read }
  61. dwLastSample : Longint; { the last Sample to read }
  62. dwBytesLeft : Longint; { how many bytes to play }
  63. dwPosition : Longint; { the current file position }
  64. lpFilePath : PChar; { filename from the actual file }
  65. lpDisp : PDispList; { pointer to display chunk's }
  66. lpInfo : PInfoChunk; { pointer to info chunk }
  67. { this MUST be the last element in this structure--its length is }
  68. { not fixed; use ab[] to get at any extra bytes (note! the length }
  69. { of ab[] is in wfx.cbSize--this CAN be zero!) }
  70. wfx : TWaveFormatEx;
  71. ab : array[0..0] of Byte;
  72. end;
  73. const
  74. { error returns from waveio functions }
  75. WIOERR_BASE = 100;
  76. WIOERR_NOERROR = 0;
  77. WIOERR_ERROR = WIOERR_BASE+1;
  78. WIOERR_BADHANDLE = WIOERR_BASE+2;
  79. WIOERR_BADFLAGS = WIOERR_BASE+3;
  80. WIOERR_BADPARAM = WIOERR_BASE+4;
  81. WIOERR_BADSIZE = WIOERR_BASE+5;
  82. WIOERR_FILEERROR = WIOERR_BASE+6;
  83. WIOERR_NOMEM = WIOERR_BASE+7;
  84. WIOERR_BADFILE = WIOERR_BASE+8;
  85. WIOERR_NODEVICE = WIOERR_BASE+9;
  86. WIOERR_BADFORMAT = WIOERR_BASE+10;
  87. WIOERR_ALLOCATED = WIOERR_BASE+11;
  88. WIOERR_NOTSUPPORTED = WIOERR_BASE+12;
  89. function wioBytesPerSample(pwfx: PWaveFormatEx): integer;
  90. function wioBytesToSamples(pwfx: PWaveFormatEx; dwBytes: Longint): Longint;
  91. function wioBytesToTime(pwfx: PWaveFormatEx; dwBytes: Longint): Longint;
  92. function wioSamplesToBytes(pwfx: PWaveFormatEx; dwSamples: Longint): Longint;
  93. function wioSamplesToTime(pwfx: PWaveFormatEx; dwSamples: Longint): Longint;
  94. function wioTimeToSamples(pwfx: PWaveFormatEx; dwTime: Longint): Longint;
  95. function wioTimeToBytes(pwfx: PWaveFormatEx; dwTime: Longint): Longint;
  96. function wioSizeOfWaveFormat(pwfx: PWaveFormatEx): integer;
  97. function wioCopyWaveFormat(pwfx: PWaveFormatEx): PWaveFormatEx;
  98. procedure wioGetFormatName(pwfx: PWaveFormatEx; var FormatName: String);
  99. procedure wioGetFormat(pwfx: PWaveFormatEx; var Format: String);
  100. function wioIsWaveFile(FilePath: TFileName; dwFlags: Longint): Boolean;
  101. function wioGetFullPathName(lpFilePath: PChar): Boolean;
  102. function wioFileExists(lpFilePath: PChar): Boolean;
  103. function wioFileDelete(lpFilePath: PChar): Boolean;
  104. procedure wioExtractPath(lpFilePath: PChar);
  105. function wioFileCreateTemp(lpFilePath: PChar): Boolean;
  106. function wioFileOpen(Var hmmio: THMMIO; Var ckRIFF: TMMCKINFO;
  107. Var HMem: THandle; lpFilePath: PChar;
  108. fccType: FourCC; dwFlags: Longint): integer;
  109. procedure wioFileClose(Var hmmio: THMMIO; Var hMem: THandle);
  110. function wioCreateFileInfo(Var lpwio: PWAVEIOCB; pwfx: PWaveFormatEx): integer;
  111. function wioCopyFileInfo(lpwioDst, lpwioSrc: PWAVEIOCB): integer;
  112. function wioReadFileInfo(Var lpwio: PWAVEIOCB; lpFilePath: PChar;
  113. fccType: FourCC; dwFlags: Longint): integer;
  114. function wioWriteFileInfo(Var lpwio: PWAVEIOCB; lpFilePath: PChar): integer;
  115. function wioFreeFileInfo(Var lpwio: PWAVEIOCB): integer;
  116. function wioWaveCopyUselessChunks(lpwioSrc, lpwioDst: PWaveIOCB): integer;
  117. function wioSetIOBufferSize(lpwio: PWaveIOCB; dwSize: Longint): integer;
  118. function wioWaveOpen(lpwio: PWaveIOCB): integer;
  119. function wioWaveClose(lpwio: PWaveIOCB): integer;
  120. function wioWaveLoadFile(lpFilePath: PChar; Var pwfx: PWaveFormatEx;
  121. Var Buffer: PChar; Var Size: Longint): integer;
  122. function wioWaveSaveFile(lpFilePath: PChar; pwfx: PWaveFormatEx;
  123. Buffer: PChar; Size: Longint): integer;
  124. function wioWaveSetFirstSample(lpwio: PWaveIOCB; dwSample: Longint): integer;
  125. function wioWaveSetLastSample(lpwio: PWaveIOCB; dwSample: Longint): integer;
  126. function wioWaveSetPosition(lpwio: PWaveIOCB; dwSample: Longint): integer;
  127. function wioWaveReadData(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
  128. function wioWaveReadDataDirect(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
  129. function wioWaveReadSamples(lpwio: PWaveIOCB; Buffer: PChar; nSamples: Longint): Longint;
  130. function wioWaveWriteData(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
  131. function wioWaveWriteDataDirect(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
  132. function wioWaveWriteSamples(lpwio: PWaveIOCB; Buffer: PChar; nSamples: Longint): Longint;
  133. implementation