...adjust the volume of audio in devices?
Author: Joe C. Hecht
{
The following example demonstrates getting and setting the volume
for the first CDAudio and LineIn device found. Note that both left and
right
channels are supported. The volume range is from 0 to 65535.
Example:
}
uses
MMSystem;
function GetLineInHandle(AudioType: Integer): Integer;
var
i: Integer;
AudioCaps: TAuxCaps;
begin
Result := 0;
for i := 0 to auxGetNumDevs - 1 do
begin
auxGetDevCaps(i, @AudioCaps, SizeOf(AudioCaps));
if AudioCaps.wTechnology = AudioType then
begin
Result := i;
Break;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
v: DWORD;
begin
AuxGetVolume(GetLineInHandle(AUXCAPS_CDAUDIO), @v);
Edit1.Text := IntToStr(LoWord(v));
Edit2.Text := IntToStr(HiWord(v));
end;
procedure TForm1.Button2Click(Sender: TObject);
var
v: DWORD;
begin
v := MakeLong(Word(StrToInt(Edit1.Text)),
Word(StrToInt(Edit2.Text)));
AuxSetVolume(GetLineInHandle(AUXCAPS_CDAUDIO), v);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
v: DWORD;
begin
AuxGetVolume(GetLineInHandle(AUXCAPS_AUXIN), @v);
Edit3.Text := IntToStr(LoWord(v));
Edit4.Text := IntToStr(HiWord(v));
end;
procedure TForm1.Button4Click(Sender: TObject);
var
v: DWORD;
begin
v := MakeLong(Word(StrToInt(Edit3.Text)),
Word(StrToInt(Edit4.Text)));
AuxSetVolume(GetLineInHandle(AUXCAPS_AUXIN), v);
end;
printed from
www.swissdelphicenter.ch
developers knowledge base