编程实现,如何使左右声道同时只输出左(或右)声道的声音?(100分)

  • 主题发起人 主题发起人 zsdonald
  • 开始时间 开始时间
Z

zsdonald

Unregistered / Unconfirmed
GUEST, unregistred user!
如题
急,请提供代码,测试通过马上给分
 
要看你是用什么函数或开发包啊?如果你用MediaPlayer控件的话可以使用MciSendCommand函数,如果你使用DirectShow开发的话就会设计到Filter的问题,这个稍微复杂一点,两种我都可以实现,你要就给我发邮件,pc-bird@vip.sina.com
 
可不可以也给我发一份呀,zsdonald兄,我也给分,还不胜感激
 
我的email:tatayou@eyou.com
 
to lovinger_2000:
我用window mediaplayer9 的activex开发,有办法实现吗?
 
to:
dennierjay@yahoo.com.cn
 
5天过去了...
 
使用Audio控件(含源码,demo),很方便。
 
Audio控件(含源码,demo),哪里有下载?
 
ftp://61.129.70.192/control/audio.zip
 
2003/09/05 10:09:40 530 Sorry, no ANONYMOUS access allowed.
 
如果是指控制Windows系统左右声道的音量就好办了,如果确实要在程序中实现只输出某一声道就不知怎么办了!
 
unit jfMMSystem;

interface

uses
Windows, Messages, SysUtils,Dialogs, Variants, MMSystem,Classes;

const
MCI_SETAUDIO= $873;
MCI_SETVIDEO=$0876;
MCI_DGV_SETAUDIO_SOURCE_LEFT = 1;
MCI_DGV_SETAUDIO_SOURCE_STEREO = 0;
MCI_DGV_SETAUDIO_SOURCE_RIGHT = 2;
MCI_DGV_SETAUDIO_SOURCE = $00004004;
MCI_DGV_SETAUDIO_VALUE = $01000000;
MCI_DGV_SETAUDIO_ITEM = $00800000;
MCI_DGV_SETAUDIO_STREAM = $00004003;
MCI_DGV_SETAUDIO_VOLUME = $00004002;

type MCI_DGV_SETAUDIO_PARMS=record
dwCallback:DWORD;
dwItem:DWORD;
dwValue:DWORD;
dwOver:DWORD;
lpstrAlgorithm:PChar;
lpstrQuality:PChar;
end

function PlayVod(DeviceID:Word;FileName:string;SoundTrack:Byte):Byte;
implementation
//播放函数
function PlayVod(DeviceID:Word;FileName:string;SoundTrack:Byte):Byte;
var
s: MCI_DGV_SETAUDIO_PARMS
err:integer;
buf:array[0..1000] of char;
begin

Result:=1;
if (UpperCase(ExtractFileExt(FileName))='.DAT') or (UpperCase(ExtractFileExt(FileName))='.MP2') then
//转换VCD文件声道.
begin

//先关闭声音
err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or MCI_SET_OFF ,integer(@s));
if(err<>0)then

begin

mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;

case SoundTrack of
0: //全声道声道
begin

s.dwValue:=0;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;

1: //左声道
begin

s.dwValue:=1;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;

2://右声道
begin

s.dwValue:=2;
s.dwItem:=MCI_DGV_SETAUDIO_SOURCE;
end;

end;

err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or
MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM ,integer(@s));
if(err<>0)then

begin

mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;


err:=mciSendCommand(DeviceID,MCI_SETAUDIO,
MCI_WAIT or MCI_SET_ON ,integer(@s));
if(err<>0)then

begin

mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;

end
else

if (UpperCase(ExtractFileExt(FileName))='.VOB') or (UpperCase(ExtractFileExt(FileName))='.MPG') then
//转换DVD文件声道.
begin

err:=mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_WAIT or MCI_SET_On ,integer(@s));
if(err<>0)then

begin

mciGetErrorString(err,buf,sizeof(buf) );
ShowMessage(buf);
end;

case SoundTrack of
2: s.dwValue:=2;//左声道
1: s.dwValue:=1;
//右声道
end;

s.dwItem:=MCI_DGV_SETAUDIO_STREAM;
mciSendCommand(DeviceID,MCI_SETAUDIO,MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM,integer(@s));
end
else

Result:=0;
end;


end.
 
好东西,可惜不支持MP3音频![:D]
 
后退
顶部