当前位置:主页>仓库管理软件> 列表

有请(LSUPER) 怎样控制音箱的左右声道 找用友财务软件官网

仓库管理软件版1楼: 用两个MediaPlayer控件需要根据情况在音箱的左右声道发出不同的声音。
两的音箱的距离一般会很远不会因为将它们放得太近而相互影响。

2楼: 欧以前用过的一个控制声音的类:

{ *********************************************************************** }
{ }
{ 声音控制类 }
{ }
{ 实现 wave、linein、cd 等设备的声音读取、设置 }
{ }
{ 设计:Lsuper 2003.06.15 }
{ }
{ Copyright (c) 1998-2003 Super Studio }
{ }
{ *********************************************************************** }



unit VolCtrl;

interface

uses
SysUtils, MMSystem;

type
{ 设备的类型 }
TDeviceType = (dvCD, dvLineIn, dvMidi, dvWave);
{ 声音 }
TVolumeType = record
case Integer of
0: (LongVolume: Longint);
1: (LeftVolume, RightVolume: Word);
end;
{ 声音控制类 }
TVolControl = class(TObject)
private
{ Private declarations }
FDevicetype: TDeviceType;
FDevice: Integer;

function GetVolume: Byte;
procedure SetVolume(Volume: Byte);
procedure SetDeviceType(Value: TDeviceType);
protected
{ Protected declarations }
procedure VolumeInit;
public
{ Public declarations }
constructor Create;
published
{ Published declarations }
property DeviceType: TDeviceType read FDeviceType write SetDeviceType;
property Volume: Byte read GetVolume write SetVolume stored False;
end;

implementation

////////////////////////////////////////////////////////////////////////////////

//设计: Lsuper 2003.06.15
//功能: 初始化
//参数:
////////////////////////////////////////////////////////////////////////////////
constructor TVolControl.Create;
begin
FDeviceType := dvCd;
VolumeInit;
end;

////////////////////////////////////////////////////////////////////////////////
//设计: Lsuper 2003.06.15
//功能: 设置设备类型
//参数:
////////////////////////////////////////////////////////////////////////////////
procedure TVolControl.SetDeviceType(Value: TDeviceType);
begin
if FDeviceType <> Value then
begin
FDeviceType := Value;
VolumeInit;
end;
end;

////////////////////////////////////////////////////////////////////////////////
//设计: Lsuper 2003.06.15
//功能: 设置声音
//参数:
////////////////////////////////////////////////////////////////////////////////
procedure TVolControl.SetVolume(Volume: Byte);
var
Vol: TVolumeType;
begin
Vol.LeftVolume := Volume shl 8;
Vol.RightVolume := Vol.LeftVolume;


case FDeviceType of
dvCD..dvLineIn:
auxSetVolume(FDevice, Vol.LongVolume);
dvMidi:
midiOutSetVolume(FDevice, Vol.LongVolume);
dvWave:
waveOutSetVolume(FDevice, Vol.LongVolume);
end;
end;

////////////////////////////////////////////////////////////////////////////////
//设计: Lsuper 2003.06.15
//功能: 读取声音
//参数:
////////////////////////////////////////////////////////////////////////////////
function TVolControl.GetVolume: Byte;
var
Vol: TVolumeType;
begin
Vol.LongVolume := 0;
case FDeviceType of
dvCD..dvLineIn:
auxGetVolume(FDevice, @Vol.LongVolume);
dvMidi:
midiOutGetVolume(FDevice, @Vol.LongVolume);
dvWave:
waveOutGetVolume(FDevice, @Vol.LongVolume);
end;
GetVolume := (Vol.LeftVolume + Vol.RightVolume) shr 9;
end;

////////////////////////////////////////////////////////////////////////////////
//设计: Lsuper 2003.06.15
//功能: 初始化所有声音控制
//参数:
////////////////////////////////////////////////////////////////////////////////
procedure TVolControl.VolumeInit;
var
AuxCaps: TAuxCaps;
WaveOutCaps: TWaveOutCaps;
MidiOutCaps: TMidiOutCaps;
I: Integer;
begin
FDevice := -1;
case FDeviceType of
dvCD: for I := 0 to auxGetNumDevs - 1 do
begin
auxGetDevCaps(I, @AuxCaps, SizeOf(AuxCaps));
if ((AuxCaps.dwSupport and AUXCAPS_VOLUME) <> 0) and
((AuxCaps.wTechnology and AUXCAPS_CDAUDIO <> 0)) then
begin
FDevice := I;
Break;
end;
end;
dvLineIn: for I := 0 to auxGetNumDevs - 1 do
begin
auxGetDevCaps(I, @AuxCaps, SizeOf(AuxCaps));
if ((AuxCaps.dwSupport and AUXCAPS_VOLUME) <> 0) and
((AuxCaps.wTechnology and AUXCAPS_AUXIN <> 0)) then
begin
FDevice := I;
Break;
end;
end;
dvWave: for I := 0 to waveOutGetNumDevs - 1 do


begin
waveOutGetDevCaps(I, @WaveOutCaps, SizeOf(WaveOutCaps));
if (WaveOutCaps.dwSupport and WAVECAPS_VOLUME) <> 0 then
begin
FDevice := I;
Break;
end;
end;
dvMidi: for I := 0 to midiOutGetNumDevs - 1 do
begin
MidiOutGetDevCaps(I, @MidiOutCaps, SizeOf(MidiOutCaps));
if (MidiOutCaps.dwSupport and MIDICAPS_VOLUME) <> 0 then
begin
FDevice := I;
Break;
end;
end;
end;
end;

end. 如用友财务软件官网

3楼: TO : LSUPER
能不能实现我所提出的问题,可不可以在用法上写的再具体些?

4楼: 这个问题好像总在提,还有就是静音,不过后者好像一直没结果。

5楼: 谁能解决我再加100分!

6楼: 1、TVolControl.SetVolume(Volume: Byte);这个过程,Volume参数的意义是什么?
2、是不是用TVolControl.VolumeInit过程得到硬件ID号,可以装上双声卡,进行每声卡放出不同声音。

仓库管理软件版7楼: Volume参数的意义是什么?
Byte型的,8位
..
TVolumeType = record
case Integer of
0: (LongVolume: Longint);
1: (LeftVolume, RightVolume: Word);
end;
..
Vol.LeftVolume := Volume shl 8;
Vol.RightVolume := Vol.LeftVolume;
2.TVolControl.VolumeInit 初始化声卡.
捧捧场,不对请指正

8楼: 多人接受答案了。