hi,
i've a little problem.
i have a 2D array, i ad every frame an value to this array.
now i whant to draw this array.
the array has 500 col's and 15 row's, each col has 15 row's.
by row is y-axis, and col is the x-axis.
Code:int colmax = 500;
int rowmax = 15;
int[][] sgram = new int[rowmax][colmax];
int[] sgram2 =new int[rowmax];
int col;
int leftedge;
int b;
int currMaxVal;
int maxValPos;
for(int i = 0; i < rowmax ; i++)
{
sgram2[i] = (int)Math.round(100*fft.getBand(i));
if ((int)Math.round(fft.getBand(i)) > (currMaxVal)){currMaxVal=((int)Math.round(fft.getBand(i)));
maxValPos = i;
}
}
noStroke();
colorMode(HSB, 140);
color a = color(maxValPos, currMaxVal, currMaxVal);
noStroke();
currMaxVal =0;
maxValPos = 0;
sgram[b][col] = (a);
b=b+1;
if (b==rowmax){b=0;
// next time will be the next column
col = col + 1;
// wrap back to the first column when we get to the end
if (col == colmax) { col = 0; }
}
i will draw the y-axis everytime i ad a new value.
when the row iss full, i will shift it 1 step left and begin to draw a new row.
i tried it like "full spectrum analyz" sketch. but it dont realy work fine.
Code:// Draw points.
// leftedge is the column in the ring-filled array that is drawn at the extreme left
// start from there, and draw to the end of the array
for (int i = 0; i < colmax-leftedge; i++) {
for (int j = 0; j < rowmax; j++) {
stroke(sgram[j][i+leftedge]);
point(i,height-j);
}
}
// Draw the rest of the image as the beginning of the array (up to leftedge)
for (int i = 0; i < leftedge; i++) {
for (int j = 0; j < rowmax; j++) {
stroke(sgram[j][i]);
point(i+colmax-leftedge,height-j);
}
}
// Next time around, we move the left edge over by one, to have the whole thing
// scroll left
leftedge = leftedge + 1;
// Make sure it wraps around
if (leftedge == colmax) { leftedge = 0; }
}
did anybody have a sample??
regars maik