Hi All,
Festive greetings. What’s the best way to do this? I will have up to 256 different sections of a live AV performance - each potentially featuring a different bit of cool codey Processing stuff. Should I be using a for loop (<=255, i++?) How I then could I implement variable content depending upon a current pattern? See my idiot code below - while I think this would work, it seems far from optimal.
if (PatternNewNumber!=-1){
textSize(48);
text(PatternNewNumber, 10, 100);
if (PatternNewNumber == 0){
// cool Processing Stuff 1..
}
if (PatternNewNumber == 1){
// cool Processing Stuff 2..
}
if (PatternNewNumber == 2){
// cool Processing Stuff 3..
}
...&etc
if (PatternNewNumber == 256){
// cool Processing Stuff 255
}
}
Oh my brain hurts!! Excellent. thanks for the guidance. What’s the rational for approaching the problem in this way? What are the advantages over the simple switch example?
It simplifies the creation and use of your coolstuff.
To create new coolstuff simply add extra stuffs in the createCoolStuffs() function then when you want to use it initialise it in setup and call it in draw like this
Hey quark and GoToLoop,
This is making total sense - thanks to you both for your clarity - you guys are great - making complex things easy to understand - a real gift Thank you and Nadolig Llawen (Welsh for Merry Christmas)
As I am now trying to expand upon the CoolStuff abstract class, where would I incorporate, for example, movie playback. If I wanted to play a different video for each bankstuffs[i] where’s the best place for the following? Import the video library in the main sketch? If there are 16 different large video files (1GB+) will there be any potential memory issue with putting movie = new Movie(this, “BankA.mov”); x 16 in setup() as the example suggests? Do I put it in the CoolBanks class instead? and the movieEvent into the mainsketch too? What’s finally the best way to conditionally play each movie - bankstuffs[0], bankstuffs[1], bankstuffs[2] etc ? Any guidance would be awesome.
import processing.video.*; // this in main sketch?
Movie bankmovie;
void setup() {
size(560, 406);
background(0);
bankmovie = new Movie(this, "BankA.mov"); /* there will be 16 of these - should this be an array
any likely issue with 16 large video files here? */
bankmovie.loop();
}
void movieEvent(Movie m) { // where should this go - main sketch or abstract class?
m.read();
}
void draw() {
if (bankmovie.available() == true) {
bankmovie.read();
image(bankmovie, 0, 0, width, height); /* make bankmovie an array index? bankmovie[i]? called within bankstuffs[i]?
*/
}
}