⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 震铃.cpp

📁 VC下实现响铃的小程序
💻 CPP
字号:
//////////////////////////////////////////////////////
//一个模拟振铃的程序: bell.cpp 2001.04.13 by  woodmen
//////////////////////////////////////////////////////
#include<fstream.h>
#include<math.h>
enum ios::seek_dir {beg=0,end=2};
void main(){
 //Open the a file to write into
 ofstream fout;fout.open ("c:\\1.wav",ios::out|ios::binary);

 //set the head of wave file
 short h[22];{
 h[0]=18770; h[1]=17990; h[2]=20992; h[3]=3;
 h[4]=16727; h[5]=17750; h[6]=28006; h[7]=8308;
 h[8]=16; h[9]=0;     h[10]=1; h[11]=1;
 h[12]=11025;h[13]=0; h[14]=11025;h[15]=0;
 h[16]=1; h[17]=8; h[18]=24932;h[19]=24948;
 }char*head=(char*)h;
 fout.seekp (0,beg);
 fout.write (head,44);

 //make the wave data like a bell
 unsigned char data[30000];
 for(int i=0;i<30000;i++)data[i]=unsigned int(sin(i)*tan(i)*tan(i));

 //write the wave data and set the length
 fout.write (data,30000);
 long int length=30000;char *ptr;ptr=(char*)&length;
 fout.seekp (40,beg);fout.write (ptr,sizeof(length));
 //close file
 fout.close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -