永发信息网

C语言编程声音的问题

答案:3  悬赏:60  手机版
解决时间 2021-03-28 14:19
  • 提问者网友:树红树绿
  • 2021-03-28 08:39
C语言编程声音的问题
最佳答案
  • 五星知识达人网友:老鼠爱大米
  • 2021-03-28 09:42
在TC2.0或者VC++6.0下运行下面程序,就是一个MP3歌,但我忘记了这首歌的名字,你先听听吧!
做个mp3播放器
#include
#include
#define N1 64
#define N2 32
#define N4 16
#define N8 8
#define N16 4
#define END 0
enum NOTES
{
C10=131,D10=147,E10=165,F10=175,G10=196,A10=220,B10=247,
C0=262,D0=296,E0=330,F0=349,G0=392,A0=440,B0=494,
C1=525,D1=587,E1=659,F1=698,G1=784,A1=880,B1=988,
C2=1047,D2=1175,E2=1319,F2=1397,G2=1568,A2=1760,B2=1796
}
song[]={
D0,N4,E0,N8,C0,N4,A10,N4,G10,N8,E10,N8,G10,N8,A10,
N8,C0,N2,A10,N4,A10,N8,C0,N8,G10,N8,A0,N8,E0,N8,G0,N8,
D0,N2,E0,N4,D0,N8,E0,N8,G0,N4,E0,N4,G10,N8,E10,N8,G10,
N8,A10,N8,C0,N2,A10,N4,A10,N8,C0,N8,A10,N8,A10,N8,D10,
N8,E10,N8,G10,N2,D0,N4,D0,N4,G0,N4,A0,N8,G0,N8,F0,N2,G0,
N2,A0,N4,G0,N8,E0,N8,D0,N8,E0,N8,C0,N8,A10,N8,D0,N2,E0,
N4,G0,N8,E0,N8,G0,N4,E0,N4,G10,N8,E10,N8,A10,N8,
C0,N4,A10,N4,A10,N8,C0,N8,D0,N8,A10,N8,C0,N8,E0,N8,D0,
N1,END,END};
main()
{
int note=0;
int fre,dur,control;
clock_t goal;
printf("please leason song of kewang:\n");
while (song[note]!=0)
{
fre=song[note];
dur=song[note+1];
if (kbhit())
break;
if (fre)
{
outportb(0x43,0xb6);
fre=(unsigned)(1193180L/fre);
outportb(0x42,(char) fre);
outportb(0x42,(char) (fre>>8));
control=inportb(0x61);
outportb(0x61,(control)|0x3);
}
goal=(clock_t)dur+clock();
while(goal>clock());
if (fre)
outportb(0x61,control);
goal=(clock_t)0;
note=note+2;
}
}
看看满不满意!
全部回答
  • 1楼网友:像个废品
  • 2021-03-28 10:41
for windows: direct x sdk 9.0->direct sound
for linux: open al
  • 2楼网友:一秋
  • 2021-03-28 09:59
VC就是支持C语言的。这么简单的问题。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯