was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

28 Visitors Online


 
...die Wave-Lautstärke regeln?
Autor: Thomas Stutz
[ Tip ausdrucken ]  

Tip Bewertung (40):  
     


uses
  
MMSystem;

function GetWaveVolume(var LVol: DWORD; var RVol: DWORD): Boolean;
var
  
WaveOutCaps: TWAVEOUTCAPS;
  Volume: DWORD;
begin
  
Result := False;
  if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, SizeOf(WaveOutCaps)) = MMSYSERR_NOERROR then
    if 
WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
    begin
      
Result := WaveOutGetVolume(WAVE_MAPPER, @Volume) = MMSYSERR_NOERROR;
      LVol   := LoWord(Volume);
      RVol   := HiWord(Volume);
    end;
end;


{
  The waveOutGetDevCaps function retrieves the capabilities of
  a given waveform-audio output device.

  The waveOutGetVolume function retrieves the current volume level
  of the specified waveform-audio output device.
}


function SetWaveVolume(const AVolume: DWORD): Boolean;
var
  
WaveOutCaps: TWAVEOUTCAPS;
begin
  
Result := False;
  if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, SizeOf(WaveOutCaps)) = MMSYSERR_NOERROR then
    if 
WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
      
Result := WaveOutSetVolume(WAVE_MAPPER, AVolume) = MMSYSERR_NOERROR;
end;

{
  AVolume:
  The low-order word contains the left-channel volume setting,
  and the high-order word contains the right-channel setting.
  A value of 65535 represents full volume, and a value of 0000 is silence.
  If a device does not support both left and right volume control,
  the low-order word of dwVolume specifies the volume level,
  and the high-order word is ignored.
}


{ *** How to Use: ***}

// SetWaveVolume:

procedure TForm1.Button1Click(Sender: TObject);
var
  
LVol: Word;
  RVol: Word;
begin
  
LVol := SpinEdit1.Value;  // max. is 65535
  
RVol := SpinEdit2.Value;  // max. is 65535
  
SetWaveVolume(MakeLong(LVol, RVol));
end;


// GetWaveVolume:

procedure TForm1.Button2Click(Sender: TObject);
var
  
LVol: DWORD;
  RVol: DWORD;
begin
  if 
GetWaveVolume(LVol, RVol) then
  begin
    
SpinEdit1.Value := LVol;
    SpinEdit2.Value := RVol;
  end;
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


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