| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- {========================================================================}
- {= (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 MMDevice;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF WIN32}
- Windows,
- {$ELSE}
- WinTypes,
- WinProcs,
- {$ENDIF}
- Classes,
- SysUtils,
- MMSystem,
- MMObj,
- MMObsrv,
- MMUtils;
- type
- { D3: This lines rely on current Win32 API}
- TMMAudioDeviceType = (dtMidiIn,dtMidiOut,dtWaveIn,dtWaveOut,dtAux,dtMixer);
- {$IFDEF WIN32}
- TMMDeviceId = type UINT;
- TMMManufacturerId = WORD;
- TMMProductId = WORD;
- TMMVersion = Byte;
- {$ENDIF}
- const
- defAudioDeviceType = dtWaveOut;
- defDeviceId = 0;
- badDeviceId = -2;
- MapperId = -1;
- { D3: This lines rely on current Win32 API}
- type
- {-- TMMDeviceCaps ---------------------------------------------------}
- TMMDeviceCaps = class(TPersistent)
- public
- procedure Clear;
- published
- property ManufacturerId: TMMManufacturerId read FManufacturerId write FWDummy stored False;
- property ProductId : TMMProductId read FProductId write FWDummy stored False;
- property VerMajor : TMMVersion read FVerMajor write FVDummy stored False;
- property VerMinor : TMMVersion read FVerMinor write FVDummy stored False;
- property ProductName : string read FProductName write SetDummyStr stored False;
- end;
- {-- TMMCustomAudioDevice ------------------------------------------------}
- TMMCustomAudioDevice = class(TMMComponent)
- protected
- procedure Open; virtual;
- procedure Close; virtual;
- procedure UpdateDevice; virtual;
- procedure RetrieveDeviceCaps;
- procedure SetActive(Value: Boolean);
- function GetActive: Boolean;
- procedure Changed; virtual;
- procedure DoChange; dynamic;
- procedure Loaded; override;
- { If descendant needs to immediately update device id w/o reopening }
- procedure SetDeviceIdDirect(Value: TMMDeviceId);
- function GetMapper: Boolean;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure AddObserver(O: TMMObserver);
- procedure RemoveObserver(O: TMMObserver);
- function ValidDevice: Boolean;
- procedure GetDeviceList(List: TStrings; IncludeMapper: Boolean);
- function GetDeviceType: TMMAudioDeviceType;
- { badDeviceId if no mixer for device }
- property MixerId: TMMDeviceId read GetMixerId;
- protected
- property DeviceType: TMMAudioDeviceType read FDeviceType write SetDeviceType default defAudioDeviceType;
- published
- property DeviceCount : Integer read GetDeviceCount write FDummyInt stored False;
- property DeviceCaps : TMMDeviceCaps read FDeviceCaps write SetDeviceCaps stored False;
- property Mapper : Boolean read GetMapper write FDummyBool stored False;
- property Active : Boolean read GetActive write SetActive default False;
- property DeviceId : TMMDeviceId read FDeviceId write SetDeviceId default defDeviceId;
- property OnChange : TNotifyEvent read FOnChange write FOnChange;
- end;
- {-- TMMDeviceChange -------------------------------------------------}
- TMMDeviceChange = class(TObject)
- end;
- {-- TMMAudioDevice --------------------------------------------------}
- TMMAudioDevice = class(TMMCustomAudioDevice)
- published
- property DeviceType;
- end;
- {-- EMMMCIError ---------------------------------------------------------}
- EMMMCIError = class(Exception)
- private
- FResult : MMResult;
- public
- constructor CreateRes(Res: MMResult);
- property Result: MMResult read FResult;
- end;
- {-- EMMDeviceError ------------------------------------------------------}
- EMMDeviceError = class(Exception)
- end;
- function Check(MMRes: MMResult): MMResult;
- function CheckExcl(MMRes: MMResult; const Excl: array of MMResult): MMResult;
- function DeviceIdToIdent(Id: LongInt; var S: string): Boolean;
- function IdentToDeviceId(const S: string; var Id: LongInt): Boolean;
- {========================================================================}
- implementation
- {========================================================================}
|