用windows的mixer,delphi的有一个第三方的vcl叫TAudioMixer
以下是Demo代码
//获取录音设备的ID
function TfrmVolume.InitInDeviceID: Boolean;
var
iLoop : Integer;
begin
Result := False;
FInDeviceID := -1;
FInChannelID:= -1;
//查找录音设备的Mixer
for iLoop := 0 to AudioMixer1.Destinations.Count-1do
begin
if AudioMixer1.Destinations[iLoop].Data.dwComponentType =
MIXERLINE_COMPONENTTYPE_DST_WAVEIN then
begin
FInDeviceID := iLoop;
Break;
end;
end;
//AudioMixer1.Destinations[FInDeviceID].Connections就是录音设备的各个音源
Result := True;
end;
//设置录音设备采用哪个音源,ConnectionID为//AudioMixer1.Destinations[FInDeviceID].Connections中的一个Connection的Index
procedure TfrmVolume.SelectInChannel(const ConnectionID: Integer);
var
L,R,M:Integer;
VD,MD:Boolean;
Stereo:Boolean;
IsSelect:Boolean;
begin
AudioMixer1.GetVolume(FInDeviceID, ConnectionID, L, R, M, Stereo, VD, MD, IsSelect);
AudioMixer1.SetVolume(FInDeviceID, ConnectionID, L, R, 1);
end;