2016年5月2日 星期一

03160276

一.
1建新專案













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

出現






二.


#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_SYNC);
    if(key =='2') PlaySoundA("Re.wav",NULL,SND_SYNC);
    if(key =='3') PlaySoundA("Mi.wav",NULL,SND_SYNC);
    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();
}

新增密語



路徑



資料夾裡有



執行~~~~~~~~~~~


按1會有DO
按2會有RE
...



三.
播放音樂

資料夾裡




程式碼
#include <GL/glut.h>
#include <windows.h>
#include <mmsystem.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;
void display()
{

}
void keyboard(unsigned char key,int x,int y)
{
    if(key =='1') PlaySoundA("Do.wav",NULL,SND_SYNC);
    if(key =='2') PlaySoundA("Re.wav",NULL,SND_SYNC);
    if(key =='3') PlaySoundA("Mi.wav",NULL,SND_SYNC);
    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);
    myMP3.Load("yukai.mp3");
    myMP3.Play();
    glutMainLoop();
}

執行


隨便按一個
OK


可以播音樂ㄌ~


沒有留言:

張貼留言