如何让PC主机上的喇叭发音?

hboy 2001-10-07 06:50:39
除用MessageBeep还有其它的方式吗,如用汇编,可提供源程序吗?我对汇编可不懂,
MessageBeep也太烂了,在98下只能发一种音,并且还不怎么响.
...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhujianping_es 2001-10-07
  • 打赏
  • 举报
回复
Use this macro,I have try it and it could sing !
__________________________________________________
;*************************************************************************** *
;This macro could play music which locates at data segment *
; written by:zhujianping *
; 2001.5.26 *
;Variable: *
; segid: name of the data segment where *
; the music frequency and time is stored! *
; mus_freq: the start place of the music frequency in data segment! *
; mus_time: the start place of the music last time stored in data *
; segment! *
;***************************************************************************
play macro segid,mus_freq,mus_time
;--------------------------------------------
local music,freq,end_mus,wait1,delay
;********************
push ax
push bx
push cx
push dx
push di
push si
push bp
push ds
;*******************
mov ax,segid
mov ds,ax
lea si,mus_freq
lea bp,ds:mus_time
freq: mov di,[si]
cmp di,-1
je end_mus
mov bx,ds:[bp]
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
push ax
push bx
push cx
push dx
push di

mov al,0b6h
out 43h,al

mov dx,12h
mov ax,533h*896
div di
out 42h,al
mov al,ah
out 42h,al

in al,61h
mov ah,al
or al,3
out 61h,al

mov bx,3000
wait1: mov cx,2801
delay: loop delay
dec bx
jnz wait1

mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax

;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
add si,2
add bp,2
jmp freq
end_mus:
pop ds
pop bp
pop si
pop di
pop dx
pop cx
pop bx
pop ax
endm



hboy 2001-10-07
  • 打赏
  • 举报
回复
不行呀,编译都通不过
mjk 2001-10-07
  • 打赏
  • 举报
回复
_asm{
in
out
led ax,10

}
sdzym 2001-10-07
  • 打赏
  • 举报
回复
// 通过PC喇叭发出声音
UINT Sound(LPVOID pParam)
{
int FreqTable[100];
int DelayTable[100];

for(int i=0;i<10;i+=100)
{
FreqTable[i]=50*i+500;
DelayTable[i]=100;
}

int *nFreqTableLength = (int *)pParam;
int Freq;
for(i=0;i<*nFreqTableLength;i++)
{
Freq=FreqTable[i];
if(Freq<37||Freq>32767)
{
_outp(0x61,_inp(0x61)&0xFC);//NoSound()
continue;
}
Freq=1193181/Freq;
_outp(0x61,_inp(0x61)|3);
_outp(0x43,0xB6);
_outp(0x42,Freq&0x00ff);
_outp(0x42,(Freq&0xff00)>>8);
Sleep(DelayTable[i]);
_outp(0x61,_inp(0x61)&0xFC);//NoSound()
}
_outp(0x61,_inp(0x61)&0xFC);//NoSound()
return TRUE;
}

void NoSound()
{
_outp(0x61,_inp(0x61)&0xFC);
}

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧