TouchOSC not controling slider on PC

Hi this is my first post.

I followed the following tutorial on Youtube on how to control sliders with TouchOSC from my iPhone to my PC.

Getting the phone set up was easy, but the sliders on the phone does not control the sliders on the PC like it is suppose to do. The code looks like it is 100% correct, I did follow the video as good as I could.

If I were using the wrong IP address I would not have been able to create and send the TouchOSC interface to my phone, so I do not think it is that. At the bottom of the code it shows my IP address and that is in deed the same as on my PC.

Help I’m not making headway…in communicating from my phone (TouchOSC app) to my PC.

<html><body><pre>
<span style="color: #33997E;">import</span> netP5.*;
<span style="color: #33997E;">import</span> oscP5.*;

OscP5&nbsp;oscP5;

<span style="color: #E2661A;">float</span> redAmount = 0.0f;
<span style="color: #E2661A;">float</span> greenAmount = 0.0f;
<span style="color: #E2661A;">float</span> blueAmount = 0.0f;

<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>setup</b></span>() {
&nbsp;&nbsp;<span style="color: #006699;">size</span>(320, 480);
&nbsp;&nbsp;<span style="color: #006699;">background</span>(0);
&nbsp;&nbsp;oscP5&nbsp;=&nbsp;<span style="color: #33997E;">new</span> OscP5(<span style="color: #33997E;">this</span>, 8000);
}

<span style="color: #33997E;">void</span> <span style="color: #006699;"><b>draw</b></span>() {
&nbsp;&nbsp;<span style="color: #006699;">background</span>(redAmount, greenAmount, blueAmount);

&nbsp;&nbsp;<span style="color: #006699;">fill</span>(0);
&nbsp;&nbsp;<span style="color: #666666;">//red rect</span>
&nbsp;&nbsp;<span style="color: #006699;">stroke</span>(255, 0, 0);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(34, 39, 67, 255);
&nbsp;&nbsp;<span style="color: #006699;">fill</span>(50, 40, 40);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(34, 39+255, 67, -redAmount);

&nbsp;&nbsp;<span style="color: #666666;">//green rect</span>
&nbsp;&nbsp;<span style="color: #006699;">fill</span>(0);
&nbsp;&nbsp;<span style="color: #006699;">stroke</span>(0, 255, 0);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(124, 39, 67, 255);
&nbsp;&nbsp;<span style="color: #006699;">fill</span>(40, 50, 40);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(124, 39+255, 67, -greenAmount);

&nbsp;&nbsp;<span style="color: #666666;">//blue rect</span>
&nbsp;&nbsp;<span style="color: #006699;">fill</span>(0);
&nbsp;&nbsp;<span style="color: #006699;">stroke</span>(0, 0, 255);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(216, 39, 67, 255);
&nbsp;&nbsp;<span style="color: #006699;">fill</span>(40, 40, 50);
&nbsp;&nbsp;<span style="color: #006699;">rect</span>(216, 39+255, 67, -blueAmount);
}

<span style="color: #33997E;">void</span> oscEvent(OscMessage theOscMessage) {
&nbsp;&nbsp;<span style="color: #E2661A;">String</span> addr = theOscMessage.addrPattern();
&nbsp;&nbsp;<span style="color: #E2661A;">float</span> val = theOscMessage.<span style="color: #006699;">get</span>(0).floatValue();

&nbsp;&nbsp;<span style="color: #669900;">if</span> (addr.<span style="color: #006699;">equals</span>(<span style="color: #7D4793;">&quot;/1/red&quot;</span>)) { 
&nbsp;&nbsp;&nbsp;&nbsp;redAmount&nbsp;=&nbsp;val;
&nbsp;&nbsp;}
&nbsp;&nbsp;<span style="color: #669900;">if</span> (addr.<span style="color: #006699;">equals</span>(<span style="color: #7D4793;">&quot;/1/green&quot;</span>)) { 
&nbsp;&nbsp;&nbsp;&nbsp;greenAmount&nbsp;=&nbsp;val;
&nbsp;&nbsp;}
&nbsp;&nbsp;<span style="color: #669900;">if</span> (addr.<span style="color: #006699;">equals</span>(<span style="color: #7D4793;">&quot;/1/blue&quot;</span>)) { 
&nbsp;&nbsp;&nbsp;&nbsp;blueAmount&nbsp;=&nbsp;val;
&nbsp;&nbsp;}
}

</pre></body></html>

Can you provide a link to your video. Also, can you check the code you provided. It seems the code you provided included markup formatting tags aka. HTML. Can you try editing your post and pasting your code making sure it does not have any formatting added in the pasting operation. You can also provide a link where you got this code from (is it from github?) or provide a link of your code via hastebin.

Kf

1 Like

Here is my code and link to Youtube video where I got it https://www.processing.org/download/support.html:

import netP5.;
import oscP5.
;

OscP5 oscP5;

float redAmount = 0.0f;
float greenAmount = 0.0f;
float blueAmount = 0.0f;

void setup() {
size(320, 480);
background(0);
oscP5 = new OscP5(this, 8000);
}

void draw() {
background(redAmount, greenAmount, blueAmount);

fill(0);
//red rect
stroke(255, 0, 0);
rect(34, 39, 67, 255);
fill(50, 40, 40);
rect(34, 39+255, 67, -redAmount);

//green rect
fill(0);
stroke(0, 255, 0);
rect(124, 39, 67, 255);
fill(40, 50, 40);
rect(124, 39+255, 67, -greenAmount);

//blue rect
fill(0);
stroke(0, 0, 255);
rect(216, 39, 67, 255);
fill(40, 40, 50);
rect(216, 39+255, 67, -blueAmount);

}

void oscEvent(OscMessage theOscMessage){
String addr = theOscMessage.addrPattern();
float val = theOscMessage.get(0).floatValue();

if(addr.equals("/1/red")){ redAmount = val;}
if(addr.equals("/1/green")){ greenAmount = val;}
if(addr.equals("/1/blue")){ blueAmount = val;}

}