Andrej77rv писал(а):
Мне нужно измерять значение громкости по выходным каналам "Line" на звуковой карте и получить данные в цифрах. Не то?
Add(MainForm,13083241,217,77)
{
Left=20
Top=105
}
Add(InlineCode,13268794,364,119)
{
WorkPoints=#12:doSetVolume7|
VarPoints=#11:VolumeLevel|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|63:uses Debug, Share, Windows, Kol, ActiveX, ActiveKOL, KOLComObj;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|9: public|55: procedure doSetVolume7(var _Data:TData; Index:word);|54: procedure VolumeLevel(var _Data:TData; Index:word);|7: end;|0:|5:const|77:CLASS_IMMDeviceEnumerator : TGUID = '{BCDE0395-E52F-467C-8E3D-C4579291692E}';|75:IID_IMMDeviceEnumerator : TGUID = '{A95664D2-9614-4F35-A746-DE8DB63617E6}';|65:IID_IMMDevice : TGUID = '{D666063F-1587-4E43-81F1-B948E807363F}';|75:IID_IMMDeviceCollection : TGUID = '{0BD7A1BE-7A1A-44DB-8397-CC5392387B5E}';|76:IID_IAudioEndpointVolume : TGUID = '{5CDF2C82-841E-4546-9722-0CF74078229A}';|78:IID_IAudioMeterInformation : TGUID = '{C02216F6-8C67-4B5B-9D00-D008E73E0064}';|84:IID_IAudioEndpointVolumeCallback : TGUID = '{657804FA-D6AD-4496-8A60-352752AF4F89}';|0:|32:DEVICE_STATE_ACTIVE = $00000001;|35:DEVICE_STATE_UNPLUGGED = $00000002;|36:DEVICE_STATE_NOTPRESENT = $00000004;|33:DEVICE_STATEMASK_ALL = $00000007;|1: |4:type|21:EDataFlow = TOleEnum;|1: |5:const|20:eRender = $00000000;|21:eCapture = $00000001;|17:eAll = $00000002;|33:EDataFlow_enum_count = $00000003;|1: |4:type|17:ERole = TOleEnum;|1: |5:const|21:eConsole = $00000000;|24:eMultimedia = $00000001;|28:eCommunications = $00000002;|29:ERole_enum_count = $00000003;|1: |4:type|50:IAudioEndpointVolumeCallback = interface(IUnknown)|42:['{657804FA-D6AD-4496-8A60-352752AF4F89}']|4:end;|1: |42:IAudioEndpointVolume = interface(IUnknown)|42:['{5CDF2C82-841E-4546-9722-0CF74078229A}']|100:function RegisterControlChangeNotify(AudioEndPtVol: IAudioEndpointVolumeCallback): Integer; stdcall;|102:function UnregisterControlChangeNotify(AudioEndPtVol: IAudioEndpointVolumeCallback): Integer; stdcall;|57:function GetChannelCount(out PInteger): Integer; stdcall;|92:function SetMasterVolumeLevel(fLevelDB: single; pguidEventContext: PGUID): Integer; stdcall;|98:function SetMasterVolumeLevelScalar(fLevelDB: single; pguidEventContext: PGUID): Integer; stdcall;|70:function GetMasterVolumeLevel(out fLevelDB: single): Integer; stdcall;|76:function GetMasterVolumeLevelScalar(out fLevelDB: single): Integer; stdcall;|112:function SetChannelVolumeLevel(nChannel: Integer; fLevelDB: double; pguidEventContext: PGUID): Integer; stdcall;|118:function SetChannelVolumeLevelScalar(nChannel: Integer; fLevelDB: double; pguidEventContext: PGUID): Integer; stdcall;|90:function GetChannelVolumeLevel(nChannel: Integer; out fLevelDB: double): Integer; stdcall;|94:function GetChannelVolumeLevelScalar(nChannel: Integer; out fLevel: double): Integer; stdcall;|77:function SetMute(bMute: Boolean; pguidEventContext: PGUID): Integer; stdcall;|55:function GetMute(out bMute: Boolean): Integer; stdcall;|88:function GetVolumeStepInfo(pnStep: Integer; out pnStepCount: Integer): Integer; stdcall;|66:function VolumeStepUp(pguidEventContext: PGUID): Integer; stdcall;|68:function VolumeStepDown(pguidEventContext: PGUID): Integer; stdcall;|76:function QueryHardwareSupport(out pdwHardwareSupportMask): Integer; stdcall;|132:function GetVolumeRange(out pflVolumeMindB: double; out pflVolumeMaxdB: double; out pflVolumeIncrementdB: double): Integer; stdcall;|4:end;|1: |44:IAudioMeterInformation = interface(IUnknown)|42:['{C02216F6-8C67-4B5B-9D00-D008E73E0064}']|4:end;|1: |36:IPropertyStore = interface(IUnknown)|4:end;|1: |31:IMMDevice = interface(IUnknown)|42:['{D666063F-1587-4E43-81F1-B948E807363F}']|37:function Activate(const refId: TGUID;|16:dwClsCtx: DWORD;|28:pActivationParams: PInteger;|61:out pEndpointVolume: IAudioEndpointVolume): Hresult; stdCall;|98:function OpenPropertyStore(stgmAccess: DWORD; out ppProperties: IPropertyStore): Hresult; stdcall;|55:function GetId(out ppstrId: PLPWSTR): Hresult; stdcall;|56:function GetState(out State: Integer): Hresult; stdcall;|4:end;|1: |1: |41:IMMDeviceCollection = interface(IUnknown)|42:['{0BD7A1BE-7A1A-44DB-8397-CC5392387B5E}']|4:end;|1: |43:IMMNotificationClient = interface(IUnknown)|42:['{7991EEC9-7E89-4D85-8390-6C703CEC60C0}']|4:end;|1: |41:IMMDeviceEnumerator = interface(IUnknown)|42:['{A95664D2-9614-4F35-A746-DE8DB63617E6}']|125:function EnumAudioEndpoints(dataFlow: EDataFlow; deviceState: SYSUINT; DevCollection: IMMDeviceCollection): Hresult; stdcall;|99:function GetDefaultAudioEndpoint(EDF: SYSUINT; ER: SYSUINT; out Dev :IMMDevice ): Hresult; stdcall;|75:function GetDevice(pwstrId: pointer; out Dev: IMMDevice): HResult; stdcall;|96:function RegisterEndpointNotificationCallback(pClient: IMMNotificationClient): Hresult; stdcall;|4:end;|3: |14:implementation|0:|32:procedure SetVolume7(L: double);|41:var endpointVolume: IAudioEndpointVolume;|38:deviceEnumerator: IMMDeviceEnumerator;|25:defaultDevice: IMMDevice;|5:begin|8: try|119: CoCreateInstance(CLASS_IMMDeviceEnumerator, nil, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, deviceEnumerator);|80: deviceEnumerator.GetDefaultAudioEndpoint(eRender, eConsole, defaultDevice);|97: defaultDevice.Activate(IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, nil, endpointVolume);|39: if endpointVolume = nil then Exit;|56: endpointVolume.SetMasterVolumeLevelScalar(L, nil); |16: except end;|4:end;|0:|36:procedure GetVolume7(var L: single);|41:var endpointVolume: IAudioEndpointVolume;|38:deviceEnumerator: IMMDeviceEnumerator;|25:defaultDevice: IMMDevice;|5:begin|8: try|119: CoCreateInstance(CLASS_IMMDeviceEnumerator, nil, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, deviceEnumerator);|80: deviceEnumerator.GetDefaultAudioEndpoint(eRender, eConsole, defaultDevice);|97: defaultDevice.Activate(IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, nil, endpointVolume);|39: if endpointVolume = nil then Exit;|51: endpointVolume.GetMasterVolumeLevelScalar(L); |16: except end;|4:end;|0:|35:procedure THiAsmClass.doSetVolume7;|12:var L: real;|5:begin|24: L := ToReal(_Data);|32: if L < 0.0 then l := 0 else|28: if L > 1.0 then L := 1;|19: SetVolume7(L);|4:end;|0:|34:procedure THiAsmClass.VolumeLevel;|13:var L:single;|5:begin|19: GetVolume7(L);|22: dtReal(_Data, L);|4:end;|0:|4:end.|
}
Add(ScrollBar,8386497,322,63)
{
Left=90
Top=130
Max=100
link(onPosition,14799700:doOperation,[(366,69)(366,97)(310,97)(310,125)])
}
Add(Math,14799700,322,119)
{
OpType=3
Op2=100
link(onResult,13268794:doSetVolume7,[])
link(Op1,8386497:Position,[])
}
Add(Math,3246739,364,196)
{
OpType=2
Op2=100
ResultType=0
link(onResult,1180828:doEvent1,[])
link(Op1,13268794:VolumeLevel,[])
}
Add(Timer,16382224,322,196)
{
Interval=100
link(onTimer,3246739:doOperation,[])
}
Add(Label,3217402,504,203)
{
Left=90
Top=45
Width=77
Height=36
Font=[MS Sans Serif,20,1,0,1]
}
Add(Hub,1180828,420,196)
{
link(onEvent1,8386497:doPosition,[(446,202)(446,136)(276,136)(276,69)])
link(onEvent2,3217402:doText,[])
}