怎么让linein静音? ( 积分: 50 )

  • 主题发起人 主题发起人 qdlover
  • 开始时间 开始时间
Q

qdlover

Unregistered / Unconfirmed
GUEST, unregistred user!
我看了
http://dev.csdn.net/develop/article/17/17257.shtm

可是没有linein静音的选项

mmsystem里面没有关于linein的定义

下面的值我都尝试过了,没有一个是控制Line in的

{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_FIRST}
MIXERLINE_COMPONENTTYPE_SRC_FIRST = $00001000;
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED}
MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_DIGITAL}
MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_LINE}
MIXERLINE_COMPONENTTYPE_SRC_LINE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE}
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER}
MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC}
MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE}
MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER}
MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT}
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY}
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_ANALOG}
MIXERLINE_COMPONENTTYPE_SRC_ANALOG = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_LAST}
MIXERLINE_COMPONENTTYPE_SRC_LAST = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10);
 
我看了
http://dev.csdn.net/develop/article/17/17257.shtm

可是没有linein静音的选项

mmsystem里面没有关于linein的定义

下面的值我都尝试过了,没有一个是控制Line in的

{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_FIRST}
MIXERLINE_COMPONENTTYPE_SRC_FIRST = $00001000;
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED}
MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_DIGITAL}
MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_LINE}
MIXERLINE_COMPONENTTYPE_SRC_LINE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE}
MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER}
MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC}
MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE}
MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER}
MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT}
MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY}
MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_ANALOG}
MIXERLINE_COMPONENTTYPE_SRC_ANALOG = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10);
{$EXTERNALSYM MIXERLINE_COMPONENTTYPE_SRC_LAST}
MIXERLINE_COMPONENTTYPE_SRC_LAST = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10);
 
用以下代码可以控制Line in了
可是针对不同的设备,编号不一样

有没有个通用的阿

unit Unit2;

//Written by David Jiang(江天送)

//july 25th. 1999

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls,

Forms, Dialogs,StdCtrls, ComCtrls, mmsystem, Buttons, ExtCtrls;

type Tvolume=record

left,right:word;

end;


type

TForm2 = class(TForm)
lines: TComboBox;
Controls: TComboBox;
Label1: TLabel;
lmute: TLabel;
lmeter: TLabel;
LVolume: TTrackBar;
Rvolume: TTrackBar;
CheckBox1: TCheckBox;
About: TSpeedButton;
BExit: TSpeedButton;
cmute: TCheckBox;
RProgressBar: TProgressBar;
Timer1: TTimer;
test: TCheckBox;

procedure FormCreate(Sender: TObject);

procedure getlinecontrol;

procedure LinesChange(Sender: TObject);

procedure ControlsChange(Sender: TObject);

procedure LVolumeChange(Sender: TObject);

procedure cmuteClick(Sender: TObject);

procedure RvolumeChange(Sender: TObject);

procedure AboutClick(Sender: TObject);

procedure BExitClick(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure FormClose(Sender: TObject;
var

Action: TCloseAction);
procedure testClick(Sender: TObject);



private

{ Private declarations }

procedure mmixer(var msg:Tmessage);

public

{ Public declarations }

end;


function getvolume(control:Pmixercontrol;var

volume:Tvolume):boolean;

function setvolume(control:Pmixercontrol;

volume:Tvolume):boolean;

function setmute(control:Pmixercontrol;

mute:integer):boolean;

function getmute(control:Pmixercontrol;var

mute:integer):boolean;

function getpeak(control:Pmixercontrol;var

peak:integer):boolean;

procedure Fillstruct(control:Pmixercontrol;var

Cdetails:Tmixercontroldetails);

var

Form2: TForm2;

fmixerhandle:hmixer;
//混音器的句柄

mcontrols:array of array of array of PMixerControl;

line:array of Tstringlist;

peaknum:integer;
//meter mcontrols的位置

implementation



{$R *.DFM}



procedure Tform2.mmixer(var msg:Tmessage);

var

volume:Tvolume;

mute:integer;

begin


if msg.Msg=MM_MIXM_CONTROL_CHANGE then


begin


if mcontrolS[lines.itemindex][controls.itemindex]

[0].dwcontrolID=msg.LParam then


if getvolume(mcontrolS[lines.itemindex]

[controls.itemindex][0],volume) then


begin


Rvolume.Position :=-volume.right;

Lvolume.Position :=-volume.left;

end;


if mcontrolS[lines.itemindex][controls.itemindex]

[1].dwcontrolid=msg.LParam then


if getmute(mcontrolS[lines.itemindex]

[controls.itemindex][1],mute) then


cmute.Checked:=mute=1;

end;


end;


procedure TForm2.FormCreate(Sender: TObject);

begin


getlinecontrol;

lines.ItemIndex :=0;

controls.Items:=line[lines.ItemIndex];

controls.ItemIndex :=0;

controls.OnChange (sender);

end;




procedure Tform2.getlinecontrol;

var

mixerID:integer;
//混音器的ID

FMixerCaps:TMixerCaps;

n,j,k,i:integer;

ml,ml2:TMIXERLINE;

MLC:TMixerLineControls;

P:PMixerControl;

begin


if mixerGetNumDevs=0 then
exit;
//如没有混合器装置,退出

fmixerhandle:=0;

mixerID:=0;

mixerOpen (@FMixerHandle,mixerID,AllocateHWnd(mmixer),

0,CALLBACK_WINDOW OR MIXER_OBJECTF_MIXER);

//打开混音器

mixerGetDevCaps (mixerID,@FMixerCaps,SizeOf (TMixerCaps));

//返回混音器的兼容性

setlength(line,fmixercaps.cDestinations);

setlength(mcontrols,fmixercaps.cDestinations );

for i:=0 to fmixercaps.cDestinations-1do


begin


ml.dwDestination:=i;

ml.cbStruct :=sizeof(tMIXERLINE);

mixerGetLineInfo(fmixerhandle,@ml,

MIXER_GETLINEINFOF_DESTINATION);

//取得混音器的Destinations

line:=tstringlist.Create ;

setlength(mcontrols,ml.cconnections);

n:=0;

if ml.cControls>1 then


begin


n:=1;

setlength(mcontrols,ml.cconnections+1);

MLC.cbStruct:=SizeOf(MLC);

MLC.dwLineID:=ml.dwLineID;

MLC.cControls:=ml.cControls;

MLC.cbmxctrl:=SizeOf(TMixerControl);

GetMem (P,SizeOf(TMixerControl)*ml.cControls);

MLC.pamxctrl:=P;

MixerGetLineControls(fMixerHandle,@MLC,

MIXER_GETLINECONTROLSF_ALL);

setlength(mcontrols[0],ml.cControls);

line.Add(p^.szname);
//Master Volume

For k:=0 to ml.cControls-1do


begin


mcontrols[0][k]:=p;

mcontrols[0][0].Metrics.dwReserved[k+1]:=1;

inc(p);

end;


end;


lines.Items.Add(ml.szName);

ML2.cbStruct:=SizeOf(TMixerLine);

ML2.dwDestination:=ml.dwDestination ;

for j:=0 to ml.cConnections -1do


begin


ML2.dwSource:=j;

MixerGetLineInfo (fmixerHandle,@ML2,

MIXER_GETLINEINFOF_SOURCE);

MLC.cbStruct:=SizeOf(MLC);

MLC.dwLineID:=ml2.dwLineID;

MLC.cControls:=ml2.cControls;

MLC.cbmxctrl:=SizeOf(TMixerControl);

GetMem (P,SizeOf(TMixerControl)*ml2.cControls);

MLC.pamxctrl:=P;

MixerGetLineControls(fMixerHandle,@MLC,

MIXER_GETLINECONTROLSF_ALL);

setlength(mcontrols[j+n],ml2.cControls);

For k:=0 to ml2.cControls-1do


begin


if p.dwControlType=MIXERCONTROL_CONTROLTYPE_VOLUME

then
line.add(p^.szName);

mcontrols[j+n][k]:=p;

mcontrols[j+n][0].Metrics.dwReserved[k+1]:=1;

inc(p);

end;
//取得混音器线路的控制器

end;


end;


end;




procedure Fillstruct(control:Pmixercontrol;var

Cdetails:Tmixercontroldetails);

begin


cdetails.cbStruct:=sizeof(cdetails);

cdetails.dwControlID:=control.dwControlID ;

cdetails.cbDetails:=sizeof(integer);

cdetails.hwndOwner :=0;

end;


function getpeak(control:Pmixercontrol;var

peak:integer):boolean;

var

details:TMIXERCONTROLDETAILSSIGNED;

cdetails:TMIXERCONTROLDETAILS;

begin


result:=false;

if control.dwControlType <>

MIXERCONTROL_CONTROLTYPE_PEAKMETER then
exit;

cdetails.cChannels :=1;

cdetails.paDetails:=@details;

fillstruct(control,cdetails);

result:=MIXERGETCONTROLDETAILS(fmixerhandle,

@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;

peak:=abs(details.LValue) div 180;

end;




function setvolume(control:Pmixercontrol;

volume:Tvolume):boolean;

var

details:array [0..30] of Integer;

cdetails:TMIXERCONTROLDETAILS;

begin


fillstruct(control,cdetails);

cdetails.cChannels :=2;

cdetails.paDetails:=@details;

details[0]:=volume.left;

details[1]:=volume.right;

result:=MIXERSETCONTROLDETAILS(fmixerhandle,

@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;

end;




function getvolume(control:Pmixercontrol;var

volume:Tvolume):boolean;

var

details:array [0..30] of Integer;

cdetails:TMIXERCONTROLDETAILS;

begin


fillstruct(control,cdetails);

cdetails.cChannels :=2;

cdetails.paDetails:=@details;

result:=MIXERGETCONTROLDETAILS(fmixerhandle,

@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;

volume.left:=details[0];

volume.right:=details[1];

end;


function setmute(control:Pmixercontrol;

mute:integer):boolean;

var

cdetails:Tmixercontroldetails;

details:array [0..30] of Integer;

begin


fillstruct(control,cdetails);

cdetails.cChannels :=1;

cdetails.paDetails:=@details;

details[0]:=mute;

result:=MIXERSETCONTROLDETAILS(fmixerhandle,

@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;

end;


function getmute(control:Pmixercontrol;var

mute:integer):boolean;

var

cdetails:Tmixercontroldetails;

details:array [0..30] of Integer;

begin


fillstruct(control,cdetails);

cdetails.cChannels :=1;

cdetails.cMultipleItems:=0;

cdetails.paDetails:=@details;

result:=MIXERGETCONTROLDETAILS(fmixerhandle,

@cdetails,MIXER_GETCONTROLDETAILSF_VALUE)=0;

mute:=details[0];

end;




procedure TForm2.LinesChange(Sender: TObject);

begin


controls.Items:=line[lines.ItemIndex];

if controls.ItemIndex =-1 then


controls.ItemIndex :=0;

end;




procedure TForm2.ControlsChange(Sender: TObject);

var

mute,k,j:integer;

volume:Tvolume;

begin


lmute.Visible :=false;

lmeter.Visible :=false;

k:=lines.ItemIndex;j:=controls.ItemIndex;

IF mcontrols[k][j][0].Metrics.dwReserved[2]=1 then


begin


lmute.Visible:=mcontrols[k][j][1].dwcontroltype

=MIXERCONTROL_CONTROLTYPE_MUTE;

lmeter.Visible:=mcontrols[k][j][1].dwcontroltype

=MIXERCONTROL_CONTROLTYPE_PEAKMETER;

if lmeter.Visible then
peaknum:=1;

end;


cmute.Enabled :=lmute.Visible ;

IF mcontrols[k][j][0].Metrics.dwReserved[3]=1 then


begin


lmeter.Visible:=mcontrols[k][j][2].dwcontroltype

=MIXERCONTROL_CONTROLTYPE_PEAKMETER;

if lmeter.Visible then
peaknum:=2;

end;


if getvolume(mcontrols[k][j][0],volume) then


begin


Rvolume.Position :=-volume.right;

Lvolume.Position :=-volume.left;

end;


if getmute(mcontrols[k][j][1],mute) then


cmute.Checked :=mute=1;

RProgressbar.Visible :=lmeter.Visible;;

timer1.Enabled:=lmeter.Visible;

end;




procedure TForm2.LVolumeChange(Sender: TObject);

var volume:tvolume;

begin


if checkbox1.Checked then
Rvolume.Position :=Lvolume.Position ;

volume.right :=-Rvolume.Position;

volume.left:=-Lvolume.Position ;

setvolume(mcontrolS[lines.itemindex][controls.itemindex][0],

volume);

end;




procedure TForm2.cmuteClick(Sender: TObject);

var mute:integer;

begin


if cmute.checked then
mute:=1 else
mute:=0;

setmute(mcontrolS[lines.itemindex][controls.itemindex][1],mute);

end;




procedure TForm2.RvolumeChange(Sender: TObject);

begin


if checkbox1.Checked then
Lvolume.Position :=Rvolume.Position ;

Lvolume.OnChange (sender);

end;




procedure TForm2.AboutClick(Sender: TObject);

begin


showmessage('Mixer Demo version 1.0 '+chr(13)

+'Written by David Jiang');

end;




procedure TForm2.BExitClick(Sender: TObject);

begin


close;

end;




procedure TForm2.Timer1Timer(Sender: TObject);

var peak:integer;

begin


IF mcontrols[lines.itemindex][controls.itemindex]

[0].Metrics.dwReserved[peaknum+1]=1 then


if getpeak(mcontrols[lines.itemindex][controls.itemindex]

[peaknum],peak) then


Rprogressbar.Position :=peak;

end;




procedure TForm2.FormClose(Sender: TObject;
var Action: TCloseAction);

begin


mixerclose(fmixerhandle);

end;


procedure TForm2.testClick(Sender: TObject);
var mute:integer;
begin

if test.checked then
mute:=1 else
mute:=0;

setmute(mcontrolS[0][7][1],mute);
end;


end.
 
上面的代码还有一个问题,就是有些声卡是准确的,

有些声卡不行,有的项目对不上号,比如说,我选择pc speak,改变的却是Line in
 
http://www.delphibbs.com/delphibbs/dispq.asp?LID=2522584
标题是: 如何得到microphone當前是否打開,及當前的音量? (50分)

这个有用吗
 
大概可以,因为没那么多不同的机器跟我测试了。不过程序已经给客户了,我也不用改了
 
为了方便后人查阅

找出来audiomixer的网站
http://www.fi.muni.cz/~xkovalc/index.php?lang=en&amp;section=delphi

奇怪的是,为什么我打他的example工程,运行,编译功能都不能用,也不能看窗体,我用delphi6
 
后退
顶部