2016年5月3日 星期二

Week11 林盈君

(1)PlaySoundA播放wav檔
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);

    glutMainLoop();
}

build options設定


遺失freeglut.dll處理


(3)加入mp3音樂

#include"CMP3_MCI.h"
CMP3_MCI player;

int main(int argc, char *argv[])
{
    .......
    player.Load("youkai.mp3");
    player.Play();
    glutMainLoop();
}




沒有留言:

張貼留言