Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Lightbulb Desactivar microfono de la PC

Hola amigos. Me sucede lo siguiente. Necesito hacer un programa que cuando yo quiera mediante un boton desactive el microfono de la PC, es desir lo apague para que no tenga entrada. O si tiene entrada que la PC lo ignore. Alguien sabe como hacer esto??

Gracias de antemano para todos !!!
Responder Con Cita
  #2  
Antiguo 18-01-2010
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 26
delphi.com.ar Va por buen camino
Debes hacerlo mediante el mixer de windows, te paso una unit que alguna vez escribí y como utilizarla:

Código Delphi [-]
{********************************************************}
{                                                        }
{    Multimedia Utils                                    }
{                                                        }
{    Autor: Federico Firenze                             }
{    enero de 2003                                       }
{                                                        }
{********************************************************}

unit MMUtils;

interface

uses
  Windows;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);

implementation

uses
  SysUtils, MMSystem;

procedure RaiseLastMMError;
begin
  { TODO : .. }
  RaiseLastOsError;
end;

procedure mmMixSetDetail(AComponentType, AControlType: DWORD; Data: Pointer; DataSize: DWORD);
var
  hMix: HMIXER;
  mxlc: MIXERLINECONTROLS;
  mxcd: TMIXERCONTROLDETAILS;
  mxc: MIXERCONTROL;
  mxl: TMixerLine;
begin
  if (mixerGetNumDevs() > 0) then
  begin
    if mixerOpen(@hMix, 0, 0, 0, 0) = MMSYSERR_NOERROR then
      try
        mxl.dwComponentType := AComponentType;
        mxl.cbStruct := SizeOf(mxl);

        if mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE) = MMSYSERR_NOERROR then
        begin
          ZeroMemory(@mxlc, SizeOf(mxlc));

          mxlc.cbStruct := SizeOf(mxlc);
          mxlc.dwLineID := mxl.dwLineID;
          mxlc.dwControlType := AControlType;
          mxlc.cControls := 1;
          mxlc.cbmxctrl := SizeOf(mxc);
          mxlc.pamxctrl := @mxc;

          if mixerGetLineControls(hMix, @mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE) = MMSYSERR_NOERROR then
          begin
            ZeroMemory(@mxcd, SizeOf(mxcd));
            mxcd.dwControlID := mxc.dwControlID;
            mxcd.cbStruct := SizeOf(mxcd);
            mxcd.cMultipleItems := 0;
            mxcd.cbDetails := DataSize;
            mxcd.paDetails := Data;
            mxcd.cChannels := 1;

            if mixerSetControlDetails(hMix, @mxcd, MIXER_SETCONTROLDETAILSF_VALUE) <> MMSYSERR_NOERROR then
              RaiseLastMMError;
          end else
            RaiseLastMMError;
        end else
          RaiseLastMMError;
      finally
        if mixerClose(hMix) <> MMSYSERR_NOERROR then
         RaiseLastMMError;
      end;
  end;
end;

procedure mmMixSetVolume(AComponentType, AValue: DWORD);
var
  uValue: TMIXERCONTROLDETAILS_UNSIGNED;
begin
  uValue.dwValue := AValue;
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_VOLUME, @uValue, SizeOf(uValue));
end;


procedure mmMixSetMute(AComponentType: DWORD; AValue: boolean);
var
  bValue: MIXERCONTROLDETAILS_BOOLEAN;
begin
  bValue.fValue := Ord(AValue);
  mmMixSetDetail(AComponentType, MIXERCONTROL_CONTROLTYPE_MUTE, @bValue, SizeOf(bValue));
end;

end.

Aquí utiliza la función mmMixSetMute para poner el micrófono en estado mute, para salir de este estado el segundo parámetro debería ser False.
Código Delphi [-]
uses MMUtils, MMSystem;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  mmMixSetMute(MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, True);
end;

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
  #3  
Antiguo 18-01-2010
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Se puede hacer utilizando la API waveOutSetVolume (msdn).

Pásate por aquí y prueba este ejemplo (que la utiliza) a ver si te funciona.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #4  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Ufff. Verda que ustedes si que son los mejores ejejeje !
Tks y espero poder ayudarlos algun dia xD.
Responder Con Cita
  #5  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Ese del microfono me dice.
Error call to undefined os function.

Que puede ser eso ??
Responder Con Cita
  #6  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Es decir: Le mensaje de error dice.

A Call to an OS function failed cuando pongo esto.

Código Delphi [-]
mmMixSetMute(MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, True);
Responder Con Cita
  #7  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Bueno Neftali, el link que me das esos codigos me trabajan de (http://www.swissdelphicenter.ch/en/showcode.php?id=225) maravillas lo unico que no se como poner el microfono en esta linea.

Código Delphi [-]
if GetVolumeControl(MyMixerHandle, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS,
        MIXERCONTROL_CONTROLTYPE_VOLUME, MyVolCtrl) then

He probado con

MIXERLINE_COMPONENTTYPE_DST_WAVEIN
y con
MIXERLINE_COMPONENTTYPE_DST_VOICEIN

Pero ninguno de los 2 me baja el volumen, pero bueno tengo que tener un microfono, cuando confirme les digo.

Gracias de todas formas !!!

Última edición por Neftali [Germán.Estévez] fecha: 19-01-2010 a las 09:36:43.
Responder Con Cita
  #8  
Antiguo 18-01-2010
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Poder: 26
delphi.com.ar Va por buen camino
Cita:
Empezado por fide_uci Ver Mensaje
Es decir: Le mensaje de error dice.

A Call to an OS function failed cuando pongo esto.

Código Delphi [-]
mmMixSetMute(MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, True);
Fíjate en que línea de la función mmMixSetDetail es que falla, para tener mas información.

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita
  #9  
Antiguo 18-01-2010
Avatar de fide_uci
fide_uci fide_uci is offline
Miembro
 
Registrado: ene 2009
Ubicación: Cuba - La Habana
Posts: 226
Poder: 16
fide_uci Va por buen camino
Donde da el error.

El error lo muestra en esta linea.

(Linea 49 de la Unit MMUtils)

if mixerGetLineInfo(hMix, @mxl, MIXER_GETLINEINFOF_COMPONENTTYPE) = MMSYSERR_NOERROR then

y de ahi salta para esta linea (de MMUtils)

RaiseLastMMError; (Linea 70)
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Grabar sonido desde un microfono gaston260 API de Windows 4 16-07-2008 04:00:31
Obtener audio desde un microfono en delphi fide API de Windows 3 13-04-2008 20:33:07
sonido y microfono en delphi cmm07 Varios 0 07-04-2008 14:59:18
microfono de alta sensibilidad b3nshi Varios 0 16-04-2005 20:26:51
Cambiar el volumen de grabación del micrófono syntetiko API de Windows 0 25-01-2005 19:11:58


La franja horaria es GMT +2. Ahora son las 10:17:01.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi