file-new project-console application
#include<windows.h>
#include<mmsystem.h>
PlaySoundA("檔案位置", NULL, SND_SYNC);
build options設定Linker add winmm
(2)用freeglut的Keyboard彈琴
從剛剛的console application出發
#include<GL/glut.h>
#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);
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("hi 3d");
glutDisplayFunc(display);
glutKeyboard(keyboard);





沒有留言:
張貼留言