Вот мой компьютер/ код рабочего стола:
Код: Выделить всё
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int colour = 255;
void setup()
{
size(600, 600);
/* start oscP5, listening for incoming messages at port 1200 */
oscP5 = new OscP5(this,1200);
println(this);
/* the address of this device */
myRemoteLocation = new NetAddress("127.0.0.1",1300);
}
void draw()
{
background(0);
fill(colour);
circle(width/2, height/2, 200);
int i = int(random(0, 200));
if (i == 1) sendmessage();
}
void sendmessage()
{
/* create the message */
OscMessage myMessage = new OscMessage("/one");
color c = color(random(0, 255), random(0, 255), random(0, 255));
myMessage.add(c);
/* send the message */
println("Sending message: " + myMessage);
oscP5.send(myMessage, myRemoteLocation);
}
/* incoming osc message are forwarded to the oscEvent method */
void oscEvent(OscMessage theOscMessage)
{
colour = theOscMessage.get(0).intValue();
}
Код: Выделить всё
### [2024/11/7 17:12:20] PROCESS @ OscP5 stopped.
### [2024/11/7 17:12:20] PROCESS @ UdpClient.openSocket udp socket initialized.
### [2024/11/7 17:12:21] PROCESS @ UdpServer.start() new Unicast DatagramSocket created @ port 1200
### [2024/11/7 17:12:21] PROCESS @ UdpServer.run() UdpServer is running @ 1200
### [2024/11/7 17:12:21] INFO @ OscP5 is running. you (192.168.0.106) are listening @ port 1200
Вот код, который работает на телефоне Android:
Код: Выделить всё
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int colour = 255;
void setup()
{
size(600, 600);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,1300);
println(this);
/* the address of this device */
myRemoteLocation = new NetAddress("127.0.0.1",1200);
}
void draw()
{
background(0);
fill(colour);
circle(width/2, height/2, 200);
int i = int(random(0, 200));
if (i == 1) sendmessage();
}
void sendmessage()
{
/* create the message */
OscMessage myMessage = new OscMessage("/two");
color c = color(random(0, 255), random(0, 255), random(0, 255));
myMessage.add(c);
/* send the message */
println("Sending message: " + myMessage);
oscP5.send(myMessage, myRemoteLocation);
}
/* incoming osc message are forwarded to the oscEvent method */
void oscEvent(OscMessage theOscMessage)
{
colour = theOscMessage.get(0).intValue();
}
Код: Выделить всё
Код: Выделить всё
### [2024/11/7 17:29:23] PROCESS @ OscP5 stopped.
### [2024/11/7 17:29:23] PROCESS @ UdpClient.openSocket udp socket initialized.
### [2024/11/7 17:29:24] PROCESS @ UdpServer.start() new Unicast DatagramSocket created @ port 1300
### [2024/11/7 17:29:24] PROCESS @ UdpServer.run() UdpServer is running @ 1300
### [2024/11/7 17:29:24] INFO @ OscP5 is running. you (127.0.0.1) are listening @ port 1300
Оба эскиза работают, но не взаимодействуют друг с другом. Если я запускаю эскиз Android на настольном компьютере вместе с компьютерным эскизом, они без проблем взаимодействуют в обоих направлениях. Что я здесь упускаю/упускаю из виду?
Подробнее здесь: https://stackoverflow.com/questions/791 ... id-and-osx