2016年5月3日 星期二

Week11 呂汶佶

hw01
彈DO RE MI

開啟貝殼專案
1.下載DO RE MI.wav檔


2.DO RE MI 拉到專案裡頭

3.程式碼
#include <windows.h>
#include <mmsystem.h>
    PlaySoundA("Do.wav", NULL , SND_SYNC);
    PlaySoundA("Re.wav", NULL , SND_SYNC);
    PlaySoundA("Mi.wav", NULL , SND_SYNC);



4.無法執行,增加Linker settings
winmm


5.執行


hw02
用freeglut的keyboard彈琴

1.從hw01的貝殼專案出發

2.freeglut.dll拉到專案裡


3.設定
freeglut
opengl32
giu32
gdi32
winmm


4.設定Include目錄

設定Lib目錄




5.Do Re Mi Fa Sol La Si拉到專案裡


6.撰寫程式碼,執行


#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);
    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;
}




沒有留言:

張貼留言