2017年11月23日 星期四

翁驊成的學習筆記 week 11

week 11 聲音--音效、音樂

step 1.

可以播wav的方法:
glut
/* Program entry point */
#include <mmsystem.h> //多媒體、聲音
int main(int argc, char *argv[])
{
    PlaySoundA("file.wav", NULL, SND_ASYNC); //SND_SYNC  等同步
                                                                                   //SND_ASYNC 不等,下一行繼續
...
}

step 2.

可以播MP3的方法: 
///PlaySoundA("file.wav", NULL, SND_SYNC);不能跑
使用 CMP3_MCI.h 即可

#include <stdio.h>
#include "CMP3_MCI.h" ///使用外掛
CMP3_MCI mp3;            ///宣告變數
int main()
{
   
mp3.Load("file.mp3"); ///讀入 mp3檔
   
mp3.Play();                 ///Play播放mp3檔
 
   printf("現在在等待輸入a\n");
   int a;
   scanf("%d", &a); ///等待輸入時,程式還沒結束,
為了卡住讓音樂一直播

}

step 3.

P語言
import ddf.minim.*;  //use ddf's minim music library
Minim minim;
AudioPlayer player; //corresponding to one mp3 file
AudioPlayer player2;
void setup()
{
   minim=new Minim(this);                 //constructor of Minim Object
   player=minim.loadFile("file.mp3"); //minim load to player
   player.play();
}
void draw()
{

}

沒有留言:

張貼留言