Registriert seit: 26. Jan 2011
339 Beiträge
Delphi 12 Athens
|
AW: Get/Set Master Volume Lautstärke?
14. Okt 2023, 20:21
gefunden...
Code:
uses MMSystem;
...
procedure GetWaveVolume(var volL, volR: DWord);
var
hWO: HWAVEOUT;
waveF: TWAVEFORMATEX;
vol: DWORD;
begin
volL:= 0;
volR:= 0;
// init TWAVEFORMATEX
FillChar(waveF, SizeOf(waveF), 0);
// open WaveMapper = std output of playsound
waveOutOpen(@hWO, WAVE_MAPPER, @waveF, 0, 0, 0);
// get volume
waveOutGetVolume(hWO, @vol);
volL:= vol and $FFFF;
volR:= vol shr 16;
waveOutClose(hWO);
end;
procedure SetWaveVolume(const volL, volR: DWord);
var
hWO: HWAVEOUT;
waveF: TWAVEFORMATEX;
vol: DWORD;
begin
// init TWAVEFORMATEX
FillChar(waveF, SizeOf(waveF), 0);
// open WaveMapper = std output of playsound
waveOutOpen(@hWO, WAVE_MAPPER, @waveF, 0, 0, 0);
vol:= volL + volR shl 16;
// set volume
waveOutSetVolume(hWO, vol);
waveOutClose(hWO);
end;
|
|
Zitat
|