Open sound control between tablet and computer message error (works on two computers)

edited September 2016 in Android Mode

Hey! I was able to get this code to work on two computers, but it's not working at all when I try to run the sketch independent of the browser on my tablet. I'm wondering if this has something to do with the port number or android mode?

Here is the code on my tablet:

    import oscP5.*;
    import netP5.*;


    Buttons button1;
    Buttons button2;

    OscP5 oscP5;
    NetAddress myRemoteLocation;

    void setup() {
      size(600,800);
      frameRate(25);
      /* start oscP5, listening for incoming messages at port 12000 */
      oscP5 = new OscP5(this,12000);



      myRemoteLocation = new NetAddress("192.168.1.179",12000);


      button1 = new Buttons();
      button1.x = 100;
      button1.y = 100;
      button1.w = 100;
      button1.h = 100;

      button2 = new Buttons();
      button2.x = 250;
      button2.y = 100;
      button2.w = 100;
      button2.h = 100;

    }


    void draw() {
      background(0);  
      rectMode(CENTER);

      fill(squareColor, 0, 0);

     button1.display("hello");

     button2.display("fractured");

    }

    void mousePressed() {
       button1.clicked("hello");
       button2.clicked("testing");

    }

    void clicked(String wordMessage){
      float d = dist(x, y, mouseX, mouseY);
      if (d < 50) { 
       boxBackground = 255;
       OscMessage myMessage = new OscMessage(wordMessage);
       oscP5.send(myMessage, myRemoteLocation);
       println(myMessage);
      }

Here is the code on my computer:

    import oscP5.*; 
    import netP5.*;

    int circleColor = 200;

    OscP5 oscP5;
    NetAddress myRemoteLocation;

    void setup() {
      size(400,400);
      frameRate(25);
      oscP5 = new OscP5(this,12000);

      myRemoteLocation = new NetAddress("192.168.1.128",12000);
    }


    void draw() {
      background(0);  
      rectMode(CENTER);

      fill(circleColor, 0, 0);
      ellipse(width/2, height/2, 100, 100);



    }


    void oscEvent(OscMessage theOscMessage) {

      print("### received an osc message.");
      //print(" addrpattern: "+theOscMessage.addrPattern());
      println(" typetag: "+theOscMessage.typetag());

      if(theOscMessage.checkAddrPattern("poopin")==true) {
        println("it worked!");

      } else if (theOscMessage.checkAddrPattern("hello")==true) {
       println("yay, it worked!");
      }

    }
Tagged:

Answers

  • edited October 2016

    The Button in your tablet code is a class that you defined yourself? Is that code located in another tab?

    I will suggest doing the following modification in your tablet code:

    void mousePressed() {
       clicked("hello");
       clicked("testing");     
    }
    

    This would make more sense but it will not work as yet because of the conditional placed inside your Clicked() function, line 57. It would be important to see how you implement your Button class to be able to get your code work properly.

    Kf

  • edited October 2016

    Thanks so much for your comment! Yes, the button is located in another tab, sorry I missed that. Thanks for looking at that and your suggestion.

    I'm realizing that issue is perhaps with android mode, as I'm unable to get the emulator running, and getting this series of errors.


    1. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/MainActivity.java (at line 11) import android.support.v4.content.ContextCompat; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The import android.support.v4.content.ContextCompat is never used ---------- 2. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/MainActivity.java (at line 15) import android.Manifest; ^^^^^^^^^^^^^^^^ The import android.Manifest is never used ---------- 3. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/MainActivity.java (at line 49) int check; ^^^^^ The value of the local variable check is not used ---------- ---------- 4. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 4) import processing.data.*; ^^^^^^^^^^^^^^^ The import processing.data is never used ---------- 5. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 5) import processing.event.*; ^^^^^^^^^^^^^^^^ The import processing.event is never used ---------- 6. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 6) import processing.opengl.*; ^^^^^^^^^^^^^^^^^ The import processing.opengl is never used ---------- 7. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 11) import java.util.HashMap; ^^^^^^^^^^^^^^^^^ The import java.util.HashMap is never used ---------- 8. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 12) import java.util.ArrayList; ^^^^^^^^^^^^^^^^^^^ The import java.util.ArrayList is never used ---------- 9. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 13) import java.io.File; ^^^^^^^^^^^^ The import java.io.File is never used ---------- 10. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 14) import java.io.BufferedReader; ^^^^^^^^^^^^^^^^^^^^^^ The import java.io.BufferedReader is never used ---------- 11. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 15) import java.io.PrintWriter; ^^^^^^^^^^^^^^^^^^^ The import java.io.PrintWriter is never used ---------- 12. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 16) import java.io.InputStream; ^^^^^^^^^^^^^^^^^^^ The import java.io.InputStream is never used ---------- 13. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 17) import java.io.OutputStream; ^^^^^^^^^^^^^^^^^^^^ The import java.io.OutputStream is never used ---------- 14. WARNING in /private/var/folders/jb/wxxdt_s52676gx9nl2nfj60w0000gn/T/android1427833249765445791sketch/src/processing/test/osc_send_sketch/osc_send_sketch.java (at line 18) import java.io.IOException; ^^^^^^^^^^^^^^^^^^^ The import java.io.IOException is never used ---------- 14 problems (14 warnings)
  • I don't have much experience with emulators. I understand you need to have them running before you execute any processing code. I would suggest making sure you have your emulator working first before trying to work in this task. For example, use a simpler example that you know it works on a real device. Regarding your code, it will help if you post your entire code.

    Kf

Sign In or Register to comment.