├── Ableton Project Info ├── AProject.ico └── Project8_1.cfg ├── Desktop.ini ├── visuals_tutorial.als └── visuals_tutorial_130916c └── visuals_tutorial_130916c.pde /Ableton Project Info/AProject.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghztomash/visuals_tutorial/9a28d4e59bfff4ee67ab8781f992d547dfe70083/Ableton Project Info/AProject.ico -------------------------------------------------------------------------------- /Ableton Project Info/Project8_1.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghztomash/visuals_tutorial/9a28d4e59bfff4ee67ab8781f992d547dfe70083/Ableton Project Info/Project8_1.cfg -------------------------------------------------------------------------------- /Desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | ConfirmFileOp=0 3 | NoSharing=0 4 | IconFile=Ableton Project Info/AProject.ico 5 | IconIndex=0 6 | -------------------------------------------------------------------------------- /visuals_tutorial.als: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghztomash/visuals_tutorial/9a28d4e59bfff4ee67ab8781f992d547dfe70083/visuals_tutorial.als -------------------------------------------------------------------------------- /visuals_tutorial_130916c/visuals_tutorial_130916c.pde: -------------------------------------------------------------------------------- 1 | // Tomash Ghz - tomashg.com 2 | // Ableton synced visuals in Processing Tutorial 3 | 4 | import themidibus.*; //Import the MIDI Bus library for MIDI communication 5 | import ddf.minim.*; // Iport the Minim Library for sound input 6 | 7 | Minim minim; // Create instances of Minim 8 | AudioInput in; 9 | MidiBus myBus; // and MidiBus 10 | 11 | int scene=0; // Keep track of the current scene 12 | int shape=0; // and shape 13 | 14 | color backgroundCol=0; // Store the background color 15 | color strokeCol=255; // Store the shape outile color 16 | 17 | float soundWeight; // Store the sound volume weight 18 | 19 | void setup() { // Setup function runs only once when the sketch starts. Initialize everything here 20 | size(1280, 768); // Set the window size 21 | 22 | noFill(); // Will draw only outline of shapes 23 | rectMode(CENTER); // Set the rectangle origin to its center 24 | colorMode(HSB, 360, 100, 100); // Set the color values to Hue Saturation Brightness instead of Red Green Blue 25 | smooth(8); // Draw smooth shapes 26 | 27 | MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. 28 | 29 | // or for testing you could ... 30 | // Parent In Out 31 | // | | | 32 | myBus = new MidiBus(this, "visuals", -1); // Create a new MidiBus class with no input device and the "visuals" port as the output device. 33 | 34 | minim = new Minim(this); // Create a new Minim class for sound input 35 | in = minim.getLineIn(); // Enable 36 | } 37 | 38 | void draw() { // Draw function runs every frame. Update everything and draw on the screen 39 | soundWeight=in.mix.level()*5; // Read the audio input and scale the value 40 | drawScene(); // Draw the visuals 41 | } 42 | 43 | void noteOn(int channel, int pitch, int velocity) { // NoteOn function only runs when a Note On message is recieved 44 | //Receive a noteOn and trigger events 45 | 46 | //println(); // uncomment to see all the incoming messages 47 | //println("Note On:"); 48 | //println("--------"); 49 | //println("Channel:"+channel); 50 | //println("Pitch:"+pitch); 51 | //println("Velocity:"+velocity); 52 | 53 | if((channel==0)&&(pitch==60)){ // Kick note will change colors 54 | randomColors(); 55 | }else if((channel==0)&&(pitch==62)){ // Snare note will sellect the next shape 56 | shape++; 57 | }else if((channel==0)&&(pitch==0)){ // Move to the next scene 58 | scene++; 59 | }else if((channel==0)&&(pitch==1)){ // Move to the previouc scene 60 | scene--; 61 | } 62 | } 63 | 64 | void noteOff(int channel, int pitch, int velocity) { // NoteOff function only runs when a Note Off message is recieved 65 | // trigger any events on note off 66 | } 67 | 68 | void drawScene(){ // A function we use to draw different things according to the current scene 69 | switch(scene){ // We only have 4 scenes here 70 | case 0: 71 | background(0); // set the background black 72 | break; 73 | case 1: 74 | background(backgroundCol); // just draw the background with its color 75 | break; 76 | case 2: 77 | drawShapes(0); //draw static shapes over the background 78 | break; 79 | case 3: 80 | drawShapes(soundWeight); //draw shapes that scale to the incoming volume levels. We pass the sound weight as the size value 81 | break; 82 | } 83 | } 84 | 85 | void randomColors(){ // A function we use to change randomly the colors 86 | backgroundCol=color(random(127,255),50,50); // Set a random color for the background with a hue from 127 to 255 87 | strokeCol=color(random(0,126),100,100);; // Set a random color for the outlines with a hue from 0 to 126 88 | } 89 | 90 | void drawShapes(float size){ // A function we use to draw a shape according to the current shape 91 | background(backgroundCol); // First draw the background 92 | stroke(strokeCol); // Set the outline color 93 | pushMatrix(); 94 | translate(width/2,height/2); // Start drawing from the center of the screen 95 | 96 | switch(shape%3){ // We only have 3 shapes so lets sycle through them. We add the size value 97 | case 0: 98 | rect(0,0,width/4+size*width/8,width/4+size*width/8); // Draw a square 99 | break; 100 | case 1: 101 | ellipse(0,0,width/4+size*width/8,width/4+size*width/8); // Draw a circle 102 | break; 103 | case 2: 104 | triangle(-width/8-size*width/16,width/8+size*width/16,0,-width/8-size*width/16,width/8+size*width/16,width/8+size*width/16); // Draw a triangle 105 | break; 106 | } 107 | popMatrix(); 108 | } 109 | --------------------------------------------------------------------------------