Hi there, i try to get an array of SoundFile to easy change/pass from one to another by press a button, may i ask for help to archive a simple result like.
Thanks
Gianmaria
import processing.sound.*;
SoundFile sounds;
private static int blk;
private static int sub;
private static int subDiv;
private static Button nextButt;
void setup() {
size(640, 360);
background(255);
blk = width/20;
sub = blk/11;
subDiv = blk/22;
nextButt = new Button(blk*18, 6*blk, blk*2, blk, 11);
//file0 = new SoundFile(this, "00.mp3");
//file0.play();
//file1 = new SoundFile(this, "01.mp3");
//file1.play();
sounds = new SoundFile(this, "02.mp3");
sounds.amp(0.25);
sounds.play();
}
void draw() {
nextButt.display();
}
void mousePressed() {
nextButt.click(mouseX, mouseY);
if (nextButt.clicked) {}
}
final private class Button {
int x, w;
int y, h;
boolean clicked;
int casa;
// Constructor initializes all variables
Button(int tempX, int tempY, int tempW, int tempH, int csa) {
x = tempX;
y = tempY;
w = tempW;
h = tempH;
casa = csa;
}
final private void click(int mx, int my) {
if (mx > x && mx < x + w && my > y && my < y + h) {
clicked = !clicked;
}
}
final private void display() {
if (clicked) {
clicked = !clicked;
fill(191);
} else {
fill(95);
}
rect(x+sub, y+sub, w-(sub*2), h-(sub*2));
fill(31);
font(x+subDiv, y+subDiv, casa);
}
}
private final void left( int x, int y) {
rect(x+sub*5, y+sub*3, sub, sub);
rect(x+sub*4, y+sub*4, sub, sub);
rect(x+sub*3, y+sub*5, sub, sub);
rect(x+sub*4, y+sub*6, sub, sub);
rect(x+sub*5, y+sub*7, sub, sub);
}
private final void right( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub);
rect(x+sub*4, y+sub*4, sub, sub);
rect(x+sub*5, y+sub*5, sub, sub);
rect(x+sub*4, y+sub*6, sub, sub);
rect(x+sub*3, y+sub*7, sub, sub);
}
private final void on( int x, int y) {
rect(x+sub*3, y+sub*3, sub*4, sub);
rect(x+sub*3, y+sub*4, sub, sub*3);
rect(x+sub*5, y+sub*4, sub, sub*3);
rect(x+sub*7, y+sub*4, sub, sub*3);
}
private final void play( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*4, y+sub*4, sub, sub*3);
rect(x+sub*5, y+sub*5, sub, sub);
}
private final void stp( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub*5);
}
private final void one( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*5, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void two( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*4, sub, sub);
rect(x+sub*3, y+sub*6, sub, sub);
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void tre( int x, int y) {
rect(x+sub*3, y+sub*3, sub*4, sub);
rect(x+sub*7, y+sub*3, sub, sub*5);
rect(x+sub*3, y+sub*5, sub*4, sub);
rect(x+sub*3, y+sub*7, sub*4, sub);
}
private final void four( int x, int y) {
rect(x+sub*7, y+sub*3, sub, sub*5);
rect(x+sub*3, y+sub*6, sub*4, sub);
rect(x+sub*4, y+sub*5, sub, sub);
rect(x+sub*5, y+sub*4, sub, sub);
rect(x+sub*6, y+sub*3, sub, sub);
}
private final void five( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*3, y+sub*4, sub, sub);
rect(x+sub*7, y+sub*6, sub, sub);
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void six( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*6, sub, sub);
rect(x+sub*3, y+sub*4, sub, sub*4);
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void seven( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*4, sub, sub);
rect(x+sub*6, y+sub*5, sub, sub);
rect(x+sub*5, y+sub*6, sub, sub*2);
}
private final void eight( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void nine( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*4, sub, sub*2);
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void cop( int x, int y) {
rect(x+sub*3, y+sub*3, sub*5, sub);
rect(x+sub*7, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*4, sub, sub*3);
rect(x+sub*3, y+sub*7, sub*5, sub);
}
private final void paste( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub);
rect(x+sub*3, y+sub*5, sub, sub);
rect(x+sub*3, y+sub*7, sub, sub);
rect(x+sub*4, y+sub*4, sub, sub);
rect(x+sub*4, y+sub*6, sub, sub);
rect(x+sub*6, y+sub*4, sub, sub);
rect(x+sub*6, y+sub*6, sub, sub);
rect(x+sub*5, y+sub*3, sub, sub);
rect(x+sub*5, y+sub*5, sub, sub);
rect(x+sub*5, y+sub*7, sub, sub);
rect(x+sub*7, y+sub*3, sub, sub);
rect(x+sub*7, y+sub*5, sub, sub);
rect(x+sub*7, y+sub*7, sub, sub);
}
private final void clea( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub);
rect(x+sub*3, y+sub*7, sub, sub);
rect(x+sub*4, y+sub*4, sub, sub);
rect(x+sub*4, y+sub*6, sub, sub);
rect(x+sub*6, y+sub*4, sub, sub);
rect(x+sub*6, y+sub*6, sub, sub);
rect(x+sub*5, y+sub*5, sub, sub);
rect(x+sub*7, y+sub*3, sub, sub);
rect(x+sub*7, y+sub*7, sub, sub);
}
private final void plus( int x, int y) {
rect(x+sub*3, y+sub*5, sub*5, sub);
rect(x+sub*5, y+sub*3, sub, sub*5);
}
private final void less( int x, int y) {
rect(x+sub*3, y+sub*5, sub*5, sub);
}
private final void s( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*7, sub*3, sub);
rect(x+sub*3, y+sub*4, sub, sub);
rect(x+sub*5, y+sub*6, sub, sub);
}
private final void a( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*3, sub, sub*5);
}
private final void v( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub*4);
rect(x+sub*4, y+sub*7, sub, sub);
rect(x+sub*5, y+sub*3, sub, sub*4);
}
private final void e( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*7, sub*3, sub);
rect(x+sub*3, y+sub*4, sub, sub * 3);
}
private final void sav(int x, int y){
s(x,y);a(x+sub*4,y);v(x+sub*8,y);e(x+sub*12,y);
}
private final void l( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*3, y+sub*7, sub*3, sub);
}
private final void o( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*7, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*3, sub, sub*5);
}
private final void d( int x, int y) {
rect(x+sub*3, y+sub*3, sub*2, sub);
rect(x+sub*3, y+sub*7, sub*2, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*4, sub, sub*3);
}
private final void loa(int x, int y){
l(x,y);o(x+sub*4,y);a(x+sub*8,y);d(x+sub*12,y);
}
private final void t( int x, int y) {
rect(x+sub*4, y+sub*3, sub, sub*5);
rect(x+sub*3, y+sub*3, sub*3, sub);
}
private final void u( int x, int y) {
rect(x+sub*3, y+sub*3, sub, sub*4);
rect(x+sub*3, y+sub*7, sub*3, sub);
rect(x+sub*5, y+sub*3, sub, sub*4);
}
private final void p( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*3, sub, sub*3);
}
private final void setu(int x, int y){
s(x,y);e(x+sub*4,y);t(x+sub*8,y);u(x+sub*12,y);p(x+sub*16,y);
}
private final void h( int x, int y) {
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*3, sub, sub*5);
}
private final void c( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*3, y+sub*7, sub*3, sub);
}
private final void n( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
rect(x+sub*5, y+sub*3, sub, sub*5);
}
private final void channel(int x, int y){
c(x,y);h(x+sub*4,y);a(x+sub*8,y);n(x+sub*12,y);n(x+sub*16,y);e(x+sub*20,y);l(x+sub*24,y);
}
private final void note(int x, int y){
n(x,y);o(x+sub*4,y);t(x+sub*8,y);e(x+sub*12,y);
}
private final void i( int x, int y) {
rect(x+sub*4, y+sub*3, sub, sub*5);
}
private final void y( int x, int y) {
rect(x+sub*4, y+sub*5, sub, sub*3);
rect(x+sub*3, y+sub*3, sub, sub*2);
rect(x+sub*5, y+sub*3, sub, sub*2);
}
private final void velocity(int x, int y){
v(x,y);e(x+sub*4,y);l(x+sub*8,y);o(x+sub*12,y);c(x+sub*16,y);i(x+sub*19,y);t(x+sub*22,y);y(x+sub*26,y);
}
private final void f( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*3, sub, sub*5);
}
private final void noteOffCh(int x, int y){
note(x,y);o(x + sub *16,y);f(x + sub *20,y);f(x + sub *24,y);channel(x + sub *32,y);
}
private final void x( int x, int y) {
rect(x+sub*4, y+sub*5, sub, sub);
rect(x+sub*3, y+sub*3, sub, sub*2);
rect(x+sub*5, y+sub*3, sub, sub*2);
rect(x+sub*3, y+sub*6, sub, sub*2);
rect(x+sub*5, y+sub*6, sub, sub*2);
}
private final void xAxis(int x, int y){
a(x ,y);x(x + sub *4,y);i(x + sub *7,y);s(x + sub *10,y);t(x + sub * 18,y);o(x + sub * 22,y);c(x + sub * 30,y);c(x + sub * 34,y);
}
private final void m( int x, int y) {
rect(x+sub*3, y+sub*3, sub*4, sub);
rect(x+sub*3, y+sub*4, sub, sub*4);
rect(x+sub*5, y+sub*4, sub, sub*4);
rect(x+sub*7, y+sub*3, sub, sub*5);
}
private final void axisMin(int x, int y){
a(x ,y);x(x + sub *4,y);i(x + sub *7,y);s(x + sub *10,y);m(x + sub *18,y);i(x + sub *23,y);n(x + sub *26,y);
}
private final void font(int x, int y, int cas) {
switch(cas) {
case 0:
cop(x, y);
break;
case 1:
one(x, y);
break;
case 2:
two(x, y);
break;
case 3:
tre(x, y);
break;
case 4:
four(x, y);
break;
case 5:
five(x, y);
break;
case 6:
six(x, y);
break;
case 7:
seven(x, y);
break;
case 8:
eight(x, y);
break;
case 9:
nine(x, y);
break;
case 10:
left(x, y);
break;
case 11:
right(x, y);
break;
case 12:
on(x, y);
break;
case 13:
play(x, y);
break;
case 14:
stp(x, y);
break;
case 15:
paste(x, y);
break;
case 16:
break;
case 17:
plus(x, y);
break;
case 18:
less(x, y);
break;
case 19:
sav(x, y);
break;
case 20:
loa(x, y);
break;
case 21:
clea(x, y);
break;
case 22:
setu(x, y);
break;
/*
case 23:
randVelDot(x, y);
break;
case 24:
randDot(x, y);
break;
case 25:
velDot(x, y);
break;
*/
}
}
/*
void randVelDot( int x, int y) {
rect(x+sub*3, y+sub*3, sub*3, sub);
rect(x+sub*5, y+sub*4, sub, sub);
rect(x+sub*3, y+sub*5, sub*3, sub);
rect(x+sub*3, y+sub*7, sub, sub);
rect(x+sub*7, y+sub*3, sub, sub*3);
rect(x+sub*7, y+sub*7, sub, sub);
}
void randDot( int x, int y) {
rect(x+sub*4, y+sub*3, sub*3, sub);
rect(x+sub*6, y+sub*4, sub, sub);
rect(x+sub*4, y+sub*5, sub*3, sub);
rect(x+sub*4, y+sub*7, sub, sub);
}
void velDot( int x, int y) {
rect(x+sub*5, y+sub*3, sub, sub*3);
rect(x+sub*5, y+sub*7, sub, sub);
}
*/