Wednesday, 13 April 2011

Well, seems like i have to upload my code here for the time being but i will try again later to upload the code to openprocessing.



So here's the code that i have been working on so far:

--------------------------------------------------------------------------------------------------------------
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;

  Minim minim;
  AudioPlayer song1;
  AudioPlayer song2;
  AudioPlayer song3;
  AudioPlayer song4;
  AudioPlayer song5;
  AudioPlayer song6;
  AudioPlayer song7;
  AudioPlayer song8;
  AudioPlayer song9;
  AudioPlayer song10;
 
  //ArrayList Line1 = new ArrayList();
  //Line.add(Line1);
  int s1=0;

void setup(){
  size(500,500);
  background(255);
  minim = new Minim(this);
  song1 = minim.loadFile("1.wav");
  song2 = minim.loadFile("2.wav");
  song3 = minim.loadFile("3.wav");
  song4 = minim.loadFile("4.wav");
  song5 = minim.loadFile("5.wav");
  song6 = minim.loadFile("6.wav");
  song7 = minim.loadFile("7.wav");
  song8 = minim.loadFile("8.wav");
  song9 = minim.loadFile("9.wav");
  song10 = minim.loadFile("10.wav");
}
void draw(){
}
/*void mouseDragged(){
  background(255);
  smooth();
  stroke(0);
  strokeWeight(0.2);
  int x1,x2;
  int m1=mouseX;
  int m2=mouseY;
  for(x1=0; x1<=500; x1=x1+5){
      line(x1,0,m1,m2);
    }
  for(x2=0; x2<=500; x2=x2+5){
      line(m1,m2,x2,500);
    }
    //song.play();
}*/
void mouseClicked(){
  background(255);
  smooth();
  stroke(0);
  strokeWeight(5);
  point(mouseX,mouseY);
}

void mouseDragged(){
  background(255);
  smooth();
  stroke(50);
  strokeWeight(0.2);
  int x3,x4;
  float m3=mouseX;
  float m4=mouseY;
  for(x3=0; x3<=500; x3=x3+20){
      line(x3,0,m3,m4);
    }
  for(x4=0; x4<=500; x4=x4+20){
      line(m3,m4,x4,500);
    }
   
}
void mouseReleased(){
  background(255);
  smooth();
  stroke(0);
  strokeWeight(0.2);
  int x1,x2;
  float m1=mouseX;
  float m2=mouseY;
  for(x1=0; x1<=500; x1=x1+20){
      line(x1,0,m1,m2);
    }
  for(x2=0; x2<=500; x2=x2+20){
      line(m1,m2,x2,500);
    }
    if (m1<=50){
      song1.loop();
      stroke(0.2);
      fill(255,100);
      s1=s1+5;
      ellipse(m1,m2,s1,s1);

     
    }
     if (m1>50 && m1<=100){
      song2.loop();
    }
     if (m1>100 && m1<=150){
      song3.loop();
    }
     if (m1>150 && m1<=200){
      song4.loop();
    }
     if (m1>200 && m1<=250){
      song5.loop();
    }
     if (m1>250 && m1<=300){
      song6.loop();
    }
     if (m1>300 && m1<=350){
      song7.loop();
    }
     if (m1>350 && m1<=400){
      song8.loop();
    }
     if (m1>400 && m1<=450){
      song9.loop();
    }
     if (m1>450){
      song10.loop();
    }    
}
void stop()
{
    song1.close();
    song2.close();
    song3.close();
    song4.close();
    song5.close();
    song6.close();
    song7.close();
    song8.close();
    song9.close();
    song10.close();
    minim.stop();
    super.stop();
}
 
void keyPressed()
{
  if(key == 's' || key == 'S')
  {
    String filePath = selectInput("Saving PNG - Select or Type File Name");  // Opens file chooser
    if(filePath != null)
    {
      save(filePath + ".png");
    }
  }
}
--------------------------------------------------------------------------------------------------------------

So what it does?

If you drag the midpoint, the pattern will change according to the new mousex position and mousey position
This is what it will appear when you drag the midpoint and then release it in the area x <= 50. Note: the circal is intended to represent the playing sound but in the mean time i  only managed to make it appear at a certain area (50>=x ), not all. (see the yelow highlighted code)



What i want it to be done:  -I want to make other pattern by clicking in the white space on the screen. To achieve these i have to use arrayList but i still dont really get it.

-I want the circal appears wherever the midpoint is when the mouse released. And it will get bigger when the sound plays (prob the value will change from 0-20 range) and vanishes when the sound stops and then begins another loop when the sound plays again.This idea is actually inspired by the xylophone sound (as i mentioned in the earlier post). It always make me think about water drop whenever this sound plays

- I want the midpoint of each pattern connect with others by straight lines and these line will change the length if you change either or both midpoints' position that they connect.

No comments:

Post a Comment