?? 震鈴.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 + -