Внешний вид сайта:

Изменение громкости звука из кода Delphi

Ниже приведен пример, как программно управлять громкостью звука из кода Delphi:

Пример кода:

uses MMSystem;

type
   TVolumeRec = record
     case Integer of
       0: (LongVolume: Longint) ;
       1: (LeftVolume, RightVolume : Word) ;
     end;

const DeviceIndex=5
       {0: Wave
        1: MIDI
        2: CDAudio
        3: Line-In
        4: Microphone
        5: Master
        6: PC-loudspeaker}
     
procedure SetVolume(aVolume: Byte) ;
var
  Vol: TVolumeRec;
begin
   Vol.LeftVolume := aVolume shl 8;
   Vol.RightVolume:= Vol.LeftVolume;
   auxSetVolume(UINT(DeviceIndex), Vol.LongVolume) ;
end;

function GetVolume: Cardinal;
var
  Vol: TVolumeRec;
begin
   AuxGetVolume(UINT(DeviceIndex), @Vol.LongVolume) ;
   Result:=(Vol.LeftVolume + Vol.RightVolume) shr 9;
end;

Автор: Zarko Gajic

Комментарии

Нет комментариев. Ваш будет первым!