这要看你具体是用什么来做播放部分的啊,我用MMTOOLS做播放器,声道控制处理直接修改WAVE数据,代码如下:
procedure TForm1.MMDSPInterface1BufferFilled(Sender: TObject;
lpWaveHdr: PWaveHdr);
var
k, i, m : integer;
left, right, x : float;
buf:array[0..65535] of SmallInt ;
begin
CopyMemory(@buf,lpWaveHdr.lpData,lpWaveHdr.dwBufferLength);
m:= lpWaveHdr.dwBufferLength div 2;
if MMAudioFile1.Volume<8 then
for i:=0 to m-1do
begin
buf:=0;
end;
m:=m div 2;
if PMenushengdao.Items[0].Checked then
begin
//for i:=0 to m-1do
begin
BufL:=buf[i*2];
BufR:=buf[i*2+1];
end;
end else
begin
if PMenushengdao.Items[1].Checked then
begin
for i:=0 to m-1do
begin
buf[i*2]:=0;
end;
//左声道
end else
begin
if PMenushengdao.Items[2].Checked then
begin
//右声道
for i:=0 to m-1do
begin
buf[i*2+1]:=0;
end;
end else
begin
if PMenushengdao.Items[3].Checked then
begin
//左右混合
for i:=0 to m-1do
begin
buf[i*2]:=(buf[i*2]+buf[i*2+1]) div 2;
buf[i*2+1]:=buf[i*2];
end;
end else
begin
if PMenushengdao.Items[4].Checked then
begin
//50%混合
for i:=0 to m-1do
begin
left := buf[i*2] + buf[i*2+1] * 0.5;
right := buf[i*2+1] + buf[i*2] * 0.5;
if (left>32767) then
left:=32767
else
if left<-32767 then
left:=-32767;
if (right>32767) then
right:=32767
else
if right<-32767 then
right:=-32767;
buf[i*2]:=trunc(left);
buf[i*2+1] := trunc(right);
end;
end else
begin
if PMenushengdao.Items[5].Checked then
begin
//左右反相
for i:=0 to m-1do
begin
buf[i*2]:= -buf[i*2];
end;
end else
begin
if PMenushengdao.Items[6].Checked then
begin
//左右对换
for i:=0 to m-1do
begin
k:=buf[i*2+1];
buf[i*2+1]:=buf[i*2];
buf[i*2]:=k;
end;
end else
begin
if PMenushengdao.Items[7].Checked then
begin
//左-->左右
for i:=0 to m-1do
begin
buf[i*2]:=buf[i*2+1];
end;
end else
begin
//右-->左右
for i:=0 to m-1do
begin
buf[i*2+1]:=buf[i*2];
end;
end;
end;
end;
end;
end;
end;
end;
end;
CopyMemory(lpWaveHdr.lpData,@buf,lpWaveHdr.dwBufferLength);
if EQonoff.Tag = 1 then
MMEqualizers1.Process(lpWaveHdr.lpData,lpWaveHdr.dwBufferLength);
//if (MMSliderWaveVolume.Position <>8192) then
begin
CopyMemory(@buf,lpWaveHdr.lpData,lpWaveHdr.dwBufferLength);
x := MMSliderWaveVolume.Position / 8192;
for i:=0 to m-1do
begin
left := buf[i*2]*x;
right := buf[i*2+1]*x;
if (left>32767) then
left:=32767
else
if left<-32767 then
left:=-32767;
if (right>32767) then
right:=32767
else
if right<-32767 then
right:=-32767;
buf[i*2]:=trunc(left);
buf[i*2+1] := trunc(right);
end;
CopyMemory(lpWaveHdr.lpData,@buf,lpWaveHdr.dwBufferLength);
//end;
AutoPosTion:=False;
MMSlider33.Position := MMAudioFile1.Position;
AutoPosTion:=True;
end;