【问题标题】:Trouble running oscp5 library and P3D renderer together in processing 3.x在处理 3.x 中同时运行 oscp5 库和 P3D 渲染器时出现问题
【发布时间】:2019-04-26 08:14:21
【问题描述】:

我试图从外部设备映射数据以绘制图案。但是 oscP5 库和 P3D 渲染器在处理 3.3.7 和 3.4 时不能一起工作,而它们可以单独工作。它们可以处理 2.2.1 但 2.2.1 不支持声音库。谁知道怎么解决?

import oscP5.*;
OscP5 oscP5;

float value;

void setup(){
size(400, 400, P3D);
rectMode(CENTER);
oscP5 = new OscP5(this, 60000);
}

void oscEvent(OscMessage theOscMessage){
  if (theOscMessage.checkAddrPattern("/ATT")){
    value = theOscMessage.get(0).floatValue();
  }
}

void draw(){
  background(0);
  noStroke();
  fill(255);
  float r = second()/10;
  rotateZ(r);
  rect(width/2, height/2, value, value);
}

The error when oscP5 and P3D work together

【问题讨论】:

  • 您能发一个minimal reproducible example 来说明问题吗?
  • 您好,非常感谢!我刚刚添加了一个代码示例。
  • @LamKo 如果您在运行此草图后启动软件在端口 60000 上发送数据,是否还会发生这种情况?您能否发布一个发送 OSC 数据的最小示例? (在处理 3.4 上,如果我不发送任何 OSC 数据,上述代码运行不会出错)
  • 我把我的答案贴上了,非常感谢!

标签: java processing visualization osc oscp5


【解决方案1】:

我解决了这个问题。 在我的原始代码中, setup() 中有一个 frameRate 初始化(如下所示的最小示例),我没有意识到是它导致了问题(因为 frameRate 初始化在分别与 oscP5 或 P3D 一起使用时不会导致错误)所以我没有写在我的问题中。 现在我删除了 frameRate 初始化行(frameRate(30)),然后 oscP5 和 P3D 最终可以一起工作(即使我仍然很困惑,但这并不影响我目前的工作)。

import oscP5.*;
OscP5 oscP5;

float value;

void setup(){
size(400, 400, P3D);
// the following line causes the error when oscP5 and P3D attempt to work together,
// but the code works when there is either oscP5 and P3D, oscP5 and frameRate or P3D and frameRate.
frameRate(30);
rectMode(CENTER);
oscP5 = new OscP5(this, 60000);
}

void oscEvent(OscMessage theOscMessage){
  if (theOscMessage.checkAddrPattern("/ATT")){
  value = theOscMessage.get(0).floatValue();
  }
}

void draw(){
  background(0);
  noStroke();
  fill(255);
  float r = second()/10;
  rotateZ(r);
  rect(width/2, height/2, value, value);
}

希望我解释清楚。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 2016-01-25
    • 1970-01-01
    相关资源
    最近更新 更多