一行程式碼發出聲音
google OpenProcessing 下載聲音檔

開啟貝殼專案

輸入咒語 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;
}
作業二 鍵盤
開新專案輸入咒語串
輸入連結
輸入程式碼到這能夠開起鍵盤模式 沒辦法按出聲音
輸入到這即可成功做出鍵盤
程式碼 :
#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();
}
作業三 撥放mp3
在2015電腦圖學找到 能找到能用mp3的檔案

youtube 轉 mp3

輸入新增之程式碼 即可撥放





沒有留言:
張貼留言