ossia / libossia

A modern C++, cross-environment distributed object model for creative coding and interaction scoring
https://ossia.io
GNU Lesser General Public License v3.0
206 stars 33 forks source link

OSCQuery parameters incorrect? #550

Closed x37v closed 4 years ago

x37v commented 4 years ago

I think that libossia doesn't conform to the OSCQuery protocol exactly for its json output, namely, VALUE and CLIPMODE values should be arrays.

If you look in the examples here: https://github.com/Vidvox/OSCQueryProposal#oscquery-examples

you'll see that nodes with only one value still respond with an array of "VALUE": [ 0.5 ]

a simple ossia program, using automatic rust bindings: ossia-sys

  use ossia_sys::*;
  use std::ffi::CString;

  fn main() {
      unsafe {
          let proto = ossia_protocol_oscquery_server_create(1234, 5678);
          let dev = ossia_device_create(proto, CString::new("supersoftware").unwrap().as_ptr());
          let root = ossia_device_get_root_node(dev);
          let p = ossia_create_parameter(
              root,
              CString::new("foo").unwrap().as_ptr(),
              CString::new("float").unwrap().as_ptr(),
          );
          ossia_parameter_push_f(p, 0.5f32);
          let p = ossia_create_parameter(
              root,
              CString::new("bar").unwrap().as_ptr(),
              CString::new("vec2").unwrap().as_ptr(),
          );
          ossia_parameter_push_2f(p, 1f32, 2f32);
      }
      loop {
          std::thread::sleep(std::time::Duration::from_millis(10));
      }
  }

produces curl http://192.168.11.119:5678

{
  "FULL_PATH": "/",
  "CONTENTS": {
    "foo": {
      "FULL_PATH": "/foo",
      "TYPE": "f",
      "VALUE": 0.5,
      "ACCESS": 3,
      "CLIPMODE": "none"
    },
    "bar": {
      "FULL_PATH": "/bar",
      "TYPE": "ff",
      "VALUE": [
        1,
        2
      ],
      "ACCESS": 3,
      "CLIPMODE": "none",
      "EXTENDED_TYPE": "vecf"
    }
  }
}

note that the VALUE for /foo is not in an array and the CLIPMODE for both /foo and /bar aren't either

jcelerier commented 4 years ago

hey ! before everything, super nice idea to do a Rust binding. I'd be interested to get a proper one going at some point that would directly call the C++ API, as going through the C API needs to do some more memory allocations. Do you know how easy it is to call directly into C++ from Rust ? I know that D can do that for instance. Otherwise, it would likely be possible to get a Rust OSCQuery library going.

Regarding this point, this was actually discussed here : https://github.com/Vidvox/OSCQueryProposal/issues/35 - when there is no array the argument applies to all parameters (else it would be super wasteful to have an array with a couple hundred elements all clipped)

jcelerier commented 4 years ago

@pchdev you've been doing some Rust (right?) so including you there :p

x37v commented 4 years ago

Regarding this point, this was actually discussed here : Vidvox/OSCQueryProposal#35 - when there is no array the argument applies to all parameters (else it would be super wasteful to have an array with a couple hundred elements all clipped)

Ahh, okay, I see If all of the elements of one of these optional attribute share the same value, it's acceptable to only list a single value (which clients will assume corresponds to all of the elements) for the sake of brevity. Cool.