如何用delphi实现扬声器(注意不是用PC喇叭)发出一定频率的声音(100)

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

asdfzxcv66

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用delphi实现扬声器(注意不是用PC喇叭)发出一定频率的声音,如1500Hz,并可控制其声音长度,如200毫秒等,另外如果数字时间长如发出音乐(1234567)中如何暂停和继续(我参考了部分资料,可能要用到多线程,我看了老半天没搞明白,请高手给我源码),谢谢!
 
没有源码,帮你顶顶。
 
beep 可以吗?
 
需要参考DX Sound 方面的API
 
unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, mmSystem;type TForm1 = class(TForm) Button1: TButton;
procedure Button1Click(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);var handle: HMIDIOUT;
begin
// Open default MIDI Out device */ if midiOutOpen(@handle, Cardinal(-1), 0, 0, CALLBACK_NULL) =0 then
begin
// Output the C note (ie, sound the note) */ midiOutShortMsg(handle , $00403C90);
// Output the E note */ midiOutShortMsg(handle, $00404090);
// Output the G note */ midiOutShortMsg(handle, $00404390);
// Here you should insert a delay so that you can hear the notes sounding */ Sleep(1000);
// Now let's turn off those 3 notes */ midiOutShortMsg(handle, $00003C90);
midiOutShortMsg(handle, $00004090);
midiOutShortMsg(handle, $00004390);
// Close the MIDI device */ midiOutClose(handle);
end;
end;
end.
 
北京男人的源码没看懂,英文不好,能解释一下哪儿是表示频率吗,如1245Hz怎么表示
 
《ibm-pc 汇编 》一书不是有 扬声器发声的 例子么。问题是windowXp下不能写端口了。
 
北京男人的源码可以实现功能,但如何设置自己需要的频率呢????????
 
看了 北京男人 的代码,又学习了。呵呵.我试了下:$00403C90 改为 $00a03C90,声音明显加长,由此初步推测:midiOutShortMsg(handle , $00a03C90);第二个参数,前四位是长度,后四位是频率.
 
赶快下载,国外网站的,不知什么时候关,源码全有。我都学习了不少的东西。它能让声卡发出音乐,你想怎控制都行。http://www.filewatcher.com/m/TToneGen.zip.263079.0.0.html
 

Similar threads

I
回复
0
查看
564
import
I
I
回复
0
查看
609
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部