Receiving Arrays, Lists, VecNf in JS process ValueInlet?


#1

Is ti possible?
Is there an equivalent to the “.message” methode for midi inlet?

ValueInlet allows to set id, min, max but not type.

As of commit b341cb1

feading the output of an XY automation to a JS ValueInlet returns

Debug: JS::ValueInlet(0x55d0ac180020) (:13)

from the “console.log”

calling “.value” on it is not defined


#2
import QtQuick 2.0
import Score 1.0
Item {
  ValueInlet { id: in1 }

  function onTick(oldtime, time, position, offset) {
    console.log(in1.value.x, in1.value.y)
  }
}

:wink:


#3

there’s a bug with lists though, investigating


#4

Savage!!

for outputing i just constructed the array as such

xy0ut.value = [xVal * (1 + xOfset.value), yVal * (1 + yOfset.value)]; 

and it works great!
even when sending it to a Cart3D.
Welle done!

is there a better, more sorrect way tho?


#5

no that looks very good


#6

found the bug, pushing a new release


#7

Also here’s how to use JS when there are lists :

import QtQuick 2.0
import Score 1.0
Item {
  ValueInlet { id: in1 }
 
  function onTick(oldtime, time, position, offset) {
    if(in1.value !== undefined)
    {
      for (var i=0; i<in1.value.length; i++)
        console.log("Array item:", in1.value[i])
    }
  }
}

#8

Perfet!!

Thanks.
Is there a place in the source code you could point to for further refference of this can just be found in QML documentation?


#9

Yes, so basically all the ValueInlet, etc… types are defined here :

  • When there is a W_PROPERTY, it means that in the QML code you can directly read and write to the member. e.g.

    W_PROPERTY(QString, address READ address WRITE setAddress NOTIFY addressChanged)
    

means that you can do console.log(address) or address: "/foo/bar"

  • W_SLOT means that this is a function that can be called from QML

It would be nice to write this as a documentation.


#10

Perfect!
Thanks!

I will get on this documentation shortly.
Leave it with me.