class Place{ int id; String comarca; String mp3; String img; String url; int imgWidth; String title; String autor; String date; int idCategory; String titleCategory; float x; float y; int radius = 6; float xx; float yy; int windowMargin; int up; color colorNormal = #cc9900; color cSilenceNormal = #a23004; int colorNormalAlpha = 23; float distSequencerGain; float distSequencerPan; float gain; float pan; boolean selected = true; boolean isPlaying = false; boolean isMp3Loaded = false; boolean isImgLoaded = false; AudioPlayer player; float loopAngle = 0.0; int[] loopDrawBuffer= new int[255]; float soundAreaHeight=150; float soundAreaY2 = 20; int scrollSpaceLineAlpha = 90; int i=5; PImage picture; public Place(int code, String comarca, float x, float y, String mp3, String img, int imgWidth, String title, String url, String _autor, String _date, int _idCat){ this.id = id; this.comarca = comarca; this.x = x; this.y = y; this.mp3 = mp3; this.img = img; this.imgWidth = imgWidth; this.title = title; this.url = url; autor = _autor; date = _date; idCategory = _idCat; // Categories of the soundScapes. Set up of the different colors of the points. if(idCategory == 30){ colorNormal = #0078cc; }else if(idCategory == 31){ colorNormal = #cc9900; }else if(idCategory == 32){ colorNormal = #cc008b; }else if(idCategory == 33){ colorNormal = #ad00cc; }else if(idCategory == 34){ colorNormal = #cc3e00; }else if(idCategory == 35){ colorNormal = #00cacc; }else if(idCategory == 36){ colorNormal = #95cc00; } } void draw(){ xx = TX(x); yy = TY(y); } void update(){ if ((xx > timelineSpaceX) && (xx < width)){ if(isMp3Loaded){ displayOnSeq(); }else{ xx = constrain(xx, 0, timelineSpaceX-radius); // don't let go further the silent space if the sound was not loaded. displayOnSilence(); } checkGain(); checkPan(); }else if((xx > silenceSpaceX) && (xx < timelineSpaceX)){ displayOnSilence(); }else{ displayOnMap(); } } void loadMp3(){ if(!isMp3Loaded){ player = minim.loadFile(mp3, 512); isMp3Loaded = true; } } void play(){ if(player != null){ player.play(); player.loop(); } } void pause(){ if(player != null){ player.pause(); } } void checkGain(){ if((player != null) && (player.hasControl(ddf.minim.Controller.PAN))){ distSequencerGain = abs(yy - timeline.lineY); if(distSequencerGain <= soundAreaHeight){ gain = map(abs(distSequencerGain), 0, soundAreaHeight, 6, -40); player.setGain(gain); } } } void checkPan(){ if((player != null) && (player.hasControl(ddf.minim.Controller.PAN))){ if ((xx > timelineSpaceX) && (xx < width)){ distSequencerPan = abs(timelineSpaceX - xx); pan = map(distSequencerPan, 0, width - timelineSpaceX, -1, 1); player.setPan(pan); } } } void loadPicture(){ if(!isImgLoaded){ picture = loadImage(img); isImgLoaded = true; } } void displayPicture(){ image(picture, 0, 0); } void displayInfoWindow(){ textFont(font, 15); fill(40, 90); if(mouseY>height/2){ windowMargin = 20; up = 160; }else{ windowMargin = 20; up = 0; } if(picture!=null){ image(picture, mouseX-(textWidth(title)/2)-(imgWidth/2), mouseY + windowMargin - up); } noStroke(); rectMode(CORNER); rect(mouseX-(textWidth(title)/2)+(imgWidth/2), mouseY + windowMargin - up, textWidth(title) + windowMargin, 120); fill(#ffffff, 99); textAlign(LEFT); text(title, mouseX-(textWidth(title)/2)+(imgWidth/2)+windowMargin/2, mouseY + 50 - up); textFont(font, 14); fill(#ffffff, 80); text("Recorded by " + autor, mouseX-(textWidth(title)/2)+(imgWidth/2)+windowMargin/2, mouseY + 80 - up); text("Date: " + date, mouseX-(textWidth(title)/2)+(imgWidth/2)+windowMargin/2, mouseY + 100 - up); text("Rec Info: shift + clic ", mouseX-(textWidth(title)/2)+(imgWidth/2)+windowMargin/2, mouseY + 120 - up); } void displaySoundArea(){ for(int i=0; i silenceSpaceX){ loadMp3(); if(player!=null){ setPlaying(); } } if(xx > timelineSpaceX){ play(); }else if(isPlaying){ pause(); } if(xx= 6){ i--; radius = i; } fill(colorNormal, 80); noStroke(); ellipse(xx, yy, radius, radius); fill(colorNormal, 25); ellipse(xx, yy, radius*3, radius*3); } void displayOnSeq(){ displaySoundArea(); scrollSpaceLine(); noStroke(); fill(colorNormal, 20); ellipse(xx, yy, radius*12, radius*12); fill(colorNormal, colorNormalAlpha); ellipse(xx, yy, radius*3, radius*3); // println(player.length() + "long"); float mx = map(player.position(), 0, player.length(), 0, TWO_PI); float sinval = sin(mx); float cosval = cos(mx); float loopX = xx + (cosval * radius*6); float loopY = yy + (sinval * radius*6); float loopX2 = xx + (cosval * radius*2); float loopY2 = yy + (sinval * radius*2); ellipse(loopX, loopY, 2, 2); ellipse(loopX2, loopY2, 2, 2); stroke(255, 0, 0); line(loopX, loopY, loopX2, loopY2); displaySoundWave(); } void displayOnSilence(){ fill(cSilenceNormal); noStroke(); ellipse(xx, yy, radius*2, radius*2); fill(cSilenceNormal, 50); ellipse(xx, yy, radius*3, radius*3); if(player == null){ stroke(255, 0, 0); line(xx-radius, yy-radius, xx+radius, yy+radius); line(xx+radius, yy-radius, xx-radius, yy+radius); } } void scrollSpaceLine(){ stroke(#e1bf00, scrollSpaceLineAlpha); if((abs(mouseX-(xx)) < 5) && ((mouseY-yy) < (soundAreaY2+20)&&(mouseY-yy) > (0))){ strokeWeight(6); scrollSpaceLineAlpha = 100; if(mousePressed){ changeSoundArea(); } }else{ strokeWeight(1); scrollSpaceLineAlpha = 90; } line(xx, yy+(radius*3/2), xx, yy+soundAreaY2); strokeWeight(1); } void changeSoundArea(){ soundAreaY2 = mouseY-yy; soundAreaHeight = soundAreaY2+30; } void stop(){ // always close Minim audio classes when you are done with them player.close(); minim.stop(); //super.stop(); } void linkUrl(){ link(url); keyPressed=false; } }