2020年5月12日 星期二

week12 Heng's




目標 : 播放wav檔(聲音,音效,音樂)
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
int main()
{

    PlaySoundA("Hahaha.wav",NULL,SND_SYNC); ///上網下載wav檔
    printf("Hello World\n");
}
 (點擊發出聲音)
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include <GL/glut.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSwapBuffers();
}
void mouse(int button,int state,int x,int y)
{
    if(state==GLUT_DOWN) PlaySoundA("Hahaha.wav",NULL,SND_SYNC);
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week12 sound");

    glutMouseFunc(mouse); ///MOUSE發出聲音
    glutDisplayFunc(display);
    glutMainLoop();
}
moolde下載檔案程式庫
目標:邊播放mp3邊點擊出wav檔(音效)
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
#include <GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMp3;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSwapBuffers();
}
void mouse(int button,int state,int x,int y)
{
    if(state==GLUT_DOWN) PlaySoundA("Hahaha.wav",NULL,SND_SYNC);
}
int main(int argc,char**argv)
{
    myMp3.Load("CrushOn.mp3");
    myMp3.Play();
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week12 sound");
    glutMouseFunc(mouse);
    glutDisplayFunc(display);
    glutMainLoop();
}


沒有留言:

張貼留言