<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with send() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=send%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:55:24 +0000</pubDate>
         <description>Tagged with send() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedsend%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Upload file to WordPress Site using Processing</title>
      <link>https://forum.processing.org/two/discussion/27968/upload-file-to-wordpress-site-using-processing</link>
      <pubDate>Mon, 14 May 2018 12:30:01 +0000</pubDate>
      <dc:creator>rallyestyle</dc:creator>
      <guid isPermaLink="false">27968@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, hoping somebody might be able to point me in the direction as im struggling to find a way to upload a json file to a WordPress site. Im currently trying to post the file to the "/wp-json/wp/v2/media/" location using the HTTP-Requests-for-Processing library but im getting back some errors and to be honest im not really sure what im doing any more lol!</p>

<p>Was hoping someone might have some ideas as to the best method of uploading a json file to the wordpress uploads location so i can hopefully use the json with a sketch that will run on the site.</p>

<p>I will post an example of the code i have been trying :)</p>
]]></description>
   </item>
   <item>
      <title>http.requests not working on 1 site</title>
      <link>https://forum.processing.org/two/discussion/27820/http-requests-not-working-on-1-site</link>
      <pubDate>Sun, 22 Apr 2018 15:48:07 +0000</pubDate>
      <dc:creator>obahama</dc:creator>
      <guid isPermaLink="false">27820@/two/discussions</guid>
      <description><![CDATA[<p>I'm gathering daily weather forecast temperature data from 3 sites/pages via the http.requests library. It works fine on the  2 url's that are commented out in my code, but not on the third. Any idea why?</p>

<pre><code>import http.requests.*;

public void setup() 
{
    size(400,400);
    smooth();

  //GetRequest get = new GetRequest("http://" + "forecast.weather.gov/MapClick.php?CityName=State+College&amp;state=PA&amp;site=CTP&amp;textField1=40.7906&amp;textField2=-77.8579");
  //GetRequest get = new GetRequest("http://" + "api.wunderground.com/api/dc43c0b770a7c1e0/forecast/q/PA/State_College.json");

    GetRequest get = new GetRequest("http://" + "www.accuweather.com/en/us/state-college-pa/16801/daily-weather-forecast/6787_pc");
    get.send();
    println("Reponse Content: " + get.getContent());
    println("Reponse Content-Length Header: " + get.getHeader("Content-Length"));
}
</code></pre>

<p>Thanks for any suggestions you may have,</p>

<p>Wade</p>
]]></description>
   </item>
   <item>
      <title>Unable to use substring() function within an array. (Parsing irishrail)</title>
      <link>https://forum.processing.org/two/discussion/27687/unable-to-use-substring-function-within-an-array-parsing-irishrail</link>
      <pubDate>Wed, 04 Apr 2018 01:03:33 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27687@/two/discussions</guid>
      <description><![CDATA[<p>I am getting an error when I attempt to use substring() as I iterate through an array. I want to extract an integer from a string of text. This works fine outside of an array:</p>

<pre><code>    String trainInfo = "E215\n17:30 - Howth to Bray (-3 mins late)\nArrived Dublin Connolly next stop Tara Street";
    int start      = trainInfo.indexOf("(" ) + 1;  // STEP 1 
    int end        = trainInfo.indexOf(" mins", start);      // STEP 2
    String status  = trainInfo.substring(start, end);    // STEP 3
    int status_no   = int(status);                    // STEP 4
    println(status_no);
</code></pre>

<p>Whereas in my case I get an error at the point of the substring():</p>

<pre><code>    void requestData() {   
      for (int i = 0; i &lt; children.length; i++) {     

        XML announcementElement = children[i].getChild("PublicMessage");
        String announcement = announcementElement.getContent(); 

        int start      = announcement.indexOf("(" ) + 1;        // STEP 1 
        int end        = announcement.indexOf(" mins", start);  // STEP 2
        String status  = announcement.substring(start, end);    // STEP 3    ***error thrown at this point***
        int status_no   = int(status);                          // STEP 4

        println(status_no);
      }
    } 
</code></pre>

<p>[edit] Though not strictly related to Processing, I found a thread in the following forum that indicates that javascript does not permit substrings within arrays. I guess the same applies to Processing?:
<a rel="nofollow" href="https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function">https://stackoverflow.com/questions/42429413/javascript-error-array-substring-is-not-a-function</a></p>

<p>The responder recommends to "slice and then remove the commas" or to use join(''). I have tried to to slice() and join(), based on Processing documentation but it's not working out.</p>

<p>Would anyone know of a way to get around this? Many thanks :)</p>
]]></description>
   </item>
   <item>
      <title>How to use HTTP Requests library with API keys</title>
      <link>https://forum.processing.org/two/discussion/26889/how-to-use-http-requests-library-with-api-keys</link>
      <pubDate>Sat, 17 Mar 2018 13:32:17 +0000</pubDate>
      <dc:creator>FeiLa</dc:creator>
      <guid isPermaLink="false">26889@/two/discussions</guid>
      <description><![CDATA[<p>I'm quite new to using APIs and am trying to use the yelp API in processing to get images.  I need some help using an API key in this library. Their website says to "put the API Key in the request header as "Authorization: Bearer &lt;YOUR API KEY&gt;" Here's my attempt...</p>

<pre><code>import http.requests.*;

GetRequest get = new GetRequest("https://" + "api.yelp.com/v3/businesses/gary-danko-san-francisco");//Just a random example I found online. I know it's not an image.
get.addHeader("Authorization", "Bearer: &lt;MY API KEY&gt;");
//^ This is my attempt at using the API key
get.send();
println("Response Content: " + get.getContent());
println("Response Content-Length Header: " + get.getHeader("Content-Length"));
</code></pre>

<p>This gets printed in the console window</p>

<pre><code>Response Content: {"error": {"code": "INVALID_AUTHORIZATION_METHOD", "description": "Invalid authorization method supplied."}}
Response Content-Length Header: 108
</code></pre>

<p>This is just a minimal reworking of the example code given in the HTTP requests library. As I said I'm very new to this and any pointers you could give would be much appreciated. Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>Minim sequencing play and record functions</title>
      <link>https://forum.processing.org/two/discussion/26337/minim-sequencing-play-and-record-functions</link>
      <pubDate>Tue, 13 Feb 2018 16:10:46 +0000</pubDate>
      <dc:creator>amycroft</dc:creator>
      <guid isPermaLink="false">26337@/two/discussions</guid>
      <description><![CDATA[<p>Hi Folks!</p>

<p>I've been working on a script where in very simple terms I would like a random beep to sound (Audioplayer beep - working!) and after that beep, a sequence of audio tracks to play (currently arranged in the array audio) and eventually audio recordings to be made (not set up yet).</p>

<p>My current issue is that</p>

<pre lang="javascript">audio[0].play(); </pre>

<p>is working perfectly but not then playing the second audio track. I've tried setting this up as a separate event (</p>

<pre lang="javascript">void playrecord()</pre>

<p>) and have found this thread very helpful to get the crux of the code from <a href="/two/profile/GoToLoop">@GoToLoop</a>: <a href="https://forum.processing.org/two/discussion/12966/how-to-play-an-audio-file-sequentially" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/12966/how-to-play-an-audio-file-sequentially</a>.</p>

<p>Ideally I would like to sequence it as audio 0 play, record audio input 0 through microphone, audio 1 play, record audio input 1 through microphone. All before the next "beep" sound is made.</p>

<p>Can anyone suggest what is going wrong?</p>

<hr />

<pre lang="javascript">
import ddf.minim.*;
import ddf.minim.AudioPlayer;
import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress otherSketch;

Minim minim;
AudioPlayer beep;

static final int AUDIO = 2;
final AudioPlayer[] audio = new AudioPlayer [AUDIO];
AudioInput daydream;
AudioRecorder[] recorder = new AudioRecorder [1];

PFont f;
int [] beeps = new int [5];
int ms;
int start = -millis();
int totalBeeps;
int beeptime;
boolean pressEnter;

int current=-1;
int count=0;
 
void setup() {
  size (512, 200, P3D);
  f= createFont ("Georgia", 16);
 
  boolean pressEnter = false;
  totalBeeps = 0;
 
  oscP5 = new OscP5(this,8001); /* start oscP5, listening for incoming messages at port 8001 */
  otherSketch = new NetAddress("xxxxxx",8000); /* Start listening at (IP Address, Port Number) */
  
 
  int fac=1000;
  beeps [0] = int(random(10, 60))*fac;//these numbers aren't right but give an earlier beep!
  beeps [1] = int(random(1260, 1739))*fac;
  beeps [2] = int(random(1860, 2339))*fac;
  beeps [3] = int(random(2460, 2939))*fac;
  beeps [4] = int(random(3060, 3539))*fac;
 
  printArray (beeps);
  
  minim = new Minim(this);
  audio [0] = minim.loadFile ("Audio_01.mp3");
  audio [1] = minim.loadFile ("Audio_02.mp3");
  
  minim = new Minim(this);
  daydream = minim.getLineIn();
 // recorder [0] = minim.createRecorder(daydream, "audio01.mp3");
  
  minim = new Minim(this);
  beep = minim.loadFile ("ping.mp3");
}
 
void keyPressed() { //boolean controlling the start screen.
  if (keyCode == ENTER) { 
    start = millis();
    pressEnter = true;
  }
}
 
void draw () {
 
  background (255);
  textFont (f, 16);
  fill (0);
 
  int ms = millis()-start;
 
  println(ms, start);
  
  startScreen();

  for (int i=0; i beeps[i] &amp;&amp; i&gt;current) {
      current=i;
      beeptime=millis();
      beep.rewind();
      beep.play();
      totalBeeps =totalBeeps+1;
      OscMessage myMessage = new OscMessage("time in milliseconds");
      myMessage.add(ms); 
      myMessage.add(millis()); 
      myMessage.add(beeptime); 
      myMessage.add(start); 
      oscP5.send(myMessage, otherSketch);       
playrecord();
    }
  } 
}

void startScreen(){
  
  if (pressEnter)//this boolean controls the start screen and initiates the timer -resetting millis to 0 when ENTER is pressed.
  {
    text("The experiment has begun and these are the random beep times:", 10, 40);
    text(beeps[0], 10, 70);
    text("milliseconds", 80, 70);
    text(beeps[1], 10, 90);
    text("milliseconds", 80, 90);
    text(beeps[2], 10, 110);
    text("milliseconds", 80, 110);
    text(beeps[3], 10, 130);
    text("milliseconds", 80, 130);
    text(beeps[4], 10, 150);
    text("milliseconds", 80, 150);
  } else {
    text("Press Enter to begin", 10, 100);
  }
 
  if (!pressEnter)
    return;
}

void playrecord(){
     audio[0].play();
     if (!audio[count].isPlaying()) audio[count=(count+1)% AUDIO].play(); 
}
</pre>
]]></description>
   </item>
   <item>
      <title>How to play a minim track at a specific time using millis()</title>
      <link>https://forum.processing.org/two/discussion/26299/how-to-play-a-minim-track-at-a-specific-time-using-millis</link>
      <pubDate>Sat, 10 Feb 2018 13:17:19 +0000</pubDate>
      <dc:creator>amycroft</dc:creator>
      <guid isPermaLink="false">26299@/two/discussions</guid>
      <description><![CDATA[<p>I am attempting to write a code which sets of a beep at controlled but random intervals using millis and minim. I can't understand why the beeps are not playing using the code below. Can anyone help?</p>

<p>I am very new to processing!</p>

<p>Thank you,</p>

<p>Amy</p>

<p>&lt;</p>

<p>pre lang="javascript"&gt;</p>

<pre><code> import ddf.minim.*;
    import ddf.minim.AudioPlayer;

    import oscP5.*;
    import netP5.*;

    OscP5 oscP5;
    NetAddress otherSketch;

    Minim minim;
    AudioPlayer beep;

    PFont f;
    int [] beeps = new int [5];
    int ms;
    int start;
    int totalBeeps;
    boolean pressEnter;

    void setup(){
      size (512,200,P3D);
      f= createFont ("Georgia",16);

      boolean pressEnter = false;
      totalBeeps = 0;
      oscP5 = new OscP5(this,8001); /* start oscP5, listening for incoming messages at port 12000 */
      otherSketch = new NetAddress("127.0.0.1",8000);

    beeps [0] = int(random(10,60))*1000;//these numbers aren't right but give an earlier beep!
    beeps [1] = int(random(1260,1739))*1000;
    beeps [2] = int(random(1860,2339))*1000;
    beeps [3] = int(random(2460,2939))*1000;
    beeps [4] = int(random(3060,3539))*1000;

    printArray (beeps);

    minim = new Minim(this);
    beep = minim.loadFile ("ping.wav");

    }

    void keyPressed() { //boolean controlling the start screen.
      if (keyCode == ENTER) { 
        start = millis();
        pressEnter = true;
      }
    }

    void draw (){

    background (255);
    textFont (f,16);
    fill (0);

    int ms = millis()-start;

    println(ms);

      if (pressEnter)//this boolean controls the start screen and initiates the timer -resetting millis to 0 when ENTER is pressed.
      {
        text("The experiment has begun and these are the random beep times:",10,40);
        text(beeps[0],10,70);
        text("milliseconds",80,70);
        text(beeps[1],10,90);
        text("milliseconds",80,90);
        text(beeps[2],10,110);
        text("milliseconds",80,110);
        text(beeps[3],10,130);
        text("milliseconds",80,130);
        text(beeps[4],10,150);
        text("milliseconds",80,150);

        OscMessage myMessage = new OscMessage("/time in milliseconds");//this isn't the correct place but a test
        myMessage.add(ms); 
        oscP5.send(myMessage, otherSketch); 
      }else {
        text("Press Enter to begin",10,100);
      }

    for (int i=0;i&lt;beeps.length;i++){ //this for loop should initiate the beeps in the array to sound if their value matches int ms (which is millis - millis when ENTER pressed) 
    if (beeps[i] == ms) 
         {
      beep.play();
      totalBeeps =totalBeeps+1;
        }
      else if ( beep.position() == beep.length() )
      {
        beep.rewind();
       }
      }
    }
</code></pre>

<p></p>
]]></description>
   </item>
   <item>
      <title>How do I send a downsampled webcam video's color pixels (as greyscale) through UDP?</title>
      <link>https://forum.processing.org/two/discussion/25688/how-do-i-send-a-downsampled-webcam-video-s-color-pixels-as-greyscale-through-udp</link>
      <pubDate>Sat, 23 Dec 2017 14:54:19 +0000</pubDate>
      <dc:creator>blvckmonolith</dc:creator>
      <guid isPermaLink="false">25688@/two/discussions</guid>
      <description><![CDATA[<p>So I'm ultimately trying to do this exactly: <a rel="nofollow" href="https://vimeo.com/80364336">https://vimeo.com/80364336</a></p>

<p>I've talked to Adam about how he did it, and he's using openFrameworks.
He said he takes video from his webcam - down-samples it to those big pixels - then sends the greyscale (0-255) array information through UDP to Cinema 4d, and then has a videoIn python script (as an effector) which takes that information and displays the shading on a matrix of cubes (1 for each pixel in his down-sampled array).</p>

<p>I'm using Processing 3.0 and he said it would work just the same if I got everything working right.
Well I found code that I've gotten to where the output is very similar to his video-downsampled.</p>

<pre><code>import processing.video.*;

// Size of each cell in the grid, ratio of window size to video size
//Screen Pixels are 80 width and 60 height in this case 640/480
//Note: 128 large-pixel width at 1024 and 72 big-pixels at 576 height
int videoScale = 8;
// Number of columns and rows in the system
int cols, rows;
// Variable to hold onto Capture object
Capture video;

void setup() {  
  size(640, 480);  
  // Initialize columns and rows  
  cols = width/videoScale;  
  rows = height/videoScale;  
  background(0);
  video = new Capture(this, cols, rows);
  video.start();
}

// Read image from the camera
void captureEvent(Capture video) {  
  video.read();
}

void draw() {
  video.loadPixels();  
  // Begin loop for columns  
  for (int i = 0; i &lt; cols; i++) {    
    // Begin loop for rows    
    for (int j = 0; j &lt; rows; j++) {      
      // Where are you, pixel-wise?      
      int x = i*videoScale;      
      int y = j*videoScale;
      color c = video.pixels[i + j*video.width];
      fill(c);   
      stroke(0);      
      rect(x, y, videoScale, videoScale);    
    }  
  }
}
</code></pre>

<p>The above code gets me basically in the ballpark as far as a video downsampled to a manageable array size for UDP transfer.
I've been able to get a simple UDP message sent from Processing 3.0 to cinema 4d in a python tag, which as I advance each frame I get the message (which is looping in processing) each frame I move forward. So in theory I'm getting there.</p>

<pre><code>import hypermedia.net.*;

int port = 20000;
String ip ="127.0.0.1";
String message =new String("Hello");
UDP udpTX;

void setup(){
udpTX=new UDP(this);
udpTX.log(true);
noLoop();
}

void draw(){
udpTX.send(message,ip,port);
delay(499);
loop();
}
</code></pre>

<p>With this UDP transfer the string "Hello" gets sent in a loop with a little less than a half second delay.
To the question!
How do I meld the two? Have the camera start showing the down-sampled video and then be sending the black and white "big" pixel color data through the UDP connection?
I'm new to this, and so filling in the gaps is a big challenge but I'm trying! If I can't get help though I probably will have to chalk this one up to being over my head. Hopefully someone here is a genius who can help me. :D</p>
]]></description>
   </item>
   <item>
      <title>Receive OSC using OscP5 library, Android Mode 4.0-beta2</title>
      <link>https://forum.processing.org/two/discussion/18194/receive-osc-using-oscp5-library-android-mode-4-0-beta2</link>
      <pubDate>Sat, 17 Sep 2016 07:34:47 +0000</pubDate>
      <dc:creator>mraeclo</dc:creator>
      <guid isPermaLink="false">18194@/two/discussions</guid>
      <description><![CDATA[<p>Hey, how is it going?</p>

<p>Im trying to receive osc on my mobile, using OscP5 library and android mode 4.0-beta2. Codes:</p>

<p>Android app</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress endereco;

float x = 1.0;
float y = 2.0;
float z = 3.0;

void setup() {
  fullScreen();
  orientation(LANDSCAPE);
  textSize(100);
  oscP5 = new OscP5(this, 9000);
  endereco = new NetAddress("localhost", 10000); // not sure if i even need to import netP5
}

void draw() {
  background(0);
  fill(255);
  text("x = " + x, 20, 200);
  text("y = " + y, 20, 400);
  text("z = " + z, 20, 600);
}

void oscEvent(OscMessage mensagem) {
  // tests if any message is being received at all
  fill(255);
  rect(50, 30, 100, 100);

  if (mensagem.checkAddrPattern("/x")) x = mensagem.get(0).floatValue();
  else if (mensagem.checkAddrPattern("/y")) y = mensagem.get(0).floatValue();
  else if (mensagem.checkAddrPattern("/z")) z = mensagem.get(0).floatValue();
}
</code></pre>

<p>Java code running on my laptop</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 osc;
NetAddress endereco;

float x = 0;
float y = 0;
float z = 0;

OscMessage mx = new OscMessage("/x");
OscMessage my = new OscMessage("/y");
OscMessage mz = new OscMessage("/z");

void setup() {
  osc = new OscP5(this, 12000);
  endereco = new NetAddress("192.168.25.2", 9000);

}

void draw() {
}

void keyPressed() {
  if (key == 'q') {
    x += 10.4;
    mx.add(x);
    osc.send(mx, endereco);
    mx.clearArguments();
  } else if (key == 'w') {
    x -= 10.5;
    mx.add(x);
    osc.send(mx, endereco);
    mx.clearArguments();
  } else if (key == 'a') {
    y += 10.4;
    my.add(y);
    osc.send(my, endereco);
    my.clearArguments();
  } else if (key == 's') {
    y -= 10.5;
    my.add(y);
    osc.send(my, endereco);
    my.clearArguments();
  } else if (key == 'z') {
    z += 10.4;
    mz.add(z);
    osc.send(mz, endereco);
    mz.clearArguments();
  } else if (key == 'x') {
    z -= 10.5;
    mz.add(z);
    osc.send(mz, endereco);
    mz.clearArguments();
  }
}
</code></pre>

<p>They are both connected to the same Wifi network, im pretty sure the IP address is correct, but it just does not receive the message sent, the INTERNET permission is checked for the app. What can I be missing?</p>

<p>Using Processing 3.2.1, Android Mode 4.0-beta2, Android 6.0 (API 23), Zenphone 2 Laser Android 5.0.2.</p>

<p>All best
Thanks in advance</p>
]]></description>
   </item>
   <item>
      <title>My Little LAN Game</title>
      <link>https://forum.processing.org/two/discussion/25144/my-little-lan-game</link>
      <pubDate>Wed, 22 Nov 2017 13:44:00 +0000</pubDate>
      <dc:creator>NewStudent</dc:creator>
      <guid isPermaLink="false">25144@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys recently i created this little game but i am not able to test it completely because i do not have a second computer on the same network i was hoping you guys could test it here is the code:</p>

<p>RPG_Game.pde:</p>

<pre><code>import oscP5.*;
import netP5.*;
import processing.net.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Player player;
Bullet bullet;
Bullet playerBullet;
Player player2;
String playerIP = "";
String myIP;
boolean setup = true;
boolean load = false;
float loadV;
boolean connected = false;
float previous;
float stepPrevious;
boolean error = false;
int x;
int y;
boolean changeStep = false;
int step = 1;
int stepValue = 5;
float previousWay = UP;
boolean walking = false;
int range = 800;
boolean fireable = false;

void setup()
{
  bullet = new Bullet(color(255, 0, 0));
  playerBullet = new Bullet(color(0, 255, 0));
  background(255, 102, 0);
  myIP = Server.ip();
  fullScreen();
  oscP5 = new OscP5(this, 23492);
  textSize(48);
  textAlign(CENTER);
  player = new Player();
  player2 = new Player();
  x = width / 2;
  y = height / 2;
}

void draw()
{
  checkTime();
  background(255, 102, 0);
  set_up();
  load();
  player.show();
  player2.show();
  bullet.show();
  playerBullet.show();
  checkBulletPlayer();
  checkBulletOtherPlayer();
  showScore();
  if (walking) moveCharacter();
  if (bullet.show) bullet.move();
  if (playerBullet.show) playerBullet.move();
  if (!bullet.show) bullet.setDir(previousWay);
  if (!playerBullet.show) playerBullet.setDir(previousWay);
}

void keyPressed()
{
  keySetup();
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = true;
  if (key == 'f' &amp;&amp; bullet.show == false &amp;&amp; !setup &amp;&amp; !load)
  {
    bullet.fire();
    OscMessage myMessage = new OscMessage("playerBullet");
    myMessage.add(bullet.bx);
    myMessage.add(bullet.by);
    myMessage.add(bullet.bdir);
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (key == 'q' &amp;&amp; !setup &amp;&amp; !load) range = 300;
  if (key == 'w' &amp;&amp; !setup &amp;&amp; !load) range = 500;
  if (key == 'e' &amp;&amp; !setup &amp;&amp; !load) range = 800;
}

void keyReleased()
{
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = false;
}

public void oscEvent(OscMessage theOscMessage)
{
  if (theOscMessage.checkAddrPattern("playerBullet"))
  {
    playerBullet.bx = theOscMessage.get(0).floatValue();
    playerBullet.by = theOscMessage.get(1).floatValue();
    playerBullet.setDir(theOscMessage.get(2).floatValue());
    playerBullet.fire();
  }
  if (theOscMessage.checkAddrPattern("PlayerCoor"))
  {
    player2.move(theOscMessage.get(0).intValue(), theOscMessage.get(1).intValue(), theOscMessage.get(2).intValue(), theOscMessage.get(3).intValue());
  }
  if (theOscMessage.checkAddrPattern("ConnectReq"))
  {
    myRemoteLocation = new NetAddress(theOscMessage.get(0).stringValue(), 23492);
    OscMessage myMessage = new OscMessage("Connect");
    myMessage.add("yes");
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (theOscMessage.checkAddrPattern("Connect")) connected = true;
}
</code></pre>

<p>Bullet.pde:</p>

<pre><code>class Bullet
{
  float bx;
  float by;
  float bdir;
  boolean show = false;
  float previousX;
  float previousY;
  color clr;

  Bullet(color a)
  {
    bdir = UP;
    clr = a;
  }

  void move()
  {
    if (bdir == UP) by -= 55;
    if (bdir == LEFT) bx -= 55;
    if (bdir == DOWN) by += 55;
    if (bdir == RIGHT) bx += 55;
    if(dist(previousX, previousY, bx, by) &gt; range) show = false;
  }

  void show()
  {
    if (show)
    {
      noStroke();
      fill(clr);
      ellipse(bx + 24, by + 24, 10, 10);
      stroke(0);
      fill(255);
    }
    if(!show) bx = by = -1000;
  }

  void fire()
  {
    bx = player.x;
    by = player.y;
    previousX = bx;
    previousY = by;
    show = true;
  }

  void setDir(float _dir)
  {
    bdir = _dir;
  }
}
</code></pre>

<p>Draw.pde:</p>

<pre><code>void set_up()
{
  if (setup)
  {
    text("Enter Other Players IP:", width / 2, height / 3);
    text("Your IP: " + myIP, width / 2, height / 7);
    fill(0, 188, 255);
    text(playerIP, width / 2, height / 2 + 15);
    fill(255);
    if (error) text("Failed to Connect or Other Machine did not Respond", width / 2, height / 2 + 200);
  }
}

void load()
{
  if (load)
  {
    if (connected) loadV += 5;
    fill(255);
    text("Connecting to: " + playerIP, width / 2, height /  7);
    rectMode(CENTER);
    rect(width / 2, height / 2, 500, 100);
    fill(255, 0, 0);
    rectMode(CORNER);
    rect(width / 2 - 250, height / 2 - 50, loadV, 100);
    if (millis() - previous &gt; 5000 &amp;&amp; loadV &lt; 500)
    {
      loadV = 0;
      setup = true;
      load = false;
      connected = false;
      error = true;
    }
    if (loadV == 500) load = false;
  }
}

void keySetup()
{
  if (setup &amp;&amp; keyCode != CONTROL &amp;&amp; keyCode != SHIFT &amp;&amp; keyCode != 524)
  {
    if (keyCode == BACKSPACE)
    {
      if (playerIP.length() &gt; 0) playerIP = playerIP.substring(0, playerIP.length() - 1);
    } else
    {
      if (keyCode == ENTER)
      {
        error = false;
        if (!playerIP.equals(""))
        {
          myRemoteLocation = new NetAddress(playerIP, 23492);
          setup = false;
          load = true;
          OscMessage myMessage = new OscMessage("ConnectReq");
          myMessage.add(myIP);
          oscP5.send(myMessage, myRemoteLocation);
          previous = millis();
        }
      } else
      {
        playerIP += key;
      }
    }
  }
  if (keyCode == TAB)
  {
    loadV = 0;
    setup = true;
    load = false;
    connected = false;
  }
}

void moveCharacter()
{
  if (!setup &amp;&amp; !load)
  {
    if (keyCode == UP)
    {
      previousWay = UP;
      if (y &gt; 0) y -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, UP, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(UP);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == DOWN)
    {
      previousWay = DOWN;
      if (y + 65 &lt; height) y += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, DOWN, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(DOWN);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == LEFT)
    {
      previousWay = LEFT;
      if (x &gt; 0) x -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, LEFT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(LEFT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == RIGHT)
    {
      previousWay = RIGHT;
      if (x + 65 &lt; width) x += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, RIGHT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(RIGHT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
  }
}

void checkTime()
{
  if (millis() - stepPrevious &gt;= 200)
  {
    stepPrevious = millis();
    changeStep = true;
  }
}

void checkBulletPlayer()
{
  if (playerBullet.bx &gt; x - 15 &amp;&amp; playerBullet.bx &lt; x + 32 &amp;&amp; playerBullet.by &gt; y - 15 &amp;&amp; playerBullet.by &lt; y + 32)
  {
    player.health -= 20;
    if (player.health &lt;= 0)
    {
      player2.score++;
      player.health = 100;
      player.x = width / 2;
      player.y = height / 2;
      x = width / 2;
      y = height / 2;
    }
  }
}

void checkBulletOtherPlayer()
{
  if (bullet.bx &gt; player2.x - 15 &amp;&amp; bullet.bx &lt; player2.x + 32 &amp;&amp; bullet.by &gt; player2.y - 15 &amp;&amp; bullet.by &lt; player2.y + 32)
  {
    player2.health -= 20;
    if (player2.health &lt;= 0)
    {
      player.score++;
      player2.health = 100;
      player2.x = width / 2;
      player2.y = height / 2;
    }
  }
}

void showScore()
{
  if (!setup &amp;&amp; !load)
  {
    fill(255);
    text((int) player.score, width / 10, height / 10);
    text((int) player2.score, width - 150, height / 10);
  }
}
</code></pre>

<p>Player.pde:</p>

<pre><code>class Player
{
  PImage player = loadImage("character.png");
  PImage sprite = player.get(0, 97, 32, 32);;
  float x;
  float y;
  float dir;
  int foot = 1;
  float health = 100;
  float score = 0;

  Player()
  {
    x = width / 2;
    y = height / 2;
    dir = UP;
  }

  void move(float _x, float _y, float _dir, int _foot)
  {
    x = _x;
    y = _y;
    dir = _dir;
    foot = _foot;
    if(dir == UP &amp;&amp; foot == 1) sprite = player.get(0, 97, 32, 32);
    if(dir == UP  &amp;&amp; foot == 2) sprite = player.get(66, 97, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 1) sprite = player.get(0, 32, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 2) sprite = player.get(66, 32, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 1) sprite = player.get(0, 128, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 2) sprite = player.get(66, 128, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 1) sprite = player.get(0, 191, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 2) sprite = player.get(66, 191, 32, 32);
  }

  void show()
  {
    if (!setup &amp;&amp; !load)
    {
      sprite.resize(48, 48);
      image(sprite, x, y);
      fill(map(health, 20, 100, 255, 0), 0, 0);
      ellipse(x, y, 10, 10);
      fill(255);
    }
  }
}
</code></pre>

<p>I am open to any suggestions and opinions.
Thanks</p>

<p>and here is the character.png file:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/508/QEL8KBAM7B1C.png" alt="character" title="character" /></p>
]]></description>
   </item>
   <item>
      <title>Udp.write (arduino) and receiver processing</title>
      <link>https://forum.processing.org/two/discussion/23881/udp-write-arduino-and-receiver-processing</link>
      <pubDate>Mon, 21 Aug 2017 17:09:07 +0000</pubDate>
      <dc:creator>kfilip</dc:creator>
      <guid isPermaLink="false">23881@/two/discussions</guid>
      <description><![CDATA[<p>Hello all,
Can you help with project for my aquarium? I want to measure temperature in the two aquarium. But I not know recieve packet, partion and save to variable. I not know very good programing, because I need ony project for akvarium...
Thank you All..
Processing:
    import hypermedia.net.*;</p>

<pre><code> UDP udp;  // DEFINUJ UDP 

int yosa; // osa šipky
int posliY; // přijmute hodnoty teplomeru
int posliX;  // přijmute hodnoty

void setup() {
  posliY = 80; //zakladni hodnota před přijmutim paketu
  posliX = 80; //zakladni hodnota před přijmutim paketu
  size(400,400);
  udp = new UDP( this, 6000 );  // VYTVOR KOMUNIKACI NA UDP PORT 6000
  udp.log( true );
 udp.listen( true );           // ČEKEJ NA ZPĚTNOU VAZBU
  String ip       = "192.168.1.177";  // VZDÁLENÁ IP ADRESA
 int port        = 8888;    // KOMUNIKAČÍ PORT
 udp.send("start", ip, port ); //pošli první paket
}
void receive( byte[] data ){ //přijmi pakety
// přijmi řetězec znaku
  String message = new String( data );
  String[] parts = split(message, "&amp;");//pakety jsou rozděleny &amp; 
  posliX = int(parts[0]);//paket
  posliY = int(parts[1]);//paket

  println( "přijmuto: x = \""+posliX+"\" přijmuto: x = \""+posliY+"\" ");   //vypiš data do terminálu
  }
</code></pre>

<p>Arduino:</p>

<pre><code>//knihovny
#include &lt;SPI.h&gt;         
#include &lt;Ethernet.h&gt;
#include &lt;EthernetUdp.h&gt; 
//knihovny pro DS18b20
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;
// Připojení čidla na pin 8
#define ONE_WIRE_BUS_PIN 8
OneWire oneWire(ONE_WIRE_BUS_PIN);//nastavení komunikace po I2S sběrnici
DallasTemperature sensors(&amp;oneWire);//předání dat z I2S teploměru
// Adresa HW na I2S
DeviceAddress tepl1 = { 0x28, 0xFF, 0xC7, 0x49, 0x71, 0x15, 0x01, 0x41 };//akvário 
DeviceAddress tepl2 = { 0x28, 0xE1, 0xC7, 0x40, 0x04, 0x00, 0x00, 0x0D }; //venkovní teplota

//mac, ip a port
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEG, 0xFE, 0xBD };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // naslouchej na tomto portu

EthernetUDP Udp;

void setup() {
  // start udp a ethernet:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
  Serial.begin(9600);
    //Inicializuj čidla
  sensors.begin();
 // Nastav 10 bitů (9-12 bitů)
  sensors.setResolution(tepl1, 10);
  sensors.setResolution(tepl2, 10);
}

void loop() {
  sensors.requestTemperatures();  //Pošli příkaz čtení teploty

  //vypiš teploty na serial
  Serial.print("Teplota Akvária:   ");
  printTemperature(tepl1);
  Serial.println();

  Serial.print("Teplota vzduchu:   ");
  printTemperature(tepl2);
  Serial.println();

  // pokud jsou přečtena data přečti paket
  char packetBuffer[UDP_TX_PACKET_MAX_SIZE]="";
  int packetSize = Udp.parsePacket();
 if(packetSize)
  {
   Serial.print("Velikost prijmutych paketu");
   Serial.println(packetSize);
   Serial.print("z ");
   IPAddress remote = Udp.remoteIP();
    for (int i =0; i &lt; 4; i++)
    {
     Serial.print(remote[i], DEC);
     if (i &lt; 3)
     {
       Serial.print(".");
     }
    }

    Serial.print(", port ");
    Serial.println(Udp.remotePort());
     // přečti přijmaný znak
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
   Serial.println("Prijmuty paket:");
   Serial.println(packetBuffer);
    //pošli pakety zpět
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
   // Udp.write(sensors.getTempC(tepl1));
Udp.write("&amp;");
     Udp.write(sensors.getTempC(tepl2));
    Udp.endPacket();  
  }
  delay(10);
}
//deklarace uživatelských funkčí čidla
void printTemperature(DeviceAddress deviceAddress)
{

float tempC = sensors.getTempC(deviceAddress);

   if (tempC == -127.00) //// Pokud bude teplota -127 vypiš chybu čidla
   {
   Serial.print("Err");
   } 
   else
   {
   Serial.print(tempC);// vypiš teplotu v C
   }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Less CPU intensive way to scan pixels</title>
      <link>https://forum.processing.org/two/discussion/23592/less-cpu-intensive-way-to-scan-pixels</link>
      <pubDate>Wed, 26 Jul 2017 23:03:33 +0000</pubDate>
      <dc:creator>TimShaw</dc:creator>
      <guid isPermaLink="false">23592@/two/discussions</guid>
      <description><![CDATA[<p>Hi -</p>

<p>I am scanning an image line by line and outputting the greyscale of each pixel to Pure Data via OSC, all of it is working ok but it seems super intensive for the computer, the fans are on full speed and sometimes Processing crashes a few minutes in.</p>

<p>Is there anything I can do to make this code less intensive? Might be missing something obvious?</p>

<p>It could be because of the frameRate, and if so are there any suggestions of other ways of doing this? So that I can still run the scanning pretty fast</p>

<p>Thanks in advance for any help</p>

<pre><code>import oscP5.*;
import netP5.*;

NetAddress remote;
OscP5 oscP5;
//int incomingOSCData;
// int sendTestData;
// String msgType;

PImage img;
int x, y, s, r;

void setup() {
  size(500, 500);
  oscP5 = new OscP5(this,12000);
  remote = new NetAddress("127.0.0.1",3000);
  s = 10;
  stroke(255);
  reset();
  frameRate(200);
  img = loadImage("10.jpg");
  background(0);
  img.loadPixels();
}

void reset(){
  background(0);
  x = 0;
  y = 0;
  OscMessage msg = new OscMessage("/sync");
  msg.add(1);
  oscP5.send(msg,remote);
}

void draw() {
  if(x&gt;=width){ y+=s; x=0; }
  if(y&gt;=height) reset();
  delay(100);
  int loc = x + y*img.width;
  noStroke();
  color c = img.pixels[loc];
  // int alpha = (c &gt;&gt; 24) &amp; 0xFF;
  int red   = (c &gt;&gt; 16) &amp; 0xFF;
  int green = (c &gt;&gt; 8)  &amp; 0xFF;
  int blue  =  c        &amp; 0xFF;
  int gray = ((red + green + blue) / 3);
  // println(alpha + " " + red + " " + green + " " + blue);
  fill(c);
  rect(x++,y,4,4);
  // println(gray);
  OscMessage msg = new OscMessage("/grayscale");
  msg.add(gray);
  oscP5.send(msg,remote);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Reading specific data from a site</title>
      <link>https://forum.processing.org/two/discussion/23241/reading-specific-data-from-a-site</link>
      <pubDate>Wed, 28 Jun 2017 13:02:24 +0000</pubDate>
      <dc:creator>SaraMelody</dc:creator>
      <guid isPermaLink="false">23241@/two/discussions</guid>
      <description><![CDATA[<p>First a bit of backstory and info. So I am a gamer and a Twitch streamer.</p>

<p>I used Processing to create a donation randomizer (basically gives me something random to do to make things interesting when someone donates a specific amount) and a swear counter (which tallies the swears I say via keyboard input and keeps track of how much money I owe).</p>

<p>The thing I wanted to do with it, though is make it show the total number of donations as well as the total amount donated thus far (not just the donations that I owe for swearing like it does now). I am unsure of how to write the Processing code to read the data off of the website I collect donations through, though. I'm also entirely unsure as to if such a thing is even possible.</p>

<p>Thank you in advance for the help! ^_^</p>
]]></description>
   </item>
   <item>
      <title>HTTP Request</title>
      <link>https://forum.processing.org/two/discussion/22202/http-request</link>
      <pubDate>Tue, 25 Apr 2017 19:07:03 +0000</pubDate>
      <dc:creator>PauloBenson</dc:creator>
      <guid isPermaLink="false">22202@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>Im trying to request some information from a public transportation web site. I'm using the HTTP Request Library. And it have to POST an authentication for then  a GET to fetch the information.i'm getting a True return from the POST authentication... but a message : authorization denied.</p>

<p>Any Help?</p>

<pre><code>import http.requests.*;

public void setup() 
{
    size(400,400);
    smooth();
  String searchLinha = "8000";


    PostRequest post = new PostRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Login/Autenticar?token=4af5e3112da870ac5708c48b7a237b30206806f296e1d302e4cb611660e2e03f");



  GetRequest linhas = new GetRequest("http:" + "//api.olhovivo.sptrans.com.br/v0/Linha/CarregarDetalhes?codigoLinha");

  post.send();
  linhas.send();

  System.out.println("Reponse Content: " + post.getContent());
  System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));

  System.out.println("Reponse Content: " + linhas.getContent());
  System.out.println("Reponse Content-Length Header: " + linhas.getHeader("Content-Length"));


}
</code></pre>

<p>the Console:</p>

<pre><code>Apr 25, 2017 3:37:39 PM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {}
Reponse Content: true
Reponse Content-Length Header: 4
Reponse Content: {"Message":"Authorization has been denied for this request."}
Reponse Content-Length Header: 61
</code></pre>
]]></description>
   </item>
   <item>
      <title>HTTP POST request problem</title>
      <link>https://forum.processing.org/two/discussion/14354/http-post-request-problem</link>
      <pubDate>Fri, 08 Jan 2016 23:38:05 +0000</pubDate>
      <dc:creator>dangear</dc:creator>
      <guid isPermaLink="false">14354@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone!
I have a problem with <strong>HTTP request</strong> library.
I use this code:</p>

<pre><code>import http.requests.*;

import java.net.*;
import java.io.*;
import java.util.*;

String API="myApi"; // Api code
String answer="My answer"; // answer text
String messageTo="1111111"; // example integer
String urlAnswer = URLEncoder.encode(trim(answer)); // encode answer string
PostRequest post = new PostRequest("https://"+"api.telegram.org/bot"+API+"/sendmessage?chat_id="+messageTo+"&amp;text="+urlAnswer);
post.send();
</code></pre>

<p>and status monitor show me this error message:</p>

<pre><code>java.lang.NullPointerException
    at http.requests.PostRequest.send(Unknown Source)
    at sketch_160109a.setup(sketch_160109a.java:33)
    at processing.core.PApplet.handleDraw(PApplet.java:2373)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1523)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
</code></pre>

<p>But <strong>GET request</strong> work perfect.</p>

<p>Can somebody explain me how I fix this problem?</p>

<p><strong>I use Processing 3.0 on MacOS 10.9.5</strong></p>
]]></description>
   </item>
   <item>
      <title>File upload to server with .drop() ?</title>
      <link>https://forum.processing.org/two/discussion/19503/file-upload-to-server-with-drop</link>
      <pubDate>Sun, 04 Dec 2016 07:11:46 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">19503@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I've been loving .drop() to upload files to the browser (so quick!). But coming up blank looking for an example of taking it the next step: uploading from browser to server.</p>

<p>There are a ton of file upload examples using ajax/etc all over the web. But I'm missing the piece that takes the data created by .drop(). What am I not understanding about the data that drop() delivers? Have even tried copying and pasting the data from f.data from the console and into a new file and saving, but that doesn't work either... Seems like I'm missing something fundamental?</p>

<p>Here's some sample code:</p>

<pre>
var xhr = new XMLHttpRequest();
var formData = new FormData();

function gotFile(f) {
   console.log('gotFile: ' + f.name + ' ' + f.size + ' ' + f.type);
  formData.append('photos[]', f.data, f.name); //FAILING HERE, TypeError: Argument 2 of FormData.append is not an object.
  // Open the connection.
  xhr.open('POST', 'upload.php', true); //an upload script on server
  // Send the Data.
  xhr.send(formData);
}
// Set up a handler for when the request finishes.
xhr.onload = function () {
  if (xhr.status === 200) {
    // File(s) uploaded.
    console.log('uploaded');
  } else {
    console.log('upload error');
  }
};
</pre>
]]></description>
   </item>
   <item>
      <title>parse a tcp message</title>
      <link>https://forum.processing.org/two/discussion/17888/parse-a-tcp-message</link>
      <pubDate>Thu, 18 Aug 2016 13:30:39 +0000</pubDate>
      <dc:creator>gavanpreet28</dc:creator>
      <guid isPermaLink="false">17888@/two/discussions</guid>
      <description><![CDATA[<p>hi guys, i need some expert advice on this.</p>

<p>I have successfully created the tcp connection between processing and matlab. I am using oscp5 library for that.
I am sending an array containing x and y coordinates from processing and my intent is to draw a sine wave in matlab with these received x &amp; y values.</p>

<p>My question is how i can separate the coordinates after receiving in matlab?
Also, i think i need to alter some setting in tcpip object because i am not receiving the same values in matlab, which i am sending.</p>

<p>You can see the code and their values below.</p>

<pre><code>-------------Processing Code-------------
import oscP5.*;
import netP5.*;

OscMessage myMessage;
OscP5 oscP5tcpClient;

int xspacing = 16;   // How far apart should each horizontal location be spaced
int w;              // Width of entire wave
float theta = 0.0;  // Start angle at 0
float amplitude = 75.0;  // Height of wave
float period = 500.0;  // How many pixels before the wave repeats
float dx;  // Value for incrementing X, a function of period and xspacing
float[] yvalues;  // Using an array to store height values for the wave
int x;

void setup() {
  size(640, 360);
  oscP5tcpClient = new OscP5( this, "141.44.219.161", 1234, OscP5.TCP);
  w = width+16;
  dx = (TWO_PI / period) * xspacing;
  yvalues = new float[w/xspacing];
}

void draw() {
  background(0);


  calcWave();
  OscMessage myMessage = new OscMessage("/test");
  myMessage.add(new float[] { x*xspacing, height/2+yvalues[x]});  =====&gt;&gt;&gt; These values are sent to Matlab. 
  oscP5tcpClient.send(myMessage);
  print(x*xspacing, height/2+yvalues[x]);
}

void calcWave() {
  // Increment theta (try different values for 'angular velocity' here
  theta += 0.02;

  // For every x value, calculate a y value with sine function
  float x = theta;
  for (int i = 0; i &lt; yvalues.length; i++) {
    yvalues[i] = sin(x)*amplitude;
    x+=dx;
  }
}

void renderWave() {
  noStroke();
  fill(255);
  // A simple way to draw the wave with an ellipse at each location
  for (int x = 0; x &lt; yvalues.length; x++) {
    ellipse(x*xspacing, height/2+yvalues[x], 16, 16);
  }
</code></pre>

<h2>    }</h2>

<pre><code>--------------------------MATLAB Code----------------------------
&gt;&gt; tcpipServer = tcpip('141.44.219.161',1234,'NetworkRole','Server');
&gt;&gt; fopen(tcpipServer)
&gt;&gt; data =fread(tcpipServer)

data =

     0
     0
     0
    20
    47
   116
   101
   115
   116
     0
     0         ===&gt;&gt;&gt; these are values i am receving in matlab, which is completely different from what i am sending.
     0
    44
   102
   102
     0
     0
     0
     0
     0
    67
    53
   127
   249

&gt;&gt; 
------------------------------------------------------------------
</code></pre>

<p>Values which i am sending from processing is look something like below</p>

<h2>230.19330 229.068510 227.924120 226.760530 225.578230 224.37770 223.159410 221.923840 220.671510 219.40290 218.118520 216.818880 215.504520 214.175930 212.83370 211.47830 210.110320 208.730290 207.338760 205.936280 204.523440 203.100770 201.668870 200.228290 198.779620 197.323430 195.860320 194.390850 192.915620 191.435230 189.950270 188.461320 186.968980 185.473860 183.976550 182.477630 180.977740 179.477450 177.9773</h2>
]]></description>
   </item>
   <item>
      <title>OSC simple example support using Ketai or not</title>
      <link>https://forum.processing.org/two/discussion/15401/osc-simple-example-support-using-ketai-or-not</link>
      <pubDate>Thu, 10 Mar 2016 06:48:54 +0000</pubDate>
      <dc:creator>dattasaurabh82</dc:creator>
      <guid isPermaLink="false">15401@/two/discussions</guid>
      <description><![CDATA[<p>Just tinkering around. Recently I'm trying to make a simple example where two processing apps talk to each other over OSC (One running in android phone and the other in my computer)..</p>

<p>Now I first tried two apps both running in my computer (Both on local network 127.0.0.1 and swapped their ports) Here are the codes: Message sender (which send a random number every-time you mouse click in the applet window)</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

float val;

void setup() {
  size(200, 200);

  /* 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", 8000);
}


void draw() {
  background(255);
}

void mousePressed() {
  //constitute message:
  OscMessage myMessage = new OscMessage("/print");
  myMessage.add(random(10, 100));
  oscP5.send(myMessage, myRemoteLocation);
}
</code></pre>

<p>On the other hand the receiver processing app is kind of like this:</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

float val;

void setup() {
  size(200, 200);

  /* start oscP5, listening for incoming messages at port 8000 */
  oscP5 = new OscP5(this, 8000);
  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}


void draw() {
  background(0);
}

void oscEvent(OscMessage theOscMessage) {
 val = theOscMessage.get(0).floatValue();
 println("Val: " + val);
} 
</code></pre>

<p>Now they seem to work on the computer ..</p>

<p>I imagined when porting it for android, I should just hardcode the ip-addresses .. But it doesn't work .. Tried to look at some help from the ketai library , but there's no direct example for a simple communication.. One example(wifi_direct_remote_cursor) explains but it's very scattered. I couldn't understand why I need to check if I was on the same network and get client addresses and all ..</p>

<p>Can someone help me establish a simple example like above below , The message sender is the Android app and the message receiver is the computer app ..</p>

<p>Thanks in advance ..</p>
]]></description>
   </item>
   </channel>
</rss>