{========================================================================} {= (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 MMWave; {$I COMPILER.INC} interface uses {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF} SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, MMSystem, MMUtils, MMObj, MMString, MMNotify, MMDSPObj, MMRegs, MMRIFF, MMWaveIO, MMPCMSup, MMFade, MMEnvelp, MMPanel; type EMMWaveError = class(Exception); TMMPlayMode = (pmSync, pmAsync, pmLoop); TMMWaveProgress = procedure(Sender: TObject; CurByte, NumBytes: Longint; Var Cancel: Boolean) of Object; {-- TMMWave ------------------------------------------------------------} TMMWave = class(TMMObject) public ChangeList: TList; procedure Progress(CurByte, NumBytes: Longint; Var Cancel: Boolean); constructor Create; virtual; destructor Destroy; override; procedure Assign(Source: TPersistent); override; procedure FreeWave; function PlaySound(aValue: TMMPlayMode): Boolean; procedure StopSound; procedure LoadFromStream(Stream: TStream); virtual; procedure SaveToStream(Stream: TStream); virtual; procedure LoadFromFile(const FileName: TFileName); procedure SaveToFile(const Filename: TFileName); procedure ImportFromRaw(const FileName: TFileName; BitLength, Channels, SampleRate: Cardinal); procedure OpenFile; procedure CloseFile; procedure CreateFile(const FileName: TFileName; pwfx: PWaveFormatEx); procedure ConvertFile(const FileName: TFileName; pwfxDst: PWaveFormatEx); function GetInfoChunk(fcc: String): String; procedure SetInfoChunk(fcc, Text: String); function ReadDataBytes(Buffer: PChar; NumBytes: Longint): Longint; function ReadDataSamples(Buffer: PChar; NumSamples: Longint): Longint; function WriteDataBytes(Buffer: PChar; NumBytes: Longint): Longint; function WriteDataSamples(Buffer: PChar; NumSamples: Longint): Longint; property StartPos: Longint read GetStartPos write SetStartPos; property EndPos: Longint read GetEndPos write SetEndPos; property Position: Longint read GetPosition write SetPosition; property Empty: Boolean read GetEmpty; property PWaveFormat: PWaveFormatEx read GetPWaveFormat write SetPWaveFormat; property PWaveIOInfo: PWaveIOCB read FPWAVEIOCB write SetPWaveIOCB; property PWaveData: Pointer read GetPWaveData; property BytesLeft: Longint read GetBytesLeft; published property OnProgress: TMMWaveProgress read FOnProgress write FOnProgress; property TimeFormat: TMMTimeFormats read FTimeFormat write SetTimeFormat default tfSample; property FileMustExist: Boolean read FFileMustExist write SetFileMustExist default True; { must come before FileName ! } property FileName: TFileName read FFileName write SetFileName; property BitLength: Word read GetBits write SetBits stored False; property Mode: TMMMode read GetMode write SetMode stored False; property FormatTag: Word read GetFormatTag write SetFormatTag stored False; property FormatString: String read GetFormatString write SetFormatString stored False; property SampleRate: Longint read GetSampleRate write SetDummy stored False; property FileSize: LongInt read GetFileSize write SetDummy stored False; property DataSize: Longint read GetDataSize write SetDummy stored False; property IOBufferSize: Longint read FIOBufSize write SetIOBufSize default 32768; end; {-- TMMCustomWaveFile --------------------------------------------------} TMMCustomWaveFile = class(TMMDSPComponent) public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure LoadFromFile(const FileName: String); procedure SaveToFile(const FileName: String); function PlaySound(aValue: TMMPlayMode): Boolean; procedure StopSound; protected property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; property OnClose: TNotifyEvent read FOnClose write FOnClose; property OnChange: TNotifyEvent read FOnChange write FOnChange; property Enabled: Boolean read FEnabled write FEnabled default True; property Envelope: TMMEnvelope read FEnvelope write SetEnvelope; published property Wave: TMMWave read FWave write SetWave; end; {-- TMMWaveFile --------------------------------------------------------} TMMWaveFile = class(TMMCustomWaveFile) published property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; property OnClose: TNotifyEvent read FOnClose write FOnClose; property Input; property Output; property Enabled; property Envelope; end; {-- TMMCustomMemoryWave ------------------------------------------------} TMMCustomMemoryWave = class(TMMCustomWaveFile) public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; {-- TMMMemoryWave ------------------------------------------------------} TMMMemoryWave = class(TMMCustomMemoryWave) published property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; property OnClose: TNotifyEvent read FOnClose write FOnClose; property Output; property Enabled; end; { TODO: ableiten von TMMCustomMarkerPanel und verschiedene Eigenschaften veröffentlichen } {-- TMMCustomWaveEditor ------------------------------------------------} TMMCustomWaveEditor = class(TMMMarkerPanel) public property Wave: TMMWave read GetWave write SetWave; end; implementation