Advertisement
Guest User

Untitled

a guest
Sep 11th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 62.68 KB | None | 0 0
  1. abstract class Visualization {
  2.   abstract void setup();
  3.   abstract void draw();
  4. }
  5. class Visualization1 extends Visualization {
  6.   // Processing Sound-Painting Animation Inspired by Stockhausen
  7.   // Shapes: Ovals, Rectangles, Lines
  8.   // Music Articulation Mapped: Dynamics(Volume), Pitch, Rhythm, Timbre
  9.  
  10.   // Variables for animation control
  11.   float pitch;      // Represents pitch(mapped to y-position of shapes)
  12.   float volume;     // Represents dynamics(mapped to size of shapes)
  13.   float rhythm;     // Represents time intervals between shape changes
  14.   float timbre;     // Represents timbre(mapped to color)
  15.  
  16.   void setup() {
  17.     size(800, 800);
  18.     frameRate(30);  // Control speed of animation
  19.     noStroke();
  20.     background(0);
  21.   }
  22.  
  23.   void draw() {
  24.     background(0, 30); // Slow fade effect to create smooth transitions
  25.  
  26.     // Simulate changes in pitch, volume, rhythm, and timbre dynamically
  27.     pitch = map(sin(frameCount * 0.05), -1, 1, 0, height);
  28.     volume = map(abs(sin(frameCount * 0.1)), 0, 1, 20, 200);
  29.     rhythm = map(noise(frameCount * 0.01), 0, 1, 5, 50);
  30.     timbre = map(sin(frameCount * 0.02), -1, 1, 0, 255);
  31.  
  32.     // Drawing ovals based on music articulation
  33.     fill(timbre, 255 - timbre, 150, 150);  // Color representing timbre
  34.     ellipse(width / 2, pitch, volume, volume);  // Oval with changing pitch and volume
  35.  
  36.     // Drawing rectangles to represent rhythm sections
  37.     fill(255 - timbre, timbre, 200, 150);
  38.     rect(random(width), pitch, rhythm, volume);  // Random rectangles appearing based on rhythm
  39.  
  40.     // Adding lines for texture and structure(representing articulation nuances)
  41.     stroke(255, 100);
  42.     line(random(width), random(height), width/2, pitch);
  43.  
  44.     // Adding more complexity for layers, creating a Stockhausen-esque aesthetic
  45.     if (frameCount % 50 == 0) {
  46.       float rectSize = random(30, 100);
  47.       fill(timbre, random(255), random(255), 200);
  48.       rect(random(width), random(height), rectSize, rectSize);
  49.     }
  50.   }
  51. }
  52. class Visualization2 extends Visualization {
  53.   // Processing Pointillistic Sound-Painting Inspired by Stockhausen
  54.   // Pointillism within rhythm, pitch, and articulation
  55.  
  56.   int numPoints = 300;  // Number of pointillist elements
  57.   float[] x = new float[numPoints];  // X positions for points
  58.   float[] y = new float[numPoints];  // Y positions for points(mapped to pitch)
  59.   float[] sizes = new float[numPoints];  // Sizes representing articulation
  60.   float[] lifeSpan = new float[numPoints];  // LifeSpan controls duration of shapes
  61.   color[] colors = new color[numPoints];  // Color represents timbre
  62.  
  63.   void setup() {
  64.     size(800, 800);
  65.     frameRate(30);
  66.     noStroke();
  67.     initializePoints();  // Initialize all points
  68.   }
  69.  
  70.   void initializePoints() {
  71.     for (int i=0; i<numPoints; i++) {
  72.       x[i] = random(width);  // Random horizontal position
  73.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical mapped to pitch
  74.       sizes[i] = random(5, 20);  // Random size for articulation
  75.       lifeSpan[i] = random(30, 100);  // Each point's lifespan before disappearing
  76.       colors[i] = color(random(255), random(255), random(255), 150);  // Semi-transparent colors
  77.     }
  78.   }
  79.  
  80.   void draw() {
  81.     background(0, 40);  // Semi-fade for smoother transitions
  82.  
  83.     // Loop through all points and update based on musical ideas
  84.     for (int i=0; i<numPoints; i++) {
  85.       if (lifeSpan[i] > 0) {
  86.         // Draw points representing individual sounds
  87.         fill(colors[i]);
  88.         ellipse(x[i], y[i], sizes[i], sizes[i]);  // Draw an ellipse as a point
  89.         lifeSpan[i] -= 1;  // Reduce lifespan
  90.  
  91.         // Update position and articulation over time for a dynamic "sound-painting"
  92.         x[i] += random(-1, 1);  // Simulate slight movement in x(rhythmic instability)
  93.         y[i] += random(-1, 1);  // Simulate small fluctuations in y(pitch micro-variations)
  94.       } else {
  95.         // Respawn the point with new properties(like a new note or articulation)
  96.         x[i] = random(width);
  97.         y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Pitch change
  98.         sizes[i] = random(5, 20);  // New articulation size
  99.         lifeSpan[i] = random(30, 100);  // Reset lifespan
  100.         colors[i] = color(random(255), random(255), random(255), 150);  // New timbre color
  101.       }
  102.     }
  103.   }
  104. }
  105. class Visualization3 extends Visualization {
  106.   // Processing Pointillistic Music Texture Inspired by Stockhausen
  107.   // Aesthetic: Pointillism applied to Rhythm, Pitch, and Articulation
  108.  
  109.   int numShapes = 400;  // Number of shapes
  110.   float[] x = new float[numShapes];  // X positions for shapes(time/rhythm)
  111.   float[] y = new float[numShapes];  // Y positions for shapes(pitch)
  112.   float[] sizes = new float[numShapes];  // Sizes representing articulation(dynamics)
  113.   float[] lifeSpan = new float[numShapes];  // Life span of each shape
  114.   float[] speeds = new float[numShapes];  // Speed of movement for rhythm variation
  115.   color[] colors = new color[numShapes];  // Color representing timbre
  116.  
  117.   void setup() {
  118.     size(800, 800);
  119.     frameRate(30);
  120.     noStroke();
  121.     initializeShapes();  // Initialize shape positions, sizes, speeds, etc.
  122.   }
  123.  
  124.   void initializeShapes() {
  125.     for (int i=0; i<numShapes; i++) {
  126.       x[i] = random(width);  // Random horizontal position(rhythm/time)
  127.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  128.       sizes[i] = random(5, 30);  // Articulation(size) reflecting dynamics
  129.       lifeSpan[i] = random(30, 150);  // Random life span for rhythmic events
  130.       speeds[i] = random(0.5, 2.5);  // Random speed for rhythm variation
  131.       colors[i] = color(random(255), random(255), random(255), 150);  // Dynamic color(timbre)
  132.     }
  133.   }
  134.  
  135.   void draw() {
  136.     background(0, 50);  // A slightly fading background for smooth transitions
  137.  
  138.     for (int i=0; i<numShapes; i++) {
  139.       if (lifeSpan[i] > 0) {
  140.         // Apply articulation, pitch, and timbre to each shape
  141.         fill(colors[i]);
  142.         ellipse(x[i], y[i], sizes[i], sizes[i]);  // Drawing an ellipse representing the sound gesture
  143.  
  144.         // Update movement and life span(reflecting dynamic rhythm and articulation)
  145.         x[i] += random(-speeds[i], speeds[i]);  // Movement represents slight rhythmic instability
  146.         y[i] += random(-0.5, 0.5);  // Slight fluctuations in pitch(micro-variations)
  147.         sizes[i] += random(-0.2, 0.2);  // Subtle size changes(dynamics in articulation)
  148.         lifeSpan[i] -= 1;  // Gradual fade-out of shape(decay of sound gesture)
  149.       } else {
  150.         // Respawn the shape with new properties(like a new note or articulation)
  151.         x[i] = random(width);
  152.         y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  153.         sizes[i] = random(5, 30);  // New articulation size
  154.         lifeSpan[i] = random(30, 150);  // Reset life span
  155.         speeds[i] = random(0.5, 2.5);  // Reset speed for rhythm variation
  156.         colors[i] = color(random(255), random(255), random(255), 150);  // New timbre color
  157.       }
  158.     }
  159.     // Occasionally draw additional lines or structures to represent complex textures
  160.     if (frameCount % 50 == 0) {
  161.       stroke(255, 100);  // Lines in white, semi-transparent
  162.       line(random(width), random(height), random(width), random(height));  // Random lines representing texture
  163.       noStroke();
  164.     }
  165.   }
  166. }
  167. class Visualization4 extends Visualization {
  168.   // Processing Sound-Painting with 3-6 Voices
  169.   // Pointillism applied to Rhythm, Pitch, and Articulation(3-6 simultaneous gestures)
  170.  
  171.   int maxVoices = 6;  // Maximum number of active voices at a time
  172.   float[] x = new float[maxVoices];  // X positions for each shape
  173.   float[] y = new float[maxVoices];  // Y positions for each shape(pitch)
  174.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  175.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  176.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  177.   color[] colors = new color[maxVoices];  // Color representing timbre
  178.  
  179.   void setup() {
  180.     size(800, 800);
  181.     frameRate(30);
  182.     noStroke();
  183.     initializeVoices();  // Initialize positions, sizes, speeds, etc.
  184.   }
  185.  
  186.   void initializeVoices() {
  187.     for (int i=0; i<maxVoices; i++) {
  188.       x[i] = random(width);  // Random horizontal position(time/rhythm)
  189.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  190.       sizes[i] = random(20, 50);  // Larger articulation(size) representing dynamics
  191.       lifeSpan[i] = random(50, 150);  // Life span for rhythmic events
  192.       speeds[i] = random(1, 3);  // Random speed for rhythm variation
  193.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  194.     }
  195.   }
  196.  
  197.   void draw() {
  198.     background(0, 50);  // Fading background for smooth transitions
  199.  
  200.     // Loop through all active voices and update them
  201.     for (int i=0; i<maxVoices; i++) {
  202.       if (lifeSpan[i] > 0) {
  203.         // Draw shapes(voices) representing individual sounds
  204.         fill(colors[i]);
  205.         ellipse(x[i], y[i], sizes[i], sizes[i]);  // Drawing an ellipse representing the sound gesture
  206.  
  207.         // Update movement, articulation, and life span
  208.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  209.         y[i] += random(-0.5, 0.5);  // Micro variations in pitch
  210.         sizes[i] += random(-0.2, 0.2);  // Subtle size changes for articulation
  211.         lifeSpan[i] -= 1;  // Reduce lifespan for fading out
  212.  
  213.       } else {
  214.         // When a voice finishes, respawn it with new properties
  215.         x[i] = random(width);  // New position for rhythm
  216.         y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  217.         sizes[i] = random(20, 50);  // New articulation size
  218.         lifeSpan[i] = random(50, 150);  // New lifespan
  219.         speeds[i] = random(1, 3);  // New speed for rhythm variation
  220.         colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  221.       }
  222.     }
  223.     // Occasionally add lines to represent musical texture
  224.     if (frameCount % 100 == 0) {
  225.       stroke(255, 150);  // Semi-transparent white lines for texture
  226.       line(random(width), random(height), random(width), random(height));  // Random lines as accents
  227.       noStroke();
  228.     }
  229.   }
  230. }
  231. class Visualization5 extends Visualization {
  232.   // Processing Visual Texture inspired by "Iron Circle" Aesthetic
  233.   // Includes ovals, rectangles, and lines representing short and long notes
  234.  
  235.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  236.   float[] x = new float[maxVoices];  // X positions for shapes
  237.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  238.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  239.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  240.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  241.   color[] colors = new color[maxVoices];  // Colors representing timbre
  242.  
  243.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  244.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  245.  
  246.   void setup() {
  247.     size(800, 800);
  248.     frameRate(30);
  249.     noStroke();
  250.     initializeVoices();  // Initialize shapes' positions, sizes, and other properties
  251.   }
  252.  
  253.   void initializeVoices() {
  254.     for (int i=0; i<maxVoices; i++) {
  255.       x[i] = random(width);  // Random X position(time/rhythm)
  256.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  257.       sizes[i] = random(20, 50);  // Articulation(size) representing dynamics
  258.       lifeSpan[i] = random(50, 150);  // Random lifespan for rhythmic variation
  259.       speeds[i] = random(1, 3);  // Random speed for rhythm variation
  260.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  261.  
  262.       // Randomly determine whether the shape is a rectangle or an oval
  263.       isRect[i] = random(1) > 0.5;
  264.  
  265.       // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  266.       isLongNote[i] = random(1) > 0.5;
  267.       if (isLongNote[i]) {
  268.         lifeSpan[i] += 100;  // Extend the lifespan for longer notes
  269.       }
  270.     }
  271.   }
  272.  
  273.   void draw() {
  274.     background(0, 50);  // Fading background for smooth transitions
  275.  
  276.     // Draw lines for layered transitions or texture, appearing every few frames
  277.     if (frameCount % 50 == 0) {
  278.       stroke(255, 100);  // White semi-transparent lines
  279.       line(random(width), random(height), random(width), random(height));  // Random lines as textural transitions
  280.       noStroke();
  281.     }
  282.     // Loop through all active shapes(voices)
  283.     for (int i=0; i<maxVoices; i++) {
  284.       if (lifeSpan[i] > 0) {
  285.         // Draw rectangles for sharp attacks or ovals for smooth articulations
  286.         fill(colors[i]);
  287.         if (isRect[i]) {
  288.           rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for more structured, mechanical sound
  289.         } else {
  290.           ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  291.         }
  292.         // Update movement, articulation, and life span
  293.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  294.         y[i] += random(-0.5, 0.5);  // Micro-variations in pitch
  295.         sizes[i] += random(-0.2, 0.2);  // Subtle size changes for articulation
  296.         lifeSpan[i] -= 1;  // Reduce lifespan to fade out
  297.  
  298.       } else {
  299.         // When a shape finishes, respawn it with new properties
  300.         x[i] = random(width);  // New position(time/rhythm)
  301.         y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  302.         sizes[i] = random(20, 50);  // New articulation size
  303.         lifeSpan[i] = random(50, 150);  // New lifespan
  304.         speeds[i] = random(1, 3);  // New speed for rhythm variation
  305.         colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  306.  
  307.         // Reassign shape type and note length
  308.         isRect[i] = random(1) > 0.5;
  309.         isLongNote[i] = random(1) > 0.5;
  310.         if (isLongNote[i]) {
  311.           lifeSpan[i] += 100;  // Extend lifespan for longer notes
  312.         }
  313.       }
  314.     }
  315.   }
  316. }
  317. class Visualization6 extends Visualization {
  318.   // Processing Visual Texture inspired by "Iron Circle" Aesthetic
  319.   // Includes variable sizes, faster tempo, and combination of ovals, rectangles, and lines
  320.  
  321.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  322.   float[] x = new float[maxVoices];  // X positions for shapes
  323.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  324.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  325.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  326.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  327.   color[] colors = new color[maxVoices];  // Colors representing timbre
  328.  
  329.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  330.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  331.  
  332.   void setup() {
  333.     size(800, 800);
  334.     frameRate(45);  // Faster frame rate to accelerate the tempo
  335.     noStroke();
  336.     initializeVoices();  // Initialize shapes' positions, sizes, and other properties
  337.   }
  338.  
  339.   void initializeVoices() {
  340.     for (int i=0; i<maxVoices; i++) {
  341.       x[i] = random(width);  // Random X position(time/rhythm)
  342.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  343.       sizes[i] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  344.       lifeSpan[i] = random(30, 100);  // Shorter life spans for faster tempo
  345.       speeds[i] = random(2, 6);  // Faster movement for increased tempo
  346.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  347.  
  348.       // Randomly determine whether the shape is a rectangle or an oval
  349.       isRect[i] = random(1) > 0.5;
  350.  
  351.       // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  352.       isLongNote[i] = random(1) > 0.5;
  353.       if (isLongNote[i]) {
  354.         lifeSpan[i] += 50;  // Extend lifespan for some longer notes, but still faster overall
  355.       }
  356.     }
  357.   }
  358.  
  359.   void draw() {
  360.     background(0, 70);  // Fading background but slightly faster to keep up with the tempo
  361.  
  362.     // Draw lines for layered transitions or texture, appearing every few frames
  363.     if (frameCount % 40 == 0) {
  364.       stroke(255, 100);  // White semi-transparent lines
  365.       line(random(width), random(height), random(width), random(height));  // Random lines as textural transitions
  366.       noStroke();
  367.     }
  368.     // Loop through all active shapes(voices)
  369.     for (int i=0; i<maxVoices; i++) {
  370.       if (lifeSpan[i] > 0) {
  371.         // Draw rectangles for sharp attacks or ovals for smooth articulations
  372.         fill(colors[i]);
  373.         if (isRect[i]) {
  374.           rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for more structured, mechanical sound
  375.         } else {
  376.           ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  377.         }
  378.         // Update movement, articulation, and life span
  379.         x[i] += random(-speeds[i], speeds[i]);  // Faster rhythmic movement
  380.         y[i] += random(-1, 1);  // Micro-variations in pitch(slightly faster)
  381.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation(quicker)
  382.         lifeSpan[i] -= 2;  // Reduce lifespan faster to keep up with tempo
  383.  
  384.       } else {
  385.         // When a shape finishes, respawn it with new properties
  386.         x[i] = random(width);  // New position(time/rhythm)
  387.         y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  388.         sizes[i] = random(10, 100);  // New articulation size(variable sizes for more contrast)
  389.         lifeSpan[i] = random(30, 100);  // Shorter lifespan for quicker tempo
  390.         speeds[i] = random(2, 6);  // Faster speed for rhythmic variation
  391.         colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  392.  
  393.         // Reassign shape type and note length
  394.         isRect[i] = random(1) > 0.5;
  395.         isLongNote[i] = random(1) > 0.5;
  396.         if (isLongNote[i]) {
  397.           lifeSpan[i] += 50;  // Longer lifespan for some notes, but still balanced for faster tempo
  398.         }
  399.       }
  400.     }
  401.   }
  402. }
  403. class Visualization7 extends Visualization {
  404.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  405.   float[] x = new float[maxVoices];  // X positions for shapes
  406.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  407.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  408.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  409.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  410.   color[] colors = new color[maxVoices];  // Colors representing timbre
  411.  
  412.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  413.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  414.  
  415.   float tempo;  // Global tempo in milliseconds
  416.   float lastUpdateTime;  // Last update time
  417.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  418.  
  419.   void setup() {
  420.     size(800, 800);
  421.     noStroke();
  422.     initializeVoices();  // Initialize shapes' positions, sizes, and other properties
  423.     lastUpdateTime = millis();  // Initialize the last update time
  424.   }
  425.  
  426.   void initializeVoices() {
  427.     for (int i=0; i<maxVoices; i++) {
  428.       x[i] = random(width);  // Random X position(time/rhythm)
  429.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  430.       sizes[i] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  431.       lifeSpan[i] = random(30, 100);  // Lifespan for shapes
  432.       speeds[i] = random(2, 6);  // Speed of movement for rhythm variation
  433.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  434.  
  435.       // Randomly determine whether the shape is a rectangle or an oval
  436.       isRect[i] = random(1) > 0.5;
  437.  
  438.       // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  439.       isLongNote[i] = random(1) > 0.5;
  440.       if (isLongNote[i]) {
  441.         lifeSpan[i] += 50;  // Extend lifespan for some longer notes
  442.       }
  443.     }
  444.   }
  445.  
  446.   void draw() {
  447.     // Calculate the global tempo and apply it
  448.     float currentTime = millis();
  449.     if (currentTime - lastUpdateTime >= tempo) {
  450.       lastUpdateTime = currentTime;
  451.  
  452.       // Draw motion blur effect by overlaying a semi-transparent background
  453.       fill(0, feedbackAlpha);  // Background with some transparency
  454.       rect(0, 0, width, height);
  455.  
  456.       // Loop through all active shapes(voices)
  457.       for (int i=0; i<maxVoices; i++) {
  458.         if (lifeSpan[i] > 0) {
  459.           // Draw rectangles for sharp attacks or ovals for smooth articulations
  460.           fill(colors[i]);
  461.           if (isRect[i]) {
  462.             rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for more structured, mechanical sound
  463.           } else {
  464.             ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  465.           }
  466.           // Update movement, articulation, and life span
  467.           x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  468.           y[i] += random(-1, 1);  // Micro-variations in pitch
  469.           sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  470.           lifeSpan[i] -= 2;  // Reduce lifespan to fade out
  471.  
  472.         } else {
  473.           // When a shape finishes, respawn it with new properties
  474.           x[i] = random(width);  // New position(time/rhythm)
  475.           y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  476.           sizes[i] = random(10, 100);  // New articulation size
  477.           lifeSpan[i] = random(30, 100);  // New lifespan
  478.           speeds[i] = random(2, 6);  // New speed for rhythmic variation
  479.           colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  480.  
  481.           // Reassign shape type and note length
  482.           isRect[i] = random(1) > 0.5;
  483.           isLongNote[i] = random(1) > 0.5;
  484.           if (isLongNote[i]) {
  485.             lifeSpan[i] += 50;  // Longer lifespan for some notes, but balanced for faster tempo
  486.           }
  487.         }
  488.       }
  489.       // Update global tempo with random fluctuation
  490.       tempo = random(21000, 46700);  // Tempo in milliseconds(21 to 46.7 seconds)
  491.     }
  492.   }
  493. }
  494. class Visualization8 extends Visualization {
  495.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  496.   float[] x = new float[maxVoices];  // X positions for shapes
  497.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  498.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  499.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  500.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  501.   color[] colors = new color[maxVoices];  // Colors representing timbre
  502.  
  503.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  504.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  505.  
  506.   float spawnInterval;  // Interval for spawning new shapes in milliseconds
  507.   float lastSpawnTime;  // Last time a new shape was spawned
  508.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  509.  
  510.   void setup() {
  511.     size(800, 800);
  512.     noStroke();
  513.     initializeVoices();  // Initialize shapes' properties
  514.     lastSpawnTime = millis();  // Initialize the last spawn time
  515.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  516.   }
  517.  
  518.   void initializeVoices() {
  519.     for (int i=0; i<maxVoices; i++) {
  520.       x[i] = random(width);  // Random X position(time/rhythm)
  521.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  522.       sizes[i] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  523.       lifeSpan[i] = random(30, 100);  // Lifespan for shapes
  524.       speeds[i] = random(2, 6);  // Speed of movement for rhythm variation
  525.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  526.  
  527.       // Randomly determine whether the shape is a rectangle or an oval
  528.       isRect[i] = random(1) > 0.5;
  529.  
  530.       // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  531.       isLongNote[i] = random(1) > 0.5;
  532.       if (isLongNote[i]) {
  533.         lifeSpan[i] += 50;  // Extend lifespan for some longer notes
  534.       }
  535.     }
  536.   }
  537.  
  538.   void draw() {
  539.     // Draw motion blur effect by overlaying a semi-transparent background
  540.     fill(0, feedbackAlpha);  // Background with some transparency
  541.     rect(0, 0, width, height);
  542.  
  543.     // Current time for tempo management
  544.     float currentTime = millis();
  545.  
  546.     // Check if it's time to spawn a new shape
  547.     if (currentTime - lastSpawnTime >= spawnInterval) {
  548.       // Spawn new shapes
  549.       for (int i=0; i<maxVoices; i++) {
  550.         if (lifeSpan[i] <= 0) {
  551.           // Replace expired shapes
  552.           x[i] = random(width);  // New X position(time/rhythm)
  553.           y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  554.           sizes[i] = random(10, 100);  // New articulation size
  555.           lifeSpan[i] = random(30, 100);  // New lifespan
  556.           speeds[i] = random(2, 6);  // New speed for rhythmic variation
  557.           colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  558.  
  559.           // Reassign shape type and note length
  560.           isRect[i] = random(1) > 0.5;
  561.           isLongNote[i] = random(1) > 0.5;
  562.           if (isLongNote[i]) {
  563.             lifeSpan[i] += 50;  // Longer lifespan for some notes
  564.           }
  565.         }
  566.       }
  567.       // Update the last spawn time and set a new random spawn interval
  568.       lastSpawnTime = currentTime;
  569.       spawnInterval = random(21000, 46700);  // New spawn interval(21 to 46.7 seconds)
  570.     }
  571.     // Loop through all active shapes(voices)
  572.     for (int i=0; i<maxVoices; i++) {
  573.       if (lifeSpan[i] > 0) {
  574.         // Draw rectangles for sharp attacks or ovals for smooth articulations
  575.         fill(colors[i]);
  576.         if (isRect[i]) {
  577.           rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for structured, mechanical sound
  578.         } else {
  579.           ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  580.         }
  581.         // Update movement, articulation, and life span
  582.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  583.         y[i] += random(-1, 1);  // Micro-variations in pitch
  584.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  585.         lifeSpan[i] -= 2;  // Reduce lifespan to fade out
  586.       }
  587.     }
  588.   }
  589. }
  590. class Visualization9 extends Visualization {
  591.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  592.   float[] x = new float[maxVoices];  // X positions for shapes
  593.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  594.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  595.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  596.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  597.   color[] colors = new color[maxVoices];  // Colors representing timbre
  598.  
  599.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  600.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  601.  
  602.   float spawnInterval;  // Interval for spawning new shapes in milliseconds
  603.   float lastSpawnTime;  // Last time a new shape was spawned
  604.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  605.  
  606.   void setup() {
  607.     size(800, 800);
  608.     noStroke();
  609.     initializeVoices();  // Initialize shapes' properties
  610.     lastSpawnTime = millis();  // Initialize the last spawn time
  611.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  612.   }
  613.  
  614.   void initializeVoices() {
  615.     for (int i=0; i<maxVoices; i++) {
  616.       x[i] = random(width);  // Random X position(time/rhythm)
  617.       y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  618.       sizes[i] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  619.       lifeSpan[i] = random(3000, 10000);  // Lifespan for shapes(3 to 10 seconds)
  620.       speeds[i] = random(2, 6);  // Speed of movement for rhythm variation
  621.       colors[i] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  622.  
  623.       // Randomly determine whether the shape is a rectangle or an oval
  624.       isRect[i] = random(1) > 0.5;
  625.  
  626.       // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  627.       isLongNote[i] = random(1) > 0.5;
  628.       if (isLongNote[i]) {
  629.         lifeSpan[i] += 5000;  // Extend lifespan for some longer notes
  630.       }
  631.     }
  632.   }
  633.  
  634.   void draw() {
  635.     // Draw motion blur effect by overlaying a semi-transparent background
  636.     fill(0, feedbackAlpha);  // Background with some transparency
  637.     rect(0, 0, width, height);
  638.  
  639.     // Current time for tempo management
  640.     float currentTime = millis();
  641.  
  642.     // Check if it's time to spawn a new shape
  643.     if (currentTime - lastSpawnTime >= spawnInterval) {
  644.       // Spawn new shapes
  645.       for (int i=0; i<maxVoices; i++) {
  646.         if (lifeSpan[i] <= 0) {
  647.           // Replace expired shapes
  648.           x[i] = random(width);  // New X position(time/rhythm)
  649.           y[i] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // New pitch
  650.           sizes[i] = random(10, 100);  // New articulation size
  651.           lifeSpan[i] = random(3000, 10000);  // New lifespan(3 to 10 seconds)
  652.           speeds[i] = random(2, 6);  // New speed for rhythmic variation
  653.           colors[i] = color(random(255), random(255), random(255), 200);  // New timbre color
  654.  
  655.           // Reassign shape type and note length
  656.           isRect[i] = random(1) > 0.5;
  657.           isLongNote[i] = random(1) > 0.5;
  658.           if (isLongNote[i]) {
  659.             lifeSpan[i] += 5000;  // Longer lifespan for some notes
  660.           }
  661.         }
  662.       }
  663.       // Update the last spawn time and set a new random spawn interval
  664.       lastSpawnTime = currentTime;
  665.       spawnInterval = random(21000, 46700);  // New spawn interval(21 to 46.7 seconds)
  666.     }
  667.     // Loop through all active shapes(voices)
  668.     for (int i=0; i<maxVoices; i++) {
  669.       if (lifeSpan[i] > 0) {
  670.         // Draw rectangles for sharp attacks or ovals for smooth articulations
  671.         fill(colors[i]);
  672.         if (isRect[i]) {
  673.           rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for structured, mechanical sound
  674.         } else {
  675.           ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  676.         }
  677.         // Update movement, articulation, and life span
  678.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  679.         y[i] += random(-1, 1);  // Micro-variations in pitch
  680.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  681.         lifeSpan[i] -=(millis() - lastSpawnTime) /(float)spawnInterval * 2;  // Gradual reduction based on spawn interval
  682.       }
  683.     }
  684.   }
  685. }
  686. class Visualization10 extends Visualization {
  687.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  688.   float[] x = new float[maxVoices];  // X positions for shapes
  689.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  690.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  691.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  692.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  693.   color[] colors = new color[maxVoices];  // Colors representing timbre
  694.  
  695.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  696.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  697.  
  698.   float spawnInterval;  // Interval for spawning new shapes in milliseconds
  699.   float lastSpawnTime;  // Last time a new shape was spawned
  700.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  701.  
  702.   int currentAlgorithm = 0;  // Index for the current visual algorithm
  703.   int algorithmChangeInterval = 60000;  // Time interval to change algorithm(60 seconds)
  704.   float lastAlgorithmChangeTime;  // Last time the algorithm was changed
  705.  
  706.   void setup() {
  707.     size(800, 800);
  708.     noStroke();
  709.     initializeVoices();  // Initialize shapes' properties
  710.     lastSpawnTime = millis();  // Initialize the last spawn time
  711.     lastAlgorithmChangeTime = millis();  // Initialize algorithm change time
  712.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  713.   }
  714.  
  715.   void initializeVoices() {
  716.     for (int i=0; i<maxVoices; i++) {
  717.       resetVoice(i);  // Initialize or reset each shape
  718.     }
  719.   }
  720.  
  721.   void resetVoice(int index) {
  722.     x[index] = random(width);  // Random X position(time/rhythm)
  723.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  724.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  725.     lifeSpan[index] = random(3000, 10000);  // Lifespan for shapes(3 to 10 seconds)
  726.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  727.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  728.  
  729.     // Randomly determine whether the shape is a rectangle or an oval
  730.     isRect[index] = random(1) > 0.5;
  731.  
  732.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  733.     isLongNote[index] = random(1) > 0.5;
  734.     if (isLongNote[index]) {
  735.       lifeSpan[index] += 5000;  // Extend lifespan for some longer notes
  736.     }
  737.   }
  738.  
  739.   void draw() {
  740.     // Draw motion blur effect by overlaying a semi-transparent background
  741.     fill(0, feedbackAlpha);  // Background with some transparency
  742.     rect(0, 0, width, height);
  743.  
  744.     // Current time for tempo management
  745.     float currentTime = millis();
  746.  
  747.     // Check if it's time to spawn a new shape
  748.     if (currentTime - lastSpawnTime >= spawnInterval) {
  749.       // Spawn new shapes
  750.       for (int i=0; i<maxVoices; i++) {
  751.         if (lifeSpan[i] <= 0) {
  752.           // Replace expired shapes
  753.           resetVoice(i);  // Initialize new shape
  754.         }
  755.       }
  756.       // Update the last spawn time and set a new random spawn interval
  757.       lastSpawnTime = currentTime;
  758.       spawnInterval = random(21000, 46700);  // New spawn interval(21 to 46.7 seconds)
  759.     }
  760.     // Loop through all active shapes(voices)
  761.     for (int i=0; i<maxVoices; i++) {
  762.       if (lifeSpan[i] > 0) {
  763.         // Draw rectangles for sharp attacks or ovals for smooth articulations
  764.         fill(colors[i]);
  765.         if (isRect[i]) {
  766.           rect(x[i], y[i], sizes[i], sizes[i]);  // Rectangle for structured, mechanical sound
  767.         } else {
  768.           ellipse(x[i], y[i], sizes[i], sizes[i]);  // Oval for smoother, evolving sounds
  769.         }
  770.         // Update movement, articulation, and life span
  771.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  772.         y[i] += random(-1, 1);  // Micro-variations in pitch
  773.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  774.         lifeSpan[i] -=(millis() - lastSpawnTime) /(float)spawnInterval * 2;  // Gradual reduction based on spawn interval
  775.       }
  776.     }
  777.     // Check if it's time to change the visual algorithm
  778.     if (currentTime - lastAlgorithmChangeTime >= algorithmChangeInterval) {
  779.       changeAlgorithm();  // Apply a new algorithm
  780.       lastAlgorithmChangeTime = currentTime;  // Update the last algorithm change time
  781.     }
  782.   }
  783.  
  784.   void changeAlgorithm() {
  785.     // Example of algorithm change: Randomly select a new algorithm for shape behavior
  786.     currentAlgorithm =(currentAlgorithm + 1) % 3;  // Cycle through 3 algorithms
  787.  
  788.     switch(currentAlgorithm) {
  789.       case 0: // Algorithm 1: Basic shapes
  790.       println("Applying Algorithm 1: Basic Shapes");
  791.       // Set properties for Algorithm 1
  792.       break;
  793.       case 1: // Algorithm 2: More dynamic shapes
  794.       println("Applying Algorithm 2: Dynamic Shapes");
  795.       // Set properties for Algorithm 2
  796.       break;
  797.       case 2: // Algorithm 3: Complex shapes with varying attributes
  798.       println("Applying Algorithm 3: Complex Shapes");
  799.       // Set properties for Algorithm 3
  800.       break;
  801.     }
  802.   }
  803. }
  804. class Visualization11 extends Visualization {
  805.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  806.   float[] x = new float[maxVoices];  // X positions for shapes
  807.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  808.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  809.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  810.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  811.   color[] colors = new color[maxVoices];  // Colors representing timbre
  812.  
  813.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  814.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  815.  
  816.   float spawnInterval;  // Interval for spawning new shapes in milliseconds
  817.   float lastSpawnTime;  // Last time a new shape was spawned
  818.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  819.  
  820.   // Algorithm parameters
  821.   int currentAlgorithm = 0;
  822.   float algorithmChangeInterval = 60000;  // Time interval to change algorithm(60 seconds)
  823.   float lastAlgorithmChangeTime;  // Last time the algorithm was changed
  824.  
  825.   // Algorithm functions
  826.  
  827.   void setup() {
  828.     size(800, 800);
  829.     noStroke();
  830.     initializeVoices();  // Initialize shapes' properties
  831.     lastSpawnTime = millis();  // Initialize the last spawn time
  832.     lastAlgorithmChangeTime = millis();  // Initialize algorithm change time
  833.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  834.     generateNewAlgorithm();  // Generate the initial algorithm
  835.   }
  836.  
  837.   void initializeVoices() {
  838.     for (int i=0; i<maxVoices; i++) {
  839.       resetVoice(i);  // Initialize or reset each shape
  840.     }
  841.   }
  842.  
  843.   void resetVoice(int index) {
  844.     x[index] = random(width);  // Random X position(time/rhythm)
  845.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  846.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  847.     lifeSpan[index] = random(3000, 10000);  // Lifespan for shapes(3 to 10 seconds)
  848.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  849.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  850.  
  851.     // Randomly determine whether the shape is a rectangle or an oval
  852.     isRect[index] = random(1) > 0.5;
  853.  
  854.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  855.     isLongNote[index] = random(1) > 0.5;
  856.     if (isLongNote[index]) {
  857.       lifeSpan[index] += 5000;  // Extend lifespan for some longer notes
  858.     }
  859.   }
  860.  
  861.   void draw() {
  862.     // Draw motion blur effect by overlaying a semi-transparent background
  863.     fill(0, feedbackAlpha);  // Background with some transparency
  864.     rect(0, 0, width, height);
  865.  
  866.     // Current time for tempo management
  867.     float currentTime = millis();
  868.  
  869.     // Check if it's time to spawn a new shape
  870.     if (currentTime - lastSpawnTime >= spawnInterval) {
  871.       // Spawn new shapes
  872.       for (int i=0; i<maxVoices; i++) {
  873.         if (lifeSpan[i] <= 0) {
  874.           // Replace expired shapes
  875.           resetVoice(i);  // Initialize new shape
  876.         }
  877.       }
  878.       // Update the last spawn time and set a new random spawn interval
  879.       lastSpawnTime = currentTime;
  880.       spawnInterval = random(21000, 46700);  // New spawn interval(21 to 46.7 seconds)
  881.     }
  882.     // Loop through all active shapes(voices)
  883.     for (int i=0; i<maxVoices; i++) {
  884.       if (lifeSpan[i] > 0) {
  885.         // Apply the current algorithm to draw shapes
  886.         applyAlgorithm(i);
  887.  
  888.         // Update movement, articulation, and life span
  889.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  890.         y[i] += random(-1, 1);  // Micro-variations in pitch
  891.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  892.         lifeSpan[i] -=(millis() - lastSpawnTime) /(float)spawnInterval * 2;  // Gradual reduction based on spawn interval
  893.       }
  894.     }
  895.     // Check if it's time to generate a new algorithm
  896.     if (currentTime - lastAlgorithmChangeTime >= algorithmChangeInterval) {
  897.       generateNewAlgorithm();  // Generate a new algorithm
  898.       lastAlgorithmChangeTime = currentTime;  // Update the last algorithm change time
  899.     }
  900.   }
  901.  
  902.   void generateNewAlgorithm() {
  903.     // Generate a new algorithm function
  904.     currentAlgorithm =(int)random(0, 3);  // Randomly select an algorithm(0, 1, or 2)
  905.     println("Generated Algorithm: " + currentAlgorithm);
  906.   }
  907.  
  908.   void applyAlgorithm(int index) {
  909.     // Apply the generated algorithm to shape drawing
  910.  
  911.     switch(currentAlgorithm) {
  912.       case 0: // Example of Algorithm 0: Basic Shapes
  913.       fill(colors[index]);
  914.       if (isRect[index]) {
  915.         rect(x[index], y[index], sizes[index], sizes[index]);
  916.       } else {
  917.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  918.       }
  919.       break;
  920.       case 1: // Example of Algorithm 1: Dynamic Sizes
  921.       fill(colors[index]);
  922.       if (isRect[index]) {
  923.         rect(x[index], y[index], sizes[index], sizes[index] * 1.5);  // Change size dynamically
  924.       } else {
  925.         ellipse(x[index], y[index], sizes[index] * 1.5, sizes[index] * 0.5);  // Ellipse with dynamic size
  926.       }
  927.       break;
  928.       case 2: // Example of Algorithm 2: Variable Opacity
  929.       fill(colors[index], random(100, 255));  // Variable opacity
  930.       if (isRect[index]) {
  931.         rect(x[index], y[index], sizes[index], sizes[index]);
  932.       } else {
  933.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  934.       }
  935.       break;
  936.     }
  937.   }
  938. }
  939. class Visualization12 extends Visualization {
  940.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  941.   float[] x = new float[maxVoices];  // X positions for shapes
  942.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  943.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  944.   float[] lifeSpan = new float[maxVoices];  // Life span of each shape
  945.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  946.   color[] colors = new color[maxVoices];  // Colors representing timbre
  947.  
  948.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  949.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  950.  
  951.   float spawnInterval;  // Interval for spawning new shapes in milliseconds
  952.   float[] spawnTimes = new float[maxVoices];  // Times at which shapes should respawn
  953.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  954.  
  955.   // Algorithm parameters
  956.   int currentAlgorithm = 0;
  957.   float algorithmChangeInterval = 60000;  // Time interval to change algorithm(60 seconds)
  958.   float lastAlgorithmChangeTime;  // Last time the algorithm was changed
  959.  
  960.   void setup() {
  961.     size(800, 800);
  962.     noStroke();
  963.     initializeVoices();  // Initialize shapes' properties
  964.     lastAlgorithmChangeTime = millis();  // Initialize algorithm change time
  965.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  966.     generateNewAlgorithm();  // Generate the initial algorithm
  967.   }
  968.  
  969.   void initializeVoices() {
  970.     for (int i=0; i<maxVoices; i++) {
  971.       resetVoice(i);  // Initialize or reset each shape
  972.       spawnTimes[i] = millis();  // Initialize spawn time for each shape
  973.     }
  974.   }
  975.  
  976.   void resetVoice(int index) {
  977.     x[index] = random(width);  // Random X position(time/rhythm)
  978.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  979.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  980.     lifeSpan[index] = random(3000, 10000);  // Lifespan for shapes(3 to 10 seconds)
  981.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  982.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  983.  
  984.     // Randomly determine whether the shape is a rectangle or an oval
  985.     isRect[index] = random(1) > 0.5;
  986.  
  987.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  988.     isLongNote[index] = random(1) > 0.5;
  989.     if (isLongNote[index]) {
  990.       lifeSpan[index] += 5000;  // Extend lifespan for some longer notes
  991.     }
  992.   }
  993.  
  994.   void draw() {
  995.     // Draw motion blur effect by overlaying a semi-transparent background
  996.     fill(0, feedbackAlpha);  // Background with some transparency
  997.     rect(0, 0, width, height);
  998.  
  999.     // Current time for tempo management
  1000.     float currentTime = millis();
  1001.  
  1002.     // Loop through all active shapes(voices)
  1003.     for (int i=0; i<maxVoices; i++) {
  1004.       // Check if it's time to respawn or if the shape is still active
  1005.       if (currentTime - spawnTimes[i] >= spawnInterval) {
  1006.         // Reset shape if it has expired
  1007.         resetVoice(i);
  1008.         spawnTimes[i] = currentTime;  // Update the spawn time for the shape
  1009.       }
  1010.       if (currentTime - spawnTimes[i] <= lifeSpan[i]) {
  1011.         // Apply the current algorithm to draw shapes
  1012.         applyAlgorithm(i);
  1013.  
  1014.         // Update movement, articulation, and life span
  1015.         x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  1016.         y[i] += random(-1, 1);  // Micro-variations in pitch
  1017.         sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  1018.       }
  1019.     }
  1020.     // Check if it's time to generate a new algorithm
  1021.     if (currentTime - lastAlgorithmChangeTime >= algorithmChangeInterval) {
  1022.       generateNewAlgorithm();  // Generate a new algorithm
  1023.       lastAlgorithmChangeTime = currentTime;  // Update the last algorithm change time
  1024.     }
  1025.   }
  1026.  
  1027.   void generateNewAlgorithm() {
  1028.     // Generate a new algorithm function
  1029.     currentAlgorithm =(int)random(0, 3);  // Randomly select an algorithm(0, 1, or 2)
  1030.     println("Generated Algorithm: " + currentAlgorithm);
  1031.   }
  1032.  
  1033.   void applyAlgorithm(int index) {
  1034.     // Apply the generated algorithm to shape drawing
  1035.  
  1036.     switch(currentAlgorithm) {
  1037.       case 0: // Example of Algorithm 0: Basic Shapes
  1038.       fill(colors[index]);
  1039.       if (isRect[index]) {
  1040.         rect(x[index], y[index], sizes[index], sizes[index]);
  1041.       } else {
  1042.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1043.       }
  1044.       break;
  1045.       case 1: // Example of Algorithm 1: Dynamic Sizes
  1046.       fill(colors[index]);
  1047.       if (isRect[index]) {
  1048.         rect(x[index], y[index], sizes[index], sizes[index] * 1.5);  // Change size dynamically
  1049.       } else {
  1050.         ellipse(x[index], y[index], sizes[index] * 1.5, sizes[index] * 0.5);  // Ellipse with dynamic size
  1051.       }
  1052.       break;
  1053.       case 2: // Example of Algorithm 2: Variable Opacity
  1054.       fill(colors[index], random(100, 255));  // Variable opacity
  1055.       if (isRect[index]) {
  1056.         rect(x[index], y[index], sizes[index], sizes[index]);
  1057.       } else {
  1058.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1059.       }
  1060.       break;
  1061.     }
  1062.   }
  1063. }
  1064. class Visualization13 extends Visualization {
  1065.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  1066.   float[] x = new float[maxVoices];  // X positions for shapes
  1067.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  1068.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  1069.   float[] spawnTimes = new float[maxVoices];  // Times at which shapes should respawn
  1070.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  1071.   color[] colors = new color[maxVoices];  // Colors representing timbre
  1072.  
  1073.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  1074.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  1075.  
  1076.   float spawnInterval;  // Interval for updating shapes in milliseconds
  1077.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  1078.  
  1079.   // Algorithm parameters
  1080.   int currentAlgorithm = 0;
  1081.   float algorithmChangeInterval = 60000;  // Time interval to change algorithm(60 seconds)
  1082.   float lastAlgorithmChangeTime;  // Last time the algorithm was changed
  1083.  
  1084.   void setup() {
  1085.     size(800, 800);
  1086.     noStroke();
  1087.     initializeVoices();  // Initialize shapes' properties
  1088.     lastAlgorithmChangeTime = millis();  // Initialize algorithm change time
  1089.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  1090.     generateNewAlgorithm();  // Generate the initial algorithm
  1091.   }
  1092.  
  1093.   void initializeVoices() {
  1094.     for (int i=0; i<maxVoices; i++) {
  1095.       resetVoice(i);  // Initialize or reset each shape
  1096.       spawnTimes[i] = millis();  // Initialize spawn time for each shape
  1097.     }
  1098.   }
  1099.  
  1100.   void resetVoice(int index) {
  1101.     x[index] = random(width);  // Random X position(time/rhythm)
  1102.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  1103.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  1104.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  1105.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  1106.  
  1107.     // Randomly determine whether the shape is a rectangle or an oval
  1108.     isRect[index] = random(1) > 0.5;
  1109.  
  1110.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  1111.     isLongNote[index] = random(1) > 0.5;
  1112.   }
  1113.  
  1114.   void draw() {
  1115.     // Draw motion blur effect by overlaying a semi-transparent background
  1116.     fill(0, feedbackAlpha);  // Background with some transparency
  1117.     rect(0, 0, width, height);
  1118.  
  1119.     // Current time for tempo management
  1120.     float currentTime = millis();
  1121.  
  1122.     // Loop through all shapes(voices)
  1123.     for (int i=0; i<maxVoices; i++) {
  1124.       // Check if it's time to update the shape's position
  1125.       if (currentTime - spawnTimes[i] >= spawnInterval) {
  1126.         resetVoice(i);  // Reinitialize shape properties
  1127.         spawnTimes[i] = currentTime;  // Update the spawn time for the shape
  1128.       }
  1129.       // Apply the current algorithm to draw shapes
  1130.       applyAlgorithm(i);
  1131.  
  1132.       // Update movement and appearance
  1133.       x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  1134.       y[i] += random(-1, 1);  // Micro-variations in pitch
  1135.       sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  1136.     }
  1137.     // Check if it's time to generate a new algorithm
  1138.     if (currentTime - lastAlgorithmChangeTime >= algorithmChangeInterval) {
  1139.       generateNewAlgorithm();  // Generate a new algorithm
  1140.       lastAlgorithmChangeTime = currentTime;  // Update the last algorithm change time
  1141.     }
  1142.   }
  1143.  
  1144.   void generateNewAlgorithm() {
  1145.     // Generate a new algorithm function
  1146.     currentAlgorithm =(int)random(0, 3);  // Randomly select an algorithm(0, 1, or 2)
  1147.     println("Generated Algorithm: " + currentAlgorithm);
  1148.   }
  1149.  
  1150.   void applyAlgorithm(int index) {
  1151.     // Apply the generated algorithm to shape drawing
  1152.  
  1153.     switch(currentAlgorithm) {
  1154.       case 0: // Example of Algorithm 0: Basic Shapes
  1155.       fill(colors[index]);
  1156.       if (isRect[index]) {
  1157.         rect(x[index], y[index], sizes[index], sizes[index]);
  1158.       } else {
  1159.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1160.       }
  1161.       break;
  1162.       case 1: // Example of Algorithm 1: Dynamic Sizes
  1163.       fill(colors[index]);
  1164.       if (isRect[index]) {
  1165.         rect(x[index], y[index], sizes[index], sizes[index] * 1.5);  // Change size dynamically
  1166.       } else {
  1167.         ellipse(x[index], y[index], sizes[index] * 1.5, sizes[index] * 0.5);  // Ellipse with dynamic size
  1168.       }
  1169.       break;
  1170.       case 2: // Example of Algorithm 2: Variable Opacity
  1171.       fill(colors[index], random(100, 255));  // Variable opacity
  1172.       if (isRect[index]) {
  1173.         rect(x[index], y[index], sizes[index], sizes[index]);
  1174.       } else {
  1175.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1176.       }
  1177.       break;
  1178.     }
  1179.   }
  1180. }
  1181. class Visualization14 extends Visualization {
  1182.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  1183.   float[] x = new float[maxVoices];  // X positions for shapes
  1184.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  1185.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  1186.   float[] spawnTimes = new float[maxVoices];  // Times at which shapes should respawn
  1187.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  1188.   color[] colors = new color[maxVoices];  // Colors representing timbre
  1189.  
  1190.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  1191.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  1192.  
  1193.   float spawnInterval;  // Interval for updating shapes in milliseconds
  1194.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  1195.  
  1196.   // Algorithm parameters
  1197.   int currentAlgorithm = 0;
  1198.   float algorithmChangeInterval = 60000;  // Time interval to change algorithm(60 seconds)
  1199.   float lastAlgorithmChangeTime;  // Last time the algorithm was changed
  1200.  
  1201.   void setup() {
  1202.     size(800, 800);
  1203.     noStroke();
  1204.     initializeVoices();  // Initialize shapes' properties
  1205.     lastAlgorithmChangeTime = millis();  // Initialize algorithm change time
  1206.     spawnInterval = random(21000, 46700);  // Initial spawn interval(21 to 46.7 seconds)
  1207.     generateNewAlgorithm();  // Generate the initial algorithm
  1208.   }
  1209.  
  1210.   void initializeVoices() {
  1211.     for (int i=0; i<maxVoices; i++) {
  1212.       resetVoice(i);  // Initialize or reset each shape
  1213.       spawnTimes[i] = millis();  // Initialize spawn time for each shape
  1214.     }
  1215.   }
  1216.  
  1217.   void resetVoice(int index) {
  1218.     x[index] = random(width);  // Random X position(time/rhythm)
  1219.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  1220.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  1221.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  1222.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  1223.  
  1224.     // Randomly determine whether the shape is a rectangle or an oval
  1225.     isRect[index] = random(1) > 0.5;
  1226.  
  1227.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  1228.     isLongNote[index] = random(1) > 0.5;
  1229.   }
  1230.  
  1231.   void draw() {
  1232.     // Draw motion blur effect by overlaying a semi-transparent background
  1233.     fill(0, feedbackAlpha);  // Background with some transparency
  1234.     rect(0, 0, width, height);
  1235.  
  1236.     // Current time for tempo management
  1237.     float currentTime = millis();
  1238.  
  1239.     // Loop through all shapes(voices)
  1240.     for (int i=0; i<maxVoices; i++) {
  1241.       // Check if it's time to update the shape's position
  1242.       if (currentTime - spawnTimes[i] >= spawnInterval) {
  1243.         resetVoice(i);  // Reinitialize shape properties
  1244.         spawnTimes[i] = currentTime;  // Update the spawn time for the shape
  1245.       }
  1246.       // Apply the current algorithm to draw shapes
  1247.       applyAlgorithm(i);
  1248.  
  1249.       // Update movement and appearance
  1250.       x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  1251.       y[i] += random(-1, 1);  // Micro-variations in pitch
  1252.       sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  1253.     }
  1254.     // Check if it's time to generate a new algorithm
  1255.     if (currentTime - lastAlgorithmChangeTime >= algorithmChangeInterval) {
  1256.       generateNewAlgorithm();  // Generate a new algorithm
  1257.       lastAlgorithmChangeTime = currentTime;  // Update the last algorithm change time
  1258.     }
  1259.   }
  1260.  
  1261.   void generateNewAlgorithm() {
  1262.     // Generate a new algorithm function
  1263.     currentAlgorithm =(int)random(0, 3);  // Randomly select an algorithm(0, 1, or 2)
  1264.     println("Generated Algorithm: " + currentAlgorithm);
  1265.   }
  1266.  
  1267.   void applyAlgorithm(int index) {
  1268.     // Apply the generated algorithm to shape drawing
  1269.  
  1270.     switch(currentAlgorithm) {
  1271.       case 0: // Example of Algorithm 0: Basic Shapes
  1272.       fill(colors[index]);
  1273.       if (isRect[index]) {
  1274.         rect(x[index], y[index], sizes[index], sizes[index]);
  1275.       } else {
  1276.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1277.       }
  1278.       break;
  1279.       case 1: // Example of Algorithm 1: Dynamic Sizes
  1280.       fill(colors[index]);
  1281.       if (isRect[index]) {
  1282.         rect(x[index], y[index], sizes[index], sizes[index] * 1.5);  // Change size dynamically
  1283.       } else {
  1284.         ellipse(x[index], y[index], sizes[index] * 1.5, sizes[index] * 0.5);  // Ellipse with dynamic size
  1285.       }
  1286.       break;
  1287.       case 2: // Example of Algorithm 2: Variable Opacity
  1288.       fill(colors[index], random(100, 255));  // Variable opacity
  1289.       if (isRect[index]) {
  1290.         rect(x[index], y[index], sizes[index], sizes[index]);
  1291.       } else {
  1292.         ellipse(x[index], y[index], sizes[index], sizes[index]);
  1293.       }
  1294.       break;
  1295.     }
  1296.   }
  1297. }
  1298. class Visualization15 extends Visualization {
  1299.   int maxVoices = 6;  // Limit to 3-6 simultaneous shapes(voices)
  1300.   float[] x = new float[maxVoices];  // X positions for shapes
  1301.   float[] y = new float[maxVoices];  // Y positions for shapes(pitch)
  1302.   float[] sizes = new float[maxVoices];  // Sizes representing articulation(dynamics)
  1303.   float[] spawnTimes = new float[maxVoices];  // Times at which shapes should respawn
  1304.   float[] speeds = new float[maxVoices];  // Speed of movement for rhythm variation
  1305.   color[] colors = new color[maxVoices];  // Colors representing timbre
  1306.  
  1307.   boolean[] isRect = new boolean[maxVoices];  // Whether the shape is a rectangle or an oval
  1308.   boolean[] isLongNote = new boolean[maxVoices];  // Short vs. Long note(lifespan)
  1309.  
  1310.   float spawnInterval;  // Interval for regenerating shapes in milliseconds
  1311.   float lastRegenerationTime;  // Last time the shapes were regenerated
  1312.   int feedbackAlpha = 50;  // Alpha value for feedback effect
  1313.  
  1314.   void setup() {
  1315.     size(800, 800);
  1316.     noStroke();
  1317.     spawnInterval = random(21000, 46700);  // Random spawn interval(21 to 46.7 seconds)
  1318.     lastRegenerationTime = millis();  // Initialize last regeneration time
  1319.     regenerateVisuals();  // Initial configuration
  1320.   }
  1321.  
  1322.   void regenerateVisuals() {
  1323.     // Reset all shape properties for new configuration
  1324.     for (int i=0; i<maxVoices; i++) {
  1325.       resetVoice(i);  // Initialize or reset each shape
  1326.       spawnTimes[i] = millis();  // Initialize spawn time for each shape
  1327.     }
  1328.   }
  1329.  
  1330.   void resetVoice(int index) {
  1331.     x[index] = random(width);  // Random X position
  1332.     y[index] = map(random(0, 1), 0, 1, height * 0.1, height * 0.9);  // Vertical position mapped to pitch
  1333.     sizes[index] = random(10, 100);  // Variable sizes for different articulation(dynamics)
  1334.     speeds[index] = random(2, 6);  // Speed of movement for rhythm variation
  1335.     colors[index] = color(random(255), random(255), random(255), 200);  // Color representing timbre
  1336.  
  1337.     // Randomly determine whether the shape is a rectangle or an oval
  1338.     isRect[index] = random(1) > 0.5;
  1339.  
  1340.     // Assign long vs. short note(longer lifespan for smoother, evolving sounds)
  1341.     isLongNote[index] = random(1) > 0.5;
  1342.   }
  1343.  
  1344.   void draw() {
  1345.     // Draw motion blur effect by overlaying a semi-transparent background
  1346.     fill(0, feedbackAlpha);  // Background with some transparency
  1347.     rect(0, 0, width, height);
  1348.  
  1349.     // Current time for regeneration management
  1350.     float currentTime = millis();
  1351.  
  1352.     // Loop through all shapes(voices)
  1353.     for (int i=0; i<maxVoices; i++) {
  1354.       // Update shape's appearance
  1355.       applyAlgorithm(i);
  1356.  
  1357.       // Update movement
  1358.       x[i] += random(-speeds[i], speeds[i]);  // Rhythmic movement
  1359.       y[i] += random(-1, 1);  // Micro-variations in pitch
  1360.       sizes[i] += random(-0.5, 0.5);  // Subtle size changes for articulation
  1361.  
  1362.       // Check if it's time to regenerate the visuals
  1363.       if (currentTime - lastRegenerationTime >= spawnInterval) {
  1364.         regenerateVisuals();  // Generate a new configuration
  1365.         lastRegenerationTime = currentTime;  // Update the last regeneration time
  1366.         spawnInterval = random(21000, 46700);  // Randomize next spawn interval
  1367.       }
  1368.     }
  1369.   }
  1370.  
  1371.   void applyAlgorithm(int index) {
  1372.     // Draw shapes according to current configuration
  1373.     fill(colors[index]);
  1374.     if (isRect[index]) {
  1375.       rect(x[index], y[index], sizes[index], sizes[index]);
  1376.     } else {
  1377.       ellipse(x[index], y[index], sizes[index], sizes[index]);
  1378.     }
  1379.   }
  1380. }
  1381.  
  1382. ArrayList<Visualization> visualizations = new ArrayList<Visualization>();
  1383. ArrayList<Float> offsets = new ArrayList<Float>();
  1384. ArrayList<Float> timers = new ArrayList<Float>();
  1385. int currentVisualizationIndex = -1;
  1386.  
  1387. void setup() {
  1388.   size(800, 600);
  1389.   noLoop();
  1390.  
  1391.   // Instantiate and add visualizations
  1392.   Visualization vis1 = new Visualization1();
  1393.   Visualization vis2 = new Visualization2();
  1394.   Visualization vis3 = new Visualization3();
  1395.   Visualization vis4 = new Visualization4();
  1396.   Visualization vis5 = new Visualization5();
  1397.   Visualization vis6 = new Visualization6();
  1398.   Visualization vis7 = new Visualization7();
  1399.   Visualization vis8 = new Visualization8();
  1400.   Visualization vis9 = new Visualization9();
  1401.   Visualization vis10 = new Visualization10();
  1402.   Visualization vis11 = new Visualization11();
  1403.   Visualization vis12 = new Visualization12();
  1404.   Visualization vis13 = new Visualization13();
  1405.   Visualization vis14 = new Visualization14();
  1406.   Visualization vis15 = new Visualization15();
  1407.  
  1408.   // Add more instances as needed
  1409.  
  1410.   visualizations.add(vis1);
  1411.   visualizations.add(vis2);
  1412.   visualizations.add(vis3);
  1413.   visualizations.add(vis4);
  1414.   visualizations.add(vis5);
  1415.   visualizations.add(vis6);
  1416.   visualizations.add(vis7);
  1417.   visualizations.add(vis8);
  1418.   visualizations.add(vis9);
  1419.   visualizations.add(vis10);
  1420.   visualizations.add(vis11);
  1421.   visualizations.add(vis12);
  1422.   visualizations.add(vis13);
  1423.   visualizations.add(vis14);
  1424.   visualizations.add(vis15);
  1425.  
  1426.   // Call setup for each visualization
  1427.   for (Visualization vis : visualizations) {
  1428.     vis.setup();
  1429.   }
  1430.  
  1431.   // Initialize offsets and timers for each visualization
  1432.   for (int i = 0; i < visualizations.size(); i++) {
  1433.     offsets.add(random(21, 46.7));
  1434.     timers.add(millis());
  1435.   }
  1436. }
  1437.  
  1438. void draw() {
  1439.   background(0);
  1440.  
  1441.   if (visualizations.size() == 0) return;
  1442.  
  1443.   // Check the time for each visualization
  1444.   for (int i = 0; i < visualizations.size(); i++) {
  1445.     float elapsedTime = (millis() - timers.get(i)) / 1000.0;
  1446.    
  1447.     if (elapsedTime >= offsets.get(i)) {
  1448.       currentVisualizationIndex = i;
  1449.       timers.set(i, millis()); // Reset timer
  1450.       break; // Break loop to render only the current visualization
  1451.     }
  1452.   }
  1453.  
  1454.   // Display the current visualization
  1455.   if (currentVisualizationIndex != -1) {
  1456.     visualizations.get(currentVisualizationIndex).draw();
  1457.   }
  1458. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement