Earlab Home | Earlab Wiki | Members | Projects | Topics | Tools | Classes | Events | Contact |

Classes

Table of Contents

ΓΕΝΙΚΑ

ΕΡΓΑΣΙΑ

Όλα τα μαθήματα έχουν μια εργασία. Η εργασία αυτή αποτελεί μια διαδικασία εξερεύνηση στο πεδίο που ορίζει ο τίτλος του μαθήματος.

AVA540

ΔΙΑΔΡΑΣΤΙΚΑ ΟΠΤΙΚΟΑΚΟΥΣΤΙΚΑ ΣΥΣΤΗΜΑΤΑ

ΓΕΝΙΚΑ

  • ΕΡΓΑΛΕΙΑ
    Στο πλαίσιο του μαθήματος θα χρησιμοποιηθούν τα παρακάτω εργαλεία:
    • Processing
      Η Processing είναι μια ανοικτή και δωρεάν γλώσσα προγραμματισμού - περιβάλλον για δημιουργικό προγραμματισμό. Δημιουργήθηκε το 2001 και απο τον Ben Fry και τον Casey Reas όταν και οι δύο ήταν φοιτητές του John Maeda στο MIT Media Lab. Περισσότερες πληροφορίες στο ιστότοπο http://processing.org/about/.
    • SuperCollider
      SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition.
    • Arduino
      Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

1ο ΕΡΓΑΣΤΗΡΙΟ

  • Εισαγωγή στην Processing
    • Έκθεση - δουλειές που έχουν γίνει με Processing (sKeTcH)
    • Ιστορία
    • Βιβλιογραφία
  • Περιβάλλον Ανάπτυξης (IDE: Intergrated Development Environment)
    • New file
    • Save As
    • Run
  • Βασικές Δεσμευμένες λέξεις - συναρτήσεις & μεταβλητές
    • size
    • line
    • width
    • height
  • Σχεδιασμός απλού γεωμετρικού σχήματος με γραμμές
    size(600,600);
    line(width/3, 2*height/3, width/2, height/3);
    line(2*width/3, 2*height/3, width/2, height/3);
    line(width/3, height/2, 2*width/3, height/2);
    

2ο ΕΡΓΑΣΤΗΡΙΟ

  • info
    Whitney called "differentialdynamics," imagine a set of points going around a circle,these cond traveling twice the speed of the first, the third three times the speed of the first, and so on, all starting together at the twelve o'clock position (Alves, 2005).

    Useful links:

  • code
    • initial sketch
      float x, y, a, b, r, th, step;
      
      void setup()  {
        size(600,600);
        smooth();
        a = width/2;
        b = height/2;
        r = 200;
        step = 0.1;
      }
      
      void draw()   {
        background(0);
        
        th = th + step;
        x = a + r*cos(th);
        y = b + r*sin(th);
        
        ellipse(x,y,10,10);
      
        x = a + r*cos(th*1.1);
        y = b + r*sin(th*1.1);
        
        ellipse(x,y,10,10);
      
      
        x = a + r*cos(th*3);
        y = b + r*sin(th*3);
      }
      
    • class orientation
      // see processing examples/objects 
      WhitneyEllipse we1, we2, we3, we4, we5, we6, we7, we8, we9, we10;
      
      void setup()  {
        size(600,600);
        smooth();
        // WhitneyEllipse(spinVelocity)
        we1 = new WhitneyEllipse(0.01);
        we2 = new WhitneyEllipse(0.02);
        we3 = new WhitneyEllipse(0.03);
        we4 = new WhitneyEllipse(0.04);  
        we5 = new WhitneyEllipse(0.05);  
        we6 = new WhitneyEllipse(0.06);  
        we7 = new WhitneyEllipse(0.07);  
        we8 = new WhitneyEllipse(0.08);  
        we9 = new WhitneyEllipse(0.09);  
        we10 = new WhitneyEllipse(0.1);    
      }
      
      void draw()   {
        background(0);
        
        we1.display();
        we2.display();
        we3.display();
        we4.display();  
        we5.display();
        we6.display();
        we7.display();  
        we8.display();
        we9.display();
        we10.display();  
      }
        
      class WhitneyEllipse
      {
        float x, y, a, b, r, th, spinVelocity;
        
        WhitneyEllipse(float spinVelocityVar)  {
          spinVelocity = spinVelocityVar;
          a = width/2;
          b = height/2;
          r = 200;
        }
        
        void display()  {
          th = th + spinVelocity;
          x = a + r*cos(th);
          y = b + r*sin(th);
        
          ellipse(x,y,10,10);
        } 
      }
      
      
    • array of objects
      // usefull link http://www.learningprocessing.com/examples/chapter-13/example-13-10/
      WhitneyEllipse[] we;
      
      int numWE = 50;
      
      void setup()  {
        size(600,600);
        smooth();
        we = new WhitneyEllipse[numWE];
        for (int i=0;i<numWE;i++)  {  
          we[i] = new WhitneyEllipse(i*0.0001);
        }
      }
      
      void draw()   {
        background(0);
        for (int i=0; i < numWE; i++)  {
          we[i].display();
        }
      }
        
      class WhitneyEllipse
      {
        float x, y, a, b, r, th, spinVelocity;
        
        WhitneyEllipse(float spinVelocityVar)  {
          spinVelocity = spinVelocityVar;
          a = width/2;
          b = height/2;
          r = 200;
        }
        
        void display()  {
          th = th + spinVelocity;
          x = a + r*cos(th);
          y = b + r*sin(th);
        
          ellipse(x,y,10,10);
        } 
      }
      
      
    • control object spin radius
      WhitneyEllipse[] we;
      
      int numWE = 250;
      
      void setup()  {
        size(600,600);
        smooth();
        we = new WhitneyEllipse[numWE];
        for (int i=0;i<numWE;i++)  {  
          we[i] = new WhitneyEllipse(i*0.001, 10+i);
        }
      }
      
      void draw()   {
        background(0);
        for (int i=0; i < numWE; i++)  {
          we[i].display();
        }
      }
      
      void mousePressed()  {
      
        println("you press A");
      }
      
      class WhitneyEllipse
      {
        float x, y, a, b, r, th, spinVelocity, spinRadius;
        
        WhitneyEllipse(float spinVelocityVar, float spinRadiusVar)  {
          spinVelocity = spinVelocityVar;
          spinRadius = spinRadiusVar;
          a = width/2;
          b = height/2;
        }
        
        void display()  {
          th = th + spinVelocity;
          x = a + spinRadius*cos(th);
          y = b + spinRadius*sin(th);
        
          ellipse(x,y,10,10);
        } 
      }
      

3ο ΕΡΓΑΣΤΗΡΙΟ

  • Θέματα
    1. Εισαγωγή font
    2. Εισαγωγή φωτογραφίας
    3. Δημιουργία μεθόδου
  • Σάρωση και συλλογή πληροφοριών των pixels απο φωτογραφία
    You can download the image from here
    /*
      This program scans in a grayscale600x600 image, extracts the 
      pixel color data, and draws this data on a grid of ellipses.
      from: http://visiblevisible.org/teaching/setpixel/students/joseph_l/
      Scanning color data from pixels
      
      edit by Aris Bezas Thu, 02 December 2010, 13:35
    */
    
    int step = 15, radius = 1;
    PFont fontA;
    
    void setup()  {
      size(600, 600);
      background(0);
      smooth();
      fontA = loadFont("Serif-48.vlw");
      ellipseMode(CENTER);
      textAlign(CENTER);
      textFont(fontA, 12);
    }
    
    void draw()  {} // draw void before mousePressed
    
    void mousePressed()  {
     radius  = radius + 1;    // Radius incrementation
     drawPicture();          // Call drawPicture void every timeyou press the mouse
    }
    
    void drawPicture()  {
      int pixel_count = 0;
      PImage face = loadImage("puma.jpg");    // load image
      color pixcol;                          // variable fr pixel color
      int facecol;
    
      //allocate space to save the pixel information from the image
      float[][] pixel_data = new float [600][600]; //600x600=360000
    
      //scans through the image and saves the pixel data in an array
      if(pixel_count < 359999)  {
        for(int i=0;i<599;i++)  {              //scan each pixels on axis x
          for(int j=0;j<599;j++)  {            //scan each pixels on axis y
            pixcol = face.pixels[pixel_count];
            pixel_data[i][j] = green(pixcol);
            pixel_count++;
          }
          pixel_count++;
        }
      }
    
      //applies the pixel data to the circles.
      for(int i=0;i<599;i+=step)  {
        for(int j=0;j<600;j+=step)    {
          fill(pixel_data[j][i]);
          text(char(int(random(160))),i,j);  // Typography
          ellipse(i,j,radius, radius);
        } 
      }
    }
    
    
    
  • Επεξεργασία και αναδόμηση εικόνας
    /*
    Image processing
    ----------------
    slice image vertically and reconstruct it randomly
    image size 407x520
    Aris Bezas 111108
    */
    
    import processing.opengl.*;
    
    PImage tibetFace;
    int imageWidth = 407;
    int imageHeight = 520;
    int slices = 110;
    //SC code: (0..49).scramble
    int[] randPos = { 67, 0, 75, 44, 93, 28, 36, 9, 49, 23, 61, 73, 56, 7, 32, 1, 69, 30, 105, 74, 99, 82, 88, 104, 25, 65, 91, 76, 109, 92, 81, 16, 85, 107, 68, 15, 106, 48, 89, 95, 63, 45, 14, 108, 58, 97, 66, 17, 90, 78, 77, 31, 12, 20, 59, 8, 52, 2, 4, 54, 24, 46, 33, 98, 79, 40, 60, 53, 103, 35, 100, 26, 80, 27, 64, 19, 101, 41, 47, 50, 55, 10, 43, 84, 18, 6, 96, 5, 62, 34, 13, 11, 87, 102, 37, 39, 57, 38, 51, 72, 86, 70, 71, 21, 42, 3, 94, 83, 29, 22 };
    
    void setup()  {
      size(imageWidth,imageHeight, OPENGL);
      tibetFace = loadImage("/Users/ari/Media/images/photograph/faces/tibet.jpg");
      image(tibetFace,0,0);
      for (int i=0; i < slices; i++)  {  
        copy(tibetFace, i*width/slices, 0, width/slices, height, randPos[i]*width/slices, 0, width/slices, height);
      }
    }
    
    

4o ΕΡΓΑΣΤΗΡΙΟ

  • Machine Listening
    • Loudness
    • Amplitude
    • Pitch
    • Onsets

TODO ΣΥΝΕΧΕΙΑ

  • Παρουσίαση του sketch
  • Εφαρμογή σε Processing με χρήση της βιβλιοθήκης OpenCV
  • Εφαρμογή στο SuperCollider για ανίχνευση της έντασης και της συχνότητας ηχητικης εισόδου σε πραγματικό χρόνο
  • Εργαστηριακή άσκηση μέσω της οποίας επιτυγχάνεται επικοινωνία Processing και SuperCollider μέσω του πρωτόκολλου OSC
  • Δημιουργία εργαστηριακής άσκησης μέσω της οποίας οπτικοποιούνται τα χαρακτηριστικά του ήχου ένταση και συχνότητα. Αναφορά σε εργαλέια για mapping projections.
  • Wireface
  • Χρήση κάμερας υπέρυθρης λήψης και υπέρυθρου φωτός και δημιουργία εφαρμογής σε περιβάλλον Processing
  • Εισαγωγικό μάθημα στο openFrameworks, εγκατάσταση και εκτέλεση

παραδειγμάτων

  • Εφαρμογή μεσώ της επιτυγχάνεται επικοινωνία μεταξύ Processing, SuperCollider και openFrameworks μέσω OSC
  • Ανάπτυξη της προηγούμενης εφαρμογής. Χρήση του openFrameworks για Computer Vision

AVA940

ΔΙΑΔΡΑΣΗ ΚΑΙ ΔΙΕΠΑΦΕΣ ΑΝΘΡΩΠΟΥ ΜΗΧΑΝΗΣ

ΓΕΝΙΚΑ

  • ΕΡΓΑΛΕΙΑ
    Στο πλαίσιο του μαθήματος θα χρησιμοποιηθούν τα παρακάτω εργαλεία:
    • Processing
      Η Processing είναι μια ανοικτή και δωρεάν γλώσσα προγραμματισμού - περιβάλλον για δημιουργικό προγραμματισμό. Δημιουργήθηκε το 2001 και απο τον Ben Fry και τον Casey Reas όταν και οι δύο ήταν φοιτητές του John Maeda στο MIT Media Lab. Περισσότερες πληροφορίες στο ιστότοπο http://processing.org/about/.
    • SuperCollider
      SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition.
    • Arduino
      Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

1ο ΕΡΓΑΣΤΗΡΙΟ

  • Εισαγωγή στο Arduino
  • Εισαγωγή στους πιεζοηλεκτρικούς αισθητήρες
    Piezoelectric materials, which are some crystals and ceramics, have the ability to produce electricity when mechanical stress is applied to them. The effect finds useful applications such as the production and detection of sound, generation of high voltages, electronic frequency generation, microbalances, and ultra fine focusing of optical assemblies. The effect is also reversible, in that if an electric field is applied across the piezoelectric material it will cause the material to change shape (by as much as 0.1% in some cases). To produce sounds from a piezo disc, an electric field is turned on and off very fast, to make the material change shape and hence cause a ʻclickʼ as the disc pops out and back in again (like a tiny drum). By changing the frequency of the pulses, the disc will deform hundreds or thousands of times per second and hence causing the buzzing sound. By changing the frequency of the clicks and the time in between them, specific notes can be produced. You can also use the piezoʼs ability to produce an electric field to measure movement or vibrations.

    Arduino Starter Kit p.74

  • Εισαγωγή στην Processing
  • Ήχος και Ηλεκτρισμός (Make:Electronics - Charles Platt page.244 (259))
  • Διάβασμα αναλογικής εισόδου και εκτύπωση της τιμής στη σειριακή έξοδο
    /*
     AnalogReadSerial
     Reads an analog input on pin 0, prints the result to the serial monitor 
    */
    
    void setup() {
      Serial.begin(57600);
    }
    
    void loop() {
      int sensorValue = analogRead(0);
      Serial.println(sensorValue, DEC);
    }
    
  • Διάδραση με το ποντίκι
    • supercollider-code
      { SinOsc.ar(MouseX.kr(40, 10000, 'exponential', 2), 0, 0.1) }.play;
      
    • processing-code
       /**
       * Mouse 2D. 
       * 
       * Moving the mouse changes the position and size of each box. 
       */
       
      void setup() 
      {
        size(200, 200); 
        noStroke();
        rectMode(CENTER);
      }
      
      void draw() 
      {   
        background(51); 
        fill(255, 204);
        rect(mouseX, height/2, mouseY/2+10, mouseY/2+10);
        fill(255, 204);
        int inverseX = width-mouseX;
        int inverseY = height-mouseY;
        rect(inverseX, height/2, (inverseY/2)+10, (inverseY/2)+10);
      }
      
      

2ο ΕΡΓΑΣΤΗΡΙΟ 2011-10-17 Mon 12:10

  • Μετασχηματισμός βομβιτή (buzzer) σε μικρόφωνο επαφής
    Convert piezo transducer to crude microphone Piezo transducers are output transducers which convert an electrical signal to sound. They require a driver circuit (such as a 555 astable) to provide a signal and if this is near their natural (resonant) frequency of about 3kHz they will produce a particularly loud sound. Piezo transducers require a small current, usually less than 10mA, so they can be connected directly to the outputs of most ICs. They are ideal for buzzes and beeps, but are not suitable for speech or music because they distort the sound. They are sometimes supplied with red and black leads, but they may be connected either way round. PCB-mounting versions are also available. Piezo transducers can also be used as input transducers for detecting sudden loud noises or impacts, effectively behaving as a crude microphone. from http://www.kpsec.freeuk.com/components/other.htm
  • Επεξεργασία σήματος μικροφώνου στο SuperCollider
    /*
    Create code at SC, for recieve piezoelectric mic signal
    Note: Change Audio Input from AUDIO MIDI SETUP
    
    Aris Bezas 
    */
    s.boot;
    
    //:Test
    {Out.ar(0, Pan2.ar(In.ar(8), 0, 0.7))}.play;
    
    //:Create a Synth
    SynthDef(\piezoelectricMic, { |level = 0| 
            Out.ar(0, Pan2.ar(In.ar(8), 0, level))
    }).send(s);
    
    x = Synth(\piezoelectricMic).play(s)    // Play the synth
    x.set(\level, 0.8)                                              //      set level
    
    //:Amplitude detection and OSC sender
    
    (
    s.boot.doWhenBooted {
    b = Buffer.alloc(s, 512); // Prepare the buffers
    };
    )
    
    (
    x = { | threshold = 0.5, out = 100 |
            var sig, chain, onsets, pips;
    
            sig = In.ar(8);
            chain = FFT(b, sig);
    
            onsets = Onsets.kr(chain, threshold, \power);
            SendReply.kr(onsets, \onset);
            // You'll hear percussive "ticks" whenever an onset is detected
            pips = WhiteNoise.ar(EnvGen.kr(Env.perc(0.001, 0.1, 0.2), onsets));
            Out.ar(out, Pan2.ar(pips, 0.75, 1));
    
    }.play;
    )
    
    x.set(\threshold, 0.5);
    x.free; // Free the synth
    
    r = OSCresponder(nil, \onset, {
            "tak".postln; // post
            // Το συντακτικό του μηνύματος πρέπει να είναι το ίδιο με αυτό που περιμένει ο ανταποκριτής (responder)
            NetAddr("127.0.0.1", 12000).sendMsg("piezo"); 
    }).add;
    
    r.free; // remove the responder 
    
    
  • Επικοινωνία SuperCollider με το Processing
    1. Setup oscP5 library at Processing. Πληροφορίες για το πως κάνουμε εγκατάσταση βιβλιοθήκης στην Processing θα βρείτε εδώ, σχετικά με την βιβλιοθήκη oscP5 εδώ.
    2. Open oscP5sendreceive by andreas schlegel example from oscP5 library for recieve the messages.
  • Processing sketch for interaction
    /**
     * oscP5plug by andreas schlegel
     * example shows how to use the plug service with oscP5.
     * the concept of the plug service is, that you can
     * register methods in your sketch to which incoming 
     * osc messages will be forwareded automatically without 
     * having to parse them in the oscEvent method.
     * that a look at the example below to get an understanding
     * of how plug works.
     * oscP5 website at http://www.sojamo.de/oscP5
     */
    
    import oscP5.*;
    import netP5.*;
    
    OscP5 oscP5;
    NetAddress myRemoteLocation;
    
    void setup() {
      size(400,400);
      frameRate(25);
      /* start oscP5, listening for incoming messages at port 12000 */
      oscP5 = new OscP5(this,12000);
      
      /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
       * an ip address and a port number. myRemoteLocation is used as parameter in
       * oscP5.send() when sending osc packets to another computer, device, 
       * application. usage see below. for testing purposes the listening port
       * and the port of the remote location address are the same, hence you will
       * send messages back to this sketch.
       */
      myRemoteLocation = new NetAddress("127.0.0.1",12000);
      
      /* osc plug service
       * osc messages with a specific address pattern can be automatically
       * forwarded to a specific method of an object. in this example 
       * a message with address pattern /test will be forwarded to a method
       * test(). below the method test takes 2 arguments - 2 ints. therefore each
       * message with address pattern /test and typetag ii will be forwarded to
       * the method test(int theA, int theB)
       */
      oscP5.plug(this,"piezo","piezo");
    }
    
    
    public void piezo() {
      background(int(random(255)), int(random(255)), int(random(255)));
    }
    
    
    void draw() {
      //background(0);
    }
    
    
    void mousePressed() {
      /* createan osc message with address pattern /test */
      OscMessage myMessage = new OscMessage("/test");
      
      myMessage.add(123); /* add an int to the osc message */
      myMessage.add(456); /* add a second int to the osc message */
    
      /* send the message */
      oscP5.send(myMessage, myRemoteLocation); 
    }
    
    
    /* incoming osc message are forwarded to the oscEvent method. */
    void oscEvent(OscMessage theOscMessage) {
      /* with theOscMessage.isPlugged() you check if the osc message has already been
       * forwarded to a plugged method. if theOscMessage.isPlugged()==true, it has already 
       * been forwared to another method in your sketch. theOscMessage.isPlugged() can 
       * be used for double posting but is not required.
      */  
      if(theOscMessage.isPlugged()==false) {
      /* print the address pattern and the typetag of the received OscMessage */
      println("### received an osc message.");
      println("### addrpattern\t"+theOscMessage.addrPattern());
      println("### typetag\t"+theOscMessage.typetag());
      }
    }
    

4ο ΕΡΓΑΣΤΗΡΙΟ 2011-11-12 Sat

  • MultiTouch Interafaces
    • iPad (iPod) - TouchOSC
      Δημιουργία γραφικών στη Processing και ηχητικού περιβάλλοντος στο SuperCollider, όπου τα γραφικά να ελέγχονται μέσω του SuperCollider, και το ηχητικό περιβάλλον απο το iPad.
      • scCode
        //:Create my Network
        n = NetAddr("localhost", 12345);
        n.sendMsg("backgroundAlpha",25) // send test message
        
        //:Create my Sound Enviroment
        SynthDef(\someNoise, { |out, add=10000|
                Out.ar(0, BPF.ar(WhiteNoise.ar(0.1.dup), add, 0.2));
        }).send(s);
        
        y = Synth.new("someNoise"); 
        y.set(\add, 5000);
        
        //:Create my Responders
        
        //:Visuals
        ~backgroundAlphaSpec = ControlSpec(0, 255, \lin);
        ~backgroundAlphaResp.remove;
        ~backgroundAlphaResp = OSCresponderNode(nil, '/backgroundAlpha', { | time, resp, msg|
                n.sendMsg("backgroundAlpha", ~backgroundAlphaSpec.map(msg[1]).asInteger.postln);
        }).add; 
        
        ~rectAlphaSpec = ControlSpec(0, 255, \lin);
        ~rectAlphaResp.remove;
        ~rectAlphaResp = OSCresponderNode(nil, '/rectAlpha', { | time, resp, msg|
                n.sendMsg("rectAlpha", ~rectAlphaSpec.map(msg[1]).asInteger.postln);
        }).add; 
        
        //:Audio
        
        ~addNoiseSpec = ControlSpec(40, 17000, \lin);
        ~addNoiseResp.remove;
        ~addNoiseResp = OSCresponderNode(nil, '/addNoise', { | time, resp, msg|
                y.set(\add, ~addNoiseSpec.map(msg[1]));
        }).add; 
        
        
      • p5Code
        import oscP5.*;
        import netP5.*;
        
        OscP5 oscP5;
        NetAddress myRemoteLocation;
        int backgroundAlpha, rectAlpha;
        
        void setup() {
          size(screenWidth,screenHeight);
          frameRate(25);
          oscP5 = new OscP5(this,12345);
          myRemoteLocation = new NetAddress("127.0.0.1",12000);
          oscP5.plug(this,"backgroundAlpha","backgroundAlpha");
          oscP5.plug(this,"rectAlpha","rectAlpha");
        }
        
        public void backgroundAlpha(int theBackgroundAlpha) {
          backgroundAlpha = theBackgroundAlpha;
        }
        public void rectAlpha(int theRectAlpha) {
          rectAlpha = theRectAlpha;
        }
        
        
        void draw() {
          fill(0,backgroundAlpha);
          rect(-10,-10, width+20, height+20);
        
          fill(255, rectAlpha);
          rect(random(width), random(height), random(200),random(200));
        }
        
        void oscEvent(OscMessage theOscMessage) {
          if(theOscMessage.isPlugged()==false) {
          /* print the address pattern and the typetag of the received OscMessage */
          println("### received an osc message.");
          println("### addrpattern\t"+theOscMessage.addrPattern());
          println("### typetag\t"+theOscMessage.typetag());
        }
        }
        

5ο ΕΡΓΑΣΤΗΡΙΟ 2011-11-21 Mon

  • Arduino - ultrasonic sensor
    Instructions
    1. Setup Arduino
    2. open firmataExample from openFrameworks. Look ofSerial for documentation.
  • ofCode
    • testApp.h
      #pragma once
      
      #include "ofMain.h"
      #include "ofEvents.h"
      
      
      class testApp : public ofSimpleApp{
      
      public:
      
              void setup();
              void update();
              void draw();
      
              void keyPressed(int key);
              void keyReleased(int key);
      
              void mouseMoved(int x, int y );
              void mouseDragged(int x, int y, int button);
              void mousePressed(int x, int y, int button);
              void mouseReleased(int x, int y, int button);
              void windowResized(int w, int h);
              void dragEvent(ofDragInfo dragInfo);
              void gotMessage(ofMessage msg);
      
              ofImage                         bgImage;
              ofTrueTypeFont          font;
          ofTrueTypeFont      smallFont;
              ofArduino       ard;
              bool            bSetupArduino;                  // flag variable for setting up arduino once
              
              //=======
              //Video
              ofVideoPlayer           myMovie;
              
          
      private:
          
          void setupArduino(const int & version);
          void digitalPinChanged(const int & pinNum);
          void analogPinChanged(const int & pinNum);
              void updateArduino();
          
          string buttonState;
          string potValue;
      
      };
      
      
      
    • test.cpp
      /*
       * This is a simple example use of ofArduino
       *
       * ofArduino currently only supports the standard Arduino boards
       * (UNO, Duemilanove, Diecimila, NG, and other boards based on the
       * ATMega168 or ATMega328 microcontrollers
       * The Arduio FIO and Arduino Mini should also work.
       * The Arduino MEGA and other variants based on microcontrollers
       * other than the ATMega168 and ATMega328 are not currently supported.
       * 
       * To use this example, open Arduino (preferably Arduino 1.0) and 
       * navigate to File -> Examples -> Firmata and open StandardFirmata.
       * Compile and upload StandardFirmata for your board, then close
       * the Arduino application and run this application.
       *
       * If you have a servo attached, press the left arrow key to rotate
       * the servo head counterclockwise and press the right arrow key to
       * rotate the servo head clockwise.
       *
       * Clicking the mouse over any part of the application will turn the
       * on-board LED on and off.
       *
       * more info aboout ofSerial http://wiki.openframeworks.cc/index.php?title=OfSerial 
       *
       */
      
      #include "testApp.h"
      
      
      //--------------------------------------------------------------
      void testApp::setup(){
              ard.connect("/dev/tty.usbserial-A4001mkL", 57600);
              ofAddListener(ard.EInitialized, this, &testApp::setupArduino);
              
              //=======
              //Video
              
              myMovie.loadMovie("/Users/ari/Media/videos/bostani/bostaniFthinoporo2011.mov");
              myMovie.play();
      
      }
      
      //--------------------------------------------------------------
      void testApp::update(){
              updateArduino();
              myMovie.idleMovie();
      }
      
      //--------------------------------------------------------------
      void testApp::setupArduino(const int & version) {
              
              // remove listener because we don't need it anymore
              ofRemoveListener(ard.EInitialized, this, &testApp::setupArduino);
      
          // set pin A0 to analog input
          ard.sendAnalogPinReporting(0, ARD_ANALOG);
      
          // Listen for changes on the analog pins
          ofAddListener(ard.EAnalogPinChanged, this, &testApp::analogPinChanged);    
      }
      
      //--------------------------------------------------------------
      void testApp::updateArduino(){
              ard.update();
      }
      
      // analog pin event handler, called whenever an analog pin value has changed
      void testApp::analogPinChanged(const int & pinNum) {
          // do something with the analog input. here we're simply going to print the pin number and
          // value to the screen each time it changes
          //potValue = "analog pin: " + ofToString(pinNum) + " = " + ofToString(ard.getAnalog(pinNum));
              cout << ard.getAnalog(0) << endl;
              myMovie.setSpeed(ofMap(ard.getAnalog(0), 750, 100, -5, 5, true));
              //myMovie.setSpeed(-1);
      }
      
      
      //--------------------------------------------------------------
      void testApp::draw(){
              myMovie.draw(0,0);
          
      }
      
      //--------------------------------------------------------------
      void testApp::keyPressed  (int key){
      
      }
      
      //--------------------------------------------------------------
      void testApp::keyReleased(int key){
      
      }
      
      //--------------------------------------------------------------
      void testApp::mouseMoved(int x, int y ){
      
      }
      
      //--------------------------------------------------------------
      void testApp::mouseDragged(int x, int y, int button){
      
      }
      
      //--------------------------------------------------------------
      void testApp::mousePressed(int x, int y, int button){
      
      }
      
      //--------------------------------------------------------------
      void testApp::mouseReleased(int x, int y, int button){
      
      }
      
      //--------------------------------------------------------------
      void testApp::windowResized(int w, int h){
      
      }
      
      //--------------------------------------------------------------
      void testApp::gotMessage(ofMessage msg){
      
      }
      
      //--------------------------------------------------------------
      void testApp::dragEvent(ofDragInfo dragInfo){ 
      
      }
      

ΣΥΝΕΧΕΙΑ

  • Σύνδεση πιεζοηλεκτρικού αισθητήρα με jack και χρήση ως μικρόφωνο
  • Δημιουργία διεπαφής μεσω του SuperCollider έλεγχο της εικόνας.
  • Δημιουργία εφαρμογής με χρήση του πρωτοκόλλου TUIO.
  • Δημιουργία εφαρμογής για διεπαφή πολυαφής (multitouch) μέσω iPod.
  • Άσκηση όπου η εικόνα χρησιμοποιείται ως διεπαφή για τον ήχο.
  • Άσκηση όπου ο ήχος χρησιμοποιείται ως διεπαφή για τον εικόνα.
  • Άσκηση όπου ο ήχος χρησιμοποιείται ως διεπαφή για τον εικόνα.
  • Αισθητήρες φωτός και ενεργοποιητές (μοτέρ).
  • Αισθητήρες μέτρησης απόστασης.

(/ 432 5)

Author: Ioannis Zannos & Aris Bezas

Date: <2011-07-18 Mon>

HTML generated by org-mode 7.4 in emacs 23