(A)下載Do Re Mi.wav
(B)File-New Project.貝殼shell
(C)Build Options 設咒語Link "winmm"
#include <windows.h>
#include <mmsystem.h>
PlaySoundA("Do.wav" , NULL , SND_SYNC);
PlaySoundA("Re.wav" , NULL , SND_SYNC);
PlaySoundA("Mi.wav" , NULL , SND_SYNC);
用freeglut的keyboard彈琴
(A)從剛剛的貝殼專案出發
(B)Build Uptions加咒語
freeglut
opengl32
glu32
gdi32
winmm
(C)nclude目錄....freeglut\include
Link lib........freeglut\lib
#include <windows.h>
#include <mmsystem.h>
void display()
{
}
void keyboard(unsigned char key,int x,int y)
{
if(key=='1')PlaySoundA("Do.wav" , NULL , SND_ASYNC);
if(key=='2')PlaySoundA("Re.wav" , NULL , SND_ASYNC);
if(key=='3')PlaySoundA("Mi.wav" , NULL , SND_ASYNC);
if(key=='4')PlaySoundA("Fa.wav" , NULL , SND_ASYNC);
if(key=='5')PlaySoundA("Sol.wav" , NULL , SND_ASYNC);
if(key=='6')PlaySoundA("La.wav" , NULL , SND_ASYNC);
if(key=='7')PlaySoundA("Si.wav" , NULL , SND_ASYNC);
}
int main(int argc,char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("3D and Sound");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}










沒有留言:
張貼留言