Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  1 582

•  TDictionary Custom Sort  4 229

•  Fast Watermark Sources  3 900

•  3D Designer  6 023

•  Sik Screen Capture  4 169

•  Patch Maker  4 708

•  Айболит (remote control)  4 621

•  ListBox Drag & Drop  3 763

•  Доска для игры Реверси  89 939

•  Графические эффекты  4 954

•  Рисование по маске  3 973

•  Перетаскивание изображений  3 339

•  Canvas Drawing  3 643

•  Рисование Луны  3 436

•  Поворот изображения  2 939

•  Рисование стержней  2 605

•  Paint on Shape  1 997

•  Генератор кроссвордов  2 759

•  Головоломка Paletto  2 182

•  Теорема Монжа об окружностях  2 875

•  Пазл Numbrix  1 958

•  Заборы и коммивояжеры  2 534

•  Игра HIP  1 573

•  Игра Go (Го)  1 508

•  Симулятор лифта  1 786

•  Программа укладки плитки  1 531

•  Генератор лабиринта  1 895

•  Проверка числового ввода  1 648

•  HEX View  1 836

•  Физический маятник  1 665

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Как изменить уровень громкости микрофона



uses
  MMSystem;

// Setzt die Lautstarke fur das Mikrofon
// Set the volume for the microphone

function SetMicrophoneVolume(bValue: Word): Boolean;
var {0..65535}
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  vol: TMIXERCONTROLDETAILS_UNSIGNED;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
  intRet: Integer;
  nMixerDevs: Integer;
begin
  // Check if Mixer is available
  // Uberprufen, ob ein Mixer vorhanden
  nMixerDevs := mixerGetNumDevs();
  if (nMixerDevs < 1) then
  begin
    Exit;
  end;

  // open the mixer
  intRet := mixerOpen(@hMix, 0, 0, 0, 0);
  if intRet = MMSYSERR_NOERROR then
  begin
    mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
    mxl.cbStruct := SizeOf(mxl);

    // get line info
    intRet := mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);

    if intRet = MMSYSERR_NOERROR then
    begin
      ZeroMemory(@mxlc, SizeOf(mxlc));
      mxlc.cbStruct := SizeOf(mxlc);
      mxlc.dwLineID := mxl.dwLineID;
      mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_VOLUME;
      mxlc.cControls := 1;
      mxlc.cbmxctrl := SizeOf(mxc);

      mxlc.pamxctrl := @mxc;
      intRet := mixerGetLineControls(hMix, @mxlc,
        MIXER_GETLINECONTROLSF_ONEBYTYPE);

      if intRet = MMSYSERR_NOERROR then
      begin
        {
         // Microphone Name
            Label1.Caption := mxlc.pamxctrl.szName;

          // Min/Max Volume
          Label2.Caption := IntToStr(mxc.Bounds.dwMinimum) + '->' + IntToStr(mxc.Bounds.dwMaximum);
        }
        ZeroMemory(@mxcd, SizeOf(mxcd));
        mxcd.dwControlID := mxc.dwControlID;
        mxcd.cbStruct := SizeOf(mxcd);
        mxcd.cMultipleItems := 0;
        mxcd.cbDetails := SizeOf(Vol);
        mxcd.paDetails := @vol;
        mxcd.cChannels := 1;

        // vol.dwValue := mxlc.pamxctrl.Bounds.lMinimum; Set min. Volume / Minimum setzen
        // vol.dwValue := mxlc.pamxctrl.Bounds.lMaximum; Set max. Volume / Maximum setzen
        vol.dwValue := bValue;

        intRet := mixerSetControlDetails(hMix, @mxcd,
          MIXER_SETCONTROLDETAILSF_VALUE);
        if intRet <> MMSYSERR_NOERROR then
          ShowMessage('SetControlDetails Error');
      end
      else
        ShowMessage('GetLineInfo Error');
    end;
    intRet := mixerClose(hMix);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetMicrophoneVolume(30000);
end;

{********************************************************}

// Enable/disable "Mute Microphone Volume"
// Ton fur Mikrofon ein/ausschalten

function SetMicrophoneVolumeMute(bMute: Boolean): Boolean;
var
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  vol: TMIXERCONTROLDETAILS_UNSIGNED;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
  intRet: Integer;
  nMixerDevs: Integer;
  mcdMute: MIXERCONTROLDETAILS_BOOLEAN;
begin
  // Check if Mixer is available
  // Uberprufen, ob ein Mixer vorhanden ist
  nMixerDevs := mixerGetNumDevs();
  if (nMixerDevs < 1) then
  begin
    Exit;
  end;

  // open the mixer
  // Mixer offnen
  intRet := mixerOpen(@hMix, 0, 0, 0, 0);
  if intRet = MMSYSERR_NOERROR then
  begin
    mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
    mxl.cbStruct := SizeOf(mxl);

    // mixerline info
    intRet := mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);

    if intRet = MMSYSERR_NOERROR then
    begin
      ZeroMemory(@mxlc, SizeOf(mxlc));
      mxlc.cbStruct := SizeOf(mxlc);
      mxlc.dwLineID := mxl.dwLineID;
      mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
      mxlc.cControls := 1;
      mxlc.cbmxctrl := SizeOf(mxc);
      mxlc.pamxctrl := @mxc;

      // Get the mute control
      // Mute control ermitteln
      intRet := mixerGetLineControls(hMix, @mxlc,
        MIXER_GETLINECONTROLSF_ONEBYTYPE);

      if intRet = MMSYSERR_NOERROR then
      begin
        ZeroMemory(@mxcd, SizeOf(mxcd));
        mxcd.cbStruct := SizeOf(TMIXERCONTROLDETAILS);
        mxcd.dwControlID := mxc.dwControlID;
        mxcd.cChannels := 1;
        mxcd.cbDetails := SizeOf(MIXERCONTROLDETAILS_BOOLEAN);
        mxcd.paDetails := @mcdMute;

        mcdMute.fValue := Ord(bMute);

        // set, unset mute
        // Stumsschalten ein/aus
        intRet := mixerSetControlDetails(hMix, @mxcd,
          MIXER_SETCONTROLDETAILSF_VALUE);
        {
        mixerGetControlDetails(hMix, @mxcd,
                               MIXER_GETCONTROLDETAILSF_VALUE);
        Result := Boolean(mcdMute.fValue);
        }
        Result := intRet = MMSYSERR_NOERROR;

        if intRet <> MMSYSERR_NOERROR then
          ShowMessage('SetControlDetails Error');
      end
      else
        ShowMessage('GetLineInfo Error');
    end;

    intRet := mixerClose(hMix);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetMicrophoneVolumeMute(False);
end;

{********************************************************}

// Enable/disable "Mute" for several mixer line sources.

uses
  MMSystem;

type
  TMixerLineSourceType = (lsDigital, lsLine, lsMicrophone, lsCompactDisk,
    lsTelephone,
    lsWaveOut, lsAuxiliary, lsAnalog, lsLast);

function SetMixerLineSourceMute(AMixerLineSourceType: TMixerLineSourceType;
  bMute: Boolean): Boolean;
var
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  vol: TMIXERCONTROLDETAILS_UNSIGNED;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
  intRet: Integer;
  nMixerDevs: Integer;
  mcdMute: MIXERCONTROLDETAILS_BOOLEAN;
begin
  Result := False;
  // Check if Mixer is available
  // Uberprufen, ob ein Mixer vorhanden ist
  nMixerDevs := mixerGetNumDevs();
  if (nMixerDevs < 1) then
  begin
    Exit;
  end;

  // open the mixer
  // Mixer offnen
  intRet := mixerOpen(@hMix, 0, 0, 0, 0);
  if intRet = MMSYSERR_NOERROR then
  begin
    ZeroMemory(@mxl, SizeOf(mxl));
    case AMixerLineSourceType of
      lsDigital: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_DIGITAL;
      lsLine: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_LINE;
      lsMicrophone: mxl.dwComponentType :=
        MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE;
      lsCompactDisk: mxl.dwComponentType :=
        MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC;
      lsTelephone: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE;
      lsWaveOut: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
      lsAuxiliary: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY;
      lsAnalog: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_ANALOG;
      lsLast: mxl.dwComponentType := MIXERLINE_COMPONENTTYPE_SRC_LAST;
    end;

    // mixerline info
    mxl.cbStruct := SizeOf(mxl);
    intRet := mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);

    if intRet = MMSYSERR_NOERROR then
    begin
      ZeroMemory(@mxlc, SizeOf(mxlc));
      mxlc.cbStruct := SizeOf(mxlc);
      mxlc.dwLineID := mxl.dwLineID;
      mxlc.dwControlType := MIXERCONTROL_CONTROLTYPE_MUTE;
      mxlc.cControls := 1;
      mxlc.cbmxctrl := SizeOf(mxc);
      mxlc.pamxctrl := @mxc;

      // Get the mute control
      // Mute control ermitteln
      intRet := mixerGetLineControls(hMix, @mxlc,
        MIXER_GETLINECONTROLSF_ONEBYTYPE);

      if intRet = MMSYSERR_NOERROR then
      begin
        ZeroMemory(@mxcd, SizeOf(mxcd));
        mxcd.cbStruct := SizeOf(TMIXERCONTROLDETAILS);
        mxcd.dwControlID := mxc.dwControlID;
        mxcd.cChannels := 1;
        mxcd.cbDetails := SizeOf(MIXERCONTROLDETAILS_BOOLEAN);
        mxcd.paDetails := @mcdMute;

        mcdMute.fValue := Ord(bMute);

        // set, unset mute
        // Stumsschalten ein/aus
        intRet := mixerSetControlDetails(hMix, @mxcd,
          MIXER_SETCONTROLDETAILSF_VALUE);
        {
        mixerGetControlDetails(hMix, @mxcd, IXER_GETCONTROLDETAILSF_VALUE);
        Result := Boolean(mcdMute.fValue);
        }
        Result := intRet = MMSYSERR_NOERROR;

        if intRet <> MMSYSERR_NOERROR then
          ShowMessage('SetControlDetails Error');
      end
      else
        ShowMessage('GetLineInfo Error');
    end;
    intRet := mixerClose(hMix);
  end;
end;

// Example Call; Beispielaufruf:

procedure TForm1.Button1Click(Sender: TObject);
begin
  // Ton ausschalten
  SetMixerLineSourceMute(lsLine, True);
end;







Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте