예제 #1
0
  // OSC\u9001\u4fe1
  public void sendOSC(ArrayList<dotObj> theList, OscMessage message, String prefix) {

    if (theList.size() > 0) {
      // \u901a\u4fe1\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u521d\u671f\u5316
      message.clear();
      // prefix\u306e\u6307\u5b9a
      message.setAddrPattern(prefix);
      // \u5024\u306e\u6307\u5b9a(\u4e0b\u8a18\u306e\u3088\u3046\u306b\u7d9a\u3051\u3066\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067PureData\u3067\u306flist\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b)
      // message.add(mouseX);
      // message.add(mouseY);

      float average = 0;
      for (int i = 0; i < theList.size(); i++) {
        average += theList.get(i).val;
      }
      average = average / theList.size();
      // println(average);

      for (int i = 0; i < theList.size(); i++) {
        float val = map(theList.get(i).val, -0.7f, 0.7f, 0, 127);
        // float zero_shift_val = theList.get(i).val - average;
        // float val = map(zero_shift_val, -0.02, 0.02, 0, 127);
        message.add(val);
      }

      // OSC\u306e\u9001\u4fe1
      oscP5.send(message, myRemoteLocation);
    }
  }
예제 #2
0
  public static void sendOSC(
      String ipAddress, long port, String oscAddress, Iterable<Double> oscArguments) {
    OscMessage message = new OscMessage(oscAddress);

    Iterator iterator = oscArguments.iterator();
    while (iterator.hasNext()) {
      message.add(((Double) iterator.next()).floatValue());
    }

    UdpClient c = new UdpClient(ipAddress, (int) port);
    c.send(message.getBytes());
  }