| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Tel.: +0351-8012255 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 20.01.1998 - 18:00:00 $ =}
- {========================================================================}
- unit MMWaveIO;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF WIN32}
- Windows,
- {$ELSE}
- WinTypes,
- WinProcs,
- {$ENDIF}
- SysUtils,
- MMSystem,
- MMRegs,
- MMRiff,
- MMUtils,
- MMAbout;
- const
- { file open flags for waveio functions }
- RIFF_FILE = $0001;
- RIFF_RESOURCE = $0002;
- RIFF_MEMORY = $0004;
- { get the extra Info only }
- RIFF_INFO_ONLY = $0008;
- type
- PWAVEIOCB = ^TWAVEIOCB;
- TWAVEIOCB = record { do not change the first items !!!! }
- dwSize : Longint; { size for the structure }
- dwFlags : Longint; { flags used to open the file }
- hmmio : THMMIO; { handle to open file }
- ckRIFF,ckDATA : TMMCKINFO; { the current RIFF and data chunk }
- hMem : THandle; { <> 0 if we have a res. file, free it !}
- dwFileSize : Longint; { the filesize for the actual file }
- dwDataBytes : Longint; { the data size for the actual file }
- dwDataOffset : Longint; { offset from data chunk }
- dwDataSamples : Longint; { how much samples in the file }
- dwFirstSample : Longint; { the first sample to read }
- dwLastSample : Longint; { the last Sample to read }
- dwBytesLeft : Longint; { how many bytes to play }
- dwPosition : Longint; { the current file position }
- lpFilePath : PChar; { filename from the actual file }
- lpDisp : PDispList; { pointer to display chunk's }
- lpInfo : PInfoChunk; { pointer to info chunk }
- { this MUST be the last element in this structure--its length is }
- { not fixed; use ab[] to get at any extra bytes (note! the length }
- { of ab[] is in wfx.cbSize--this CAN be zero!) }
- wfx : TWaveFormatEx;
- ab : array[0..0] of Byte;
- end;
- const
- { error returns from waveio functions }
- WIOERR_BASE = 100;
- WIOERR_NOERROR = 0;
- WIOERR_ERROR = WIOERR_BASE+1;
- WIOERR_BADHANDLE = WIOERR_BASE+2;
- WIOERR_BADFLAGS = WIOERR_BASE+3;
- WIOERR_BADPARAM = WIOERR_BASE+4;
- WIOERR_BADSIZE = WIOERR_BASE+5;
- WIOERR_FILEERROR = WIOERR_BASE+6;
- WIOERR_NOMEM = WIOERR_BASE+7;
- WIOERR_BADFILE = WIOERR_BASE+8;
- WIOERR_NODEVICE = WIOERR_BASE+9;
- WIOERR_BADFORMAT = WIOERR_BASE+10;
- WIOERR_ALLOCATED = WIOERR_BASE+11;
- WIOERR_NOTSUPPORTED = WIOERR_BASE+12;
- function wioBytesPerSample(pwfx: PWaveFormatEx): integer;
- function wioBytesToSamples(pwfx: PWaveFormatEx; dwBytes: Longint): Longint;
- function wioBytesToTime(pwfx: PWaveFormatEx; dwBytes: Longint): Longint;
- function wioSamplesToBytes(pwfx: PWaveFormatEx; dwSamples: Longint): Longint;
- function wioSamplesToTime(pwfx: PWaveFormatEx; dwSamples: Longint): Longint;
- function wioTimeToSamples(pwfx: PWaveFormatEx; dwTime: Longint): Longint;
- function wioTimeToBytes(pwfx: PWaveFormatEx; dwTime: Longint): Longint;
- function wioSizeOfWaveFormat(pwfx: PWaveFormatEx): integer;
- function wioCopyWaveFormat(pwfx: PWaveFormatEx): PWaveFormatEx;
- procedure wioGetFormatName(pwfx: PWaveFormatEx; var FormatName: String);
- procedure wioGetFormat(pwfx: PWaveFormatEx; var Format: String);
- function wioIsWaveFile(FilePath: TFileName; dwFlags: Longint): Boolean;
- function wioGetFullPathName(lpFilePath: PChar): Boolean;
- function wioFileExists(lpFilePath: PChar): Boolean;
- function wioFileDelete(lpFilePath: PChar): Boolean;
- procedure wioExtractPath(lpFilePath: PChar);
- function wioFileCreateTemp(lpFilePath: PChar): Boolean;
- function wioFileOpen(Var hmmio: THMMIO; Var ckRIFF: TMMCKINFO;
- Var HMem: THandle; lpFilePath: PChar;
- fccType: FourCC; dwFlags: Longint): integer;
- procedure wioFileClose(Var hmmio: THMMIO; Var hMem: THandle);
- function wioCreateFileInfo(Var lpwio: PWAVEIOCB; pwfx: PWaveFormatEx): integer;
- function wioCopyFileInfo(lpwioDst, lpwioSrc: PWAVEIOCB): integer;
- function wioReadFileInfo(Var lpwio: PWAVEIOCB; lpFilePath: PChar;
- fccType: FourCC; dwFlags: Longint): integer;
- function wioWriteFileInfo(Var lpwio: PWAVEIOCB; lpFilePath: PChar): integer;
- function wioFreeFileInfo(Var lpwio: PWAVEIOCB): integer;
- function wioWaveCopyUselessChunks(lpwioSrc, lpwioDst: PWaveIOCB): integer;
- function wioSetIOBufferSize(lpwio: PWaveIOCB; dwSize: Longint): integer;
- function wioWaveOpen(lpwio: PWaveIOCB): integer;
- function wioWaveClose(lpwio: PWaveIOCB): integer;
- function wioWaveLoadFile(lpFilePath: PChar; Var pwfx: PWaveFormatEx;
- Var Buffer: PChar; Var Size: Longint): integer;
- function wioWaveSaveFile(lpFilePath: PChar; pwfx: PWaveFormatEx;
- Buffer: PChar; Size: Longint): integer;
- function wioWaveSetFirstSample(lpwio: PWaveIOCB; dwSample: Longint): integer;
- function wioWaveSetLastSample(lpwio: PWaveIOCB; dwSample: Longint): integer;
- function wioWaveSetPosition(lpwio: PWaveIOCB; dwSample: Longint): integer;
- function wioWaveReadData(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
- function wioWaveReadDataDirect(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
- function wioWaveReadSamples(lpwio: PWaveIOCB; Buffer: PChar; nSamples: Longint): Longint;
- function wioWaveWriteData(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
- function wioWaveWriteDataDirect(lpwio: PWaveIOCB; Buffer: PChar; nBytes: Longint): Longint;
- function wioWaveWriteSamples(lpwio: PWaveIOCB; Buffer: PChar; nSamples: Longint): Longint;
- implementation
|