Thứ Tư, 23 tháng 1, 2008

Changing Left and Right channel volumes separately

Changing Left and Right channel volumes separately:

These two procedures illustrated bellow set the volumes
of right and left channels separately.

Using Waveoutsetvolume from MMsystem you can set the wave out volme.
to do this you have to set the value into a Dword variable:

The 2 low order bytes : volume for the left channel which can be something
between 0 upto 65535

The 2 high order bytes : volume for the right channel which can be sonething
between 0 upto 65535

using these procedures you can set the channels separately:

uses MMsystem

Procedure Left_volume (value : Dword);
var Rvol, temp : Dword;
waveoutgetvolume(WAVE_MAPPER, @temp);//returns the current volume
Rvol := hiword (temp);
shl Rvol, 16
Rvol := Rvol and $ffff0000;
waveoutsetvolume(WAVE_MAPPER, value or Rvol);

Procedure Right_volume (value : Dword);
var Lvol, temp : Dword;
waveoutgetvolume(WAVE_MAPPER, @temp);
Lvol := Loword (temp);
shl value, 16
value := value and $ffff0000;
waveoutsetvolume(WAVE_MAPPER, value or Lvol);

Note for directshow user :
to change the balance you should use "IBasicAudio"

var pBA : IBasicAudio;

pBA.put_Balance(10000); // from -10000 to 10000

Không có nhận xét nào: