关于声道控制问题,200分(200分)

  • 主题发起人 主题发起人 Arcter
  • 开始时间 开始时间
A

Arcter

Unregistered / Unconfirmed
GUEST, unregistred user!
我想设计一个卡拉OK播放系统,可以实现原唱和OK切换,
设想为控制声道来实现,在delphi中如何得到一个声道的声音
然后在两个声道发音,请请教各位大虾
 
我有一个第三方的控件
 
用audio控件
 
我花钱买过一个控件,不过好早了,delphi3的吧,不知道还能不能用
 
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.
 
如果是AVI的文件有没有办法?

DJ6674,能否将控件email一份:arcter@163.net,谢谢。
 
我也要,麻烦DJ6674。
email:tatayou@eyou.com
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
911
DelphiTeacher的专栏
D
D
回复
0
查看
868
DelphiTeacher的专栏
D
D
回复
0
查看
835
DelphiTeacher的专栏
D
后退
顶部