1.下載Do Re Mi.wav
2建立File-New Project. 貝殼專案
3.Build options 設咒語 Linker winmm
4.加入程式碼
#include <iostream>
#include <windows.h>
#include <mmsystem.h>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
PlaySoundA("Do.wav", NULL, SND_SYNC);
PlaySoundA("Re.wav", NULL, SND_SYNC);
PlaySoundA("Mi.wav", NULL, SND_SYNC);
return 0;
}
6.執行Do Re Mi
課堂作業2
1.從剛剛的貝殼專案出發
2.Build options 加咒語
freeglut
opengl32
glu32
gdi32
winmm
3.加入 include 和 lib
4.加入程式碼
#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;
6.執行
課堂作業三
播放 mp3
1.在資料夾加入以下檔案
2. 加入#include "CMP3_MCI.h"
CMP3_MCI player;
3. 在main() 裡加入
player.Load("youkai.mp3");
player.Play();
glutMainLoop();
4.執行
沒有留言:
張貼留言