ModalityTeam / Modality-toolkit

A SuperCollider toolkit to simplify the creation of personal (electronic) instruments utilising hardware and software controllers of any kind.
http://modalityteam.github.io/
87 stars 26 forks source link

can't get feedback to work with Touch OSC #313

Closed geoffroymontel closed 5 years ago

geoffroymontel commented 5 years ago

I'm trying to use Touch OSC through Modality Toolkit. I'm running SC 3.9.3 and have installed Modality through Quarks.gui On my iPad running Touch OSC 1.9.10, I use the Simple Layout.

The following code works :

t = MKtl(\tosca, "touchosc-simple1");
t.device.updateSrcAddr("192.168.1.12", 63763); // IP and port of TouchOsc on my iPad as printed
t.gui;
t.elAt.action = { |el|
    "tOsc %: %\n".postf(el.name, el.value.round(0.001))
};

I'm getting values printed on the console when I move a slider on the iPad, like

tOsc sl_1: 0.316

Great.

But how do I set a value on SC side and have the slider move on the iPad ?

I tried

t.setValueAt(\sl_1, 0.0);

But the slider does not move on the iPad. Same if I move a slider on the GUI displayed by t.gui

If I type

OSCFunc.trace(true);

and move a slider on the iPad, I get the following on the console so IP and port seems to be OK.

OSC Message Received:
    time: 104.314042791
    address: a NetAddr(192.168.1.12, 63763)
    recvPort: 57120
    msg: [ /1/fader1, 0.49654316902161 ]

Thanks in advance for your help.

LFSaw commented 5 years ago

The description file does currently not have declared the elements as \inOut but rather \in. I am not sure, if bidirectional communication does work with OSC yet but you can try to change the slider descriptions in

MKtlDesc("touchosc-simple1").openFile

to be

// [...]
        (
            key: \sl,
            shared: (elementType: \slider, spec: \unipolar, ioType: \inout),
// [..]

Hope this will help :)

LFSaw commented 5 years ago

since this is not a bug, I'll close this.

LFSaw commented 5 years ago

feel free to comment though, I'll continue reading :)

geoffroymontel commented 5 years ago

Thanks @LFSaw ! Sorry for the delay, but I've just tried to change ioType so that

        (
            key: \sl,
            shared: (elementType: \slider, spec: \unipolar, ioType: \inout),
            elements: (1..4).collect { |num|
                (oscPath: "/1/fader%".format(num).asSymbol)
            }
        ),

but it makes no difference.

It seems bi-directionnal communication was implemented in OSC but a quick debug seems to show that the OSC message is not sent to the right IP/port. I will try to debug that later.

LFSaw commented 5 years ago

Great find! I'll link @adcxyz to this so that he is aware of it.

gilfuser commented 5 years ago

Hi Modality Crew and Geoffroy. I had something very similar working some time ago. I don't have a device with Touch OSC to test it again a.t.m., but here is the corresponding part of code in the description I used. Maybe there's a clue of what is going on:

(
key: \sl,
shared: (ioType: \inout),
elements: (
    6.collect {|i|
        (
            key: (i+1).asSymbol,
            oscPath: "/fxr1/fader%".format(i+1).asSymbol,
            elementType: 'slider', spec: \unipolar, style: (
                width: 5, height: 0.85, row: (i * 0.85), column: 4 )
        )
    }
)
)

The main difference seems to be: shared ioType parameter only and the others are set individually.

geoffroymontel commented 5 years ago

Thanks ! I've just submitted a pull request that seems to fix it on my side.