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;
begin
waveoutgetvolume(WAVE_MAPPER, @temp);//returns the current volume
Rvol := hiword (temp);
asm
shl Rvol, 16
end;
Rvol := Rvol and $ffff0000;
waveoutsetvolume(WAVE_MAPPER, value or Rvol);
end;


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


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: