Regulowanie głośności za pomoca TrackBara

0

Ustawiłem TrackBara, podpiąłem pod niego następujący kod:

 procedure TForm1.TrackBar1Change(Sender: TObject);
begin
case TrackBar1.Position of
0: WaveOutSetVolume( 0, $00000000);
1: WaveOutSetVolume( 0, $10001000);
2: WaveOutSetVolume( 0, $20002000);
3: WaveOutSetVolume( 0, $30003000);
4: WaveOutSetVolume( 0, $40004000);
5: WaveOutSetVolume( 0, $50005000);
6: WaveOutSetVolume( 0, $60006000);
7: WaveOutSetVolume( 0, $70007000);
8: WaveOutSetVolume( 0, $80008000);
9: WaveOutSetVolume( 0, $90009000);
10: WaveOutSetVolume( 0, $FFFFFFFF);
end;

Dodałem bibliotekę do uses i nadal nie mogę regulować dźwięku. Nie odsyłajcie mnie do google, bo już tam szukałem, zazwyczaj zresztą odsyła mnie z powrotem na to forum do tematu w którym podobny problem nie został rozwiązany.

0

Kod który podałeś powinien działać. Zmień na kod podany poniżej i zobacz jaki błąd pokazuje.

const
  VOLUME: array [0..10] of Cardinal = ($00000000, $10001000, $20002000, $30003000,
    $40004000, $50005000, $60006000, $70007000, $80008000, $90009000, $FFFFFFFF);
var
  LastError: Cardinal;
  Msg: string;
begin
  LastError:= WaveOutSetVolume(0, VOLUME[TrackBar1.Position]);
  if LastError = MMSYSERR_NOERROR then exit;
  case LastError of
    MMSYSERR_INVALHANDLE : Msg:= 'MMSYSERR_INVALHANDLE Specified device handle is invalid.';
    MMSYSERR_NODRIVER    : Msg:= 'MMSYSERR_NODRIVER No device driver is present.';
    MMSYSERR_NOMEM       : Msg:= 'MMSYSERR_NOMEM Unable to allocate or lock memory.';
    MMSYSERR_NOTSUPPORTED: Msg:= 'MMSYSERR_NOTSUPPORTED Function is not supported.';
  else
    Msg:= SysErrorMessage(LastError);
  end;
  ShowMessage(Msg);
end;

Nie masz przypadkiem zainstalowanych 2 kart dźwiękowych (np. zintegrowanej i "normalnej") ? Może regulujesz głośność nie tego urządzenia?

0

Po uruchomieniu pokazał się taki komunikat:

MMSYSERR_NOTSUPPORTED Function is not supported.

0
http://msdn.microsoft.com/en-us/library/aa908146.aspx napisał(a)

Not all devices support volume changes. To determine whether the device supports volume control, use the WAVECAPS_VOLUME flag to test the dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function). To determine whether the device supports volume control on both the left and right channels, use the WAVECAPS_LRVOLUME flag.

pobierz za pomocą http://msdn.microsoft.com/en-us/library/aa910397.aspx ilość urządzeń wyjściowych i spróbuj na innych

1 użytkowników online, w tym zalogowanych: 0, gości: 1