2016年5月2日 星期一

week11 搖晃的D罩杯

課堂作業(1)
首先開啟一個新專案

之後再輸入本週密語winmm

與程式碼
#include <iostream>
#include <windows.h>
#include <mmsystem.h>
using namespace std;

int main()
{
    int a;
    for(int i=0;i<10;i++){
        cout << "Hello world!" << endl;
        PlaySoundA("Do.wav",NULL,SND_ASYNC);
        cin>>a;
    }
    return 0;
}


在SND_ASYNC//A指非同步
openprocessing網站下載音檔

再放到專案裡面的資料夾


跑出來的程式顯現
課堂作業(2)
接著做



需要找到
C:\Desktop\freeglut\include
C:\Desktop\freeglut\lib
跟輸入freeglut、opengl32、glu32、gdi32、winmm

freeglut.dll要再放入專案裡面喔

試跑
作業(3)
把剛剛完成的3D寫入KAY數字音鍵

程式碼如下
#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 sound version");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}
記得要把相對應的音檔放入專案資料夾
之後就可以執行囉。
作業(4)

CMP3_MCI先把這個檔案放入專案資料夾裡

然後新增程式碼
#include "CMP3_MCI.h"
CMP3_MCI myMP3;

新增程式碼  
myMP3.Load("yukai.mp3");
myMP3.Play();
這樣接下來跑的就會有自動撥放的MP3音檔

跑出這個就按下OK鍵就行了
也會有數字音鍵。

沒有留言:

張貼留言