2019年9月19日 星期四

week02_秋天

Sound編輯(超前)

匯入函式庫方式

輸入minim找到該函式庫下載就好了

函式庫中可使用下:
  • AudioPlayer 播放
  • AudioMetaData 讀取mp3檔
  • AudioRecorder 錄音
  • AudioInput 監聽聲音輸入的內容
  • AudioOutput 輸出聲音
免費音樂資料庫:freesound

點按撥放暫停音樂

song.loop(); //循環播放
song.skip(1000);// 快轉
song.skip(-2000); //倒轉

以下程式碼:
import ddf.minim.*; //匯入聲音函式庫


//宣告變數
Minim minim;
AudioPlayer song;
boolean isPlaying = false;

void setup(){
  size(100,100);
  
  minim = new Minim(this);  //物件
  
  song = minim.loadFile("playsound/test.mp3"); //讀入MP3檔
  song.loop(); //循環播放
  song.play(); //播放
  isPlaying = true;
}

void draw(){
  
}

void mousePressed(){ //事件偵測 滑鼠點按
  if(isPlaying){
    song.pause(); //暫停
  }else{
    song.play();
  }
  isPlaying = !isPlaying;
}

void keyPressed(){//事件偵測 鍵盤
 if(key == 'f'){ // 快轉
   song.skip(1000);
 }
 if(key == 'r'){ //倒轉
   song.skip(-2000);
 }
}
打卡機



void setup(){
  size(800,300);
 for(int x = 0; x < 800; x+=16){
    for(int y = 0; y < 300; y+=30){
      rect(x,y,16,30);
    }
  }
}
void draw(){

}

void mousePressed(){
  int nowX = mouseX/16*16, nowY = mouseY/30*30;
  fill(0);
  rect(nowX,nowY,16,30);
}

圖片放入
PImage img;

void setup(){
  img = loadImage("1780.jpg");
  size(1000,1000);

}
void draw(){
  //image(img, 0, 0);
  //image(img,mouseX,mouseY,width/4,height/4);
}

void mousePressed(){
  image(img,mouseX,mouseY,width/4,height/4);
}
有背景圖的打卡
PImage img; //背景圖

void setup(){
  img = loadImage("1780.jpg");
  image(img, 0, 0,width*2,height*2);
  size(1000,500);
  /*for(int x = 0; x < 800; x+=10){
    for(int y = 0; y < 400; y+=18){
      rect(x,y,16,30);
    }
  }*/
}
void draw(){

}

void mousePressed(){
  int nowX = mouseX/10*10, nowY = mouseY/15*15;
  if(mouseButton == LEFT){
    fill(0);
  }else if(mouseButton == RIGHT){
    fill(166);
  }
  
  rect(nowX,nowY,10,15);
  
}

void keyPressed(){
 if(key == 's'){
   save("diagonal.jpg"); //存圖
 }
}

  





沒有留言:

張貼留言

alanhc 互動技術-week17 [final]

回顧這學期的作品:  期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...