I need help to get OSC in Processing enabled

Dear Community,

I need help to write two little Scripts.

1.) A Script which sends a OSC Message 2.) A Script which received this OSC Message

Can anybody give me a advice which to write this two little Programms

In hope of Help

ComputerArtist_ThL

Hi @ComputerArtist_ThL and welcome to the forum!

Do you want to write the OSC code from scratch, or would you be happy using an existing library?

There’s a Processing library for this called oscP5.

It comes with examples for both sending and receiving OSC messages, which should cover exactly what you need.

Hi @sableraph

Thank you for your Answer.

Yes I have read that this Library exists. And I would used it. But I can not write a little script to use it. The Problem is that I have not found the example script. Can you give me a Link to this script.

Thank you for your Answer

ComputerArtist-ThL

I have found the Example in the Library Page you have give me

But I can not let run this Programm

It’s start correctly. But when I press any Key it would only received on Message and stop.

I have archived a Solution for Sending OSC.

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress remoteLocation;

void setup() {
  size(400, 200);
  // Zieladresse: IP und Port
  remoteLocation = new NetAddress("127.0.0.1", 1234);
  // Initiiere OscP5 ohne zu empfangen (nur senden)
  oscP5 = new OscP5(this, 1234); // eigener (lokaler) Port, kann beliebig sein

  println("Drücke eine Taste, um eine OSC Nachricht zu senden.");
}

void draw() {
  background(30);
  fill(255);
  textAlign(CENTER, CENTER);
  text("Drücke eine Taste für OSC Nachricht", width / 2, height / 2);
}

void keyPressed() {
  // Erzeuge eine neue OSC Nachricht mit einem bestimmten Address-Pattern
  OscMessage msg = new OscMessage("/test");
  msg.add(frameCount); // z.B. eine Zahl
  msg.add(frameCount); // z.B. eine Zahl

  // Sende die Nachricht an die Zieladresse
  oscP5.send(msg, remoteLocation);

  println("OSC Nachricht gesendet: " + msg);
}

But I have not a Working Version for Reveivement