Remote Codec: Get value of an item [Solved]

Want to talk about music hardware or software that doesn't include Reason?
Post Reply
User avatar
MadMarcsen
Posts: 3
Joined: 29 Jan 2015
Location: /Germany/Aurich

02 Aug 2017

Hi there,

i have the following line in my codec:

Code: Select all

{name="ModEnvDest", input="value", output="value", min=0, max=5},
How can i extract the actual value of the item in the codec file? Is this possible with remote.get_item_value?

If im right, then it should be possible to create a function and call it from local inputs:

Code: Select all

{pattern="b? 10 xx", name="ModEnvDest", value="set_new_value()"},
I have tried a few things but failed with different error messages.

My goal is to increment the extracted value by 1 if an input is recognized on the given item. Therefore, i have a button inside a TouchOSC template that sends the value 1 if pressed. Remote than should recognize the input and increment the value. One can than press a button on the touch device and cycle, for example, through the different waveforms on oscillators.

I have little knowledge in C, but no experience in Lua.

Thank you.
Last edited by MadMarcsen on 02 Aug 2017, edited 1 time in total.

User avatar
artotaku
Posts: 652
Joined: 09 May 2015
Location: Munich, Germany
Contact:

02 Aug 2017

You can ask for the current value of a remote item with

remote.get_remote_value(item_index)

where item_index is the index of the item where it has been put into the items array/map in remote_init() function.

There is another one returning an object containing further information about the remote item:
remote.get_item_state(item_index)

User avatar
MadMarcsen
Posts: 3
Joined: 29 Jan 2015
Location: /Germany/Aurich

02 Aug 2017

@artotaku:

Thank you for your reply.

In the meanwhile i solved the problem:

Code: Select all

g_fnord_item_index = 12

function set_new_value(x)
    local button_value = remote.get_item_value(g_fnord_item_index)

    if (button_value >=0 and button_value <=4 and x == 1) then
        button_value = button_value + 1
    end

    if (button_value >0 and button_value <=5 and x == 0) then
        button_value = button_value - 1
    end

    return (button_value)

end
The function is called by from local inputs:

Code: Select all

{pattern="b? 10 xx", name="ModEnvDest", value="set_new_value(x)"},
I have two buttons inside a TouchOSC template. One button always sends value 0, the other one 1. The value is then passed to the function and there the value of the item gets increased or decreased. Also, there's a check if min and max values are ok:

Code: Select all

{name="ModEnvDest", input="value", output="value", min=0, max=5},

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests