whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

41 Visitors Online


 
...adjust the volume of audio in devices?
Autor: Joe C. Hecht
[ Print tip ]  

Tip Rating (10):  
     


{
  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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners