Forum

You must be logged in to post Login


Lost Your Password?

Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

iPhone to Bespoke OSC using TouchOSC

No Tags
UserPost

12:53 pm
April 11, 2011


Paul

Admin

posts 49

Hello Mazvydas,

I'm unfamiliar with TouchOSC, but from a quick google search, this iPhone app allows OSC packets to be sent from, or received by the iPhone using UDP. If I understand your question correctly, you're attempting to send OSC messages from your iPhone to your PC. If this is the case, then you won't set your PC to bind to the IP address and port used by the iPhone — quite the contrary. On the PC, you'll bind to whatever IP address your PC's ethernet adapter has been assigned (not the loopback address of 127.0.0.1). Likewise, the port you'll choose is up to you — as long as it's not in use by another application on your PC. The configuration, therefore, is on the iPhone. You'll configure the iPhone to send messages to the IP address and port specified on your PC.

Furthermore, be certain that you register the incoming OSC message address(es) to your PC's OscServer object — or that you disable the filtering of OSC messages on the PC. This is done with code such as:

sOscServer.RegisterMethod("/some/message")

or

sOscServer.FilterRegisteredMethods = False

Paul

 

Posted from Mazvydas on the comments page:

Hello, I am trying to communicate my iphone (with TouchOSC application) to my pc (using your example VB.net client application). I changed the ServerAddress to iphone’s IP on the local network and also the ServerPort to the same one as iphone uses. However the client does not seem to get signals from the iphone. What may be the problem? Maybe I’ve forgot to add/change something in the code?

Thanks.

7:22 am
April 12, 2011


Mazvydas

Guest

Post edited 7:55 am – April 12, 2011 by Mazvydas


Wow, thanks for a fast and informative reply. It works now!

Another short question.

If I understood correctly, the 'AliveMethod' filters the signals to a specific one that I have chosen. But could it be done in the opposite way:  is it possible to show all the messages received except one.

Just to make it clear  - I would like to filter only one signal not to be shown on the console.

Also, the TouchOSC not only sends messages, but also values in them (e.g. for defining whether a button is pressed or released). Is it possible to display it in the console?

 

Thanks.

9:06 am
April 12, 2011


Paul

Admin

posts 49

Hello Mazvydas,

To your first question, it's very simple to accept all messages except one. You'll do this within the message handler itself — not with a particular method call within the Bespoke OSC library. First, be certain that you've disabled message filtering by setting the OscServer FilterRegisteredMethods to False. For example:

sOscServer.FilterRegisteredMethods = False

Next, simply test the Message.Address for the specific OSC address that you don't want to handle. For example:

If e.Message.Address <> "/this/is/not/the/droid/you're/loooking/for" Then
' Code to handle the message
End If

To your second question, yes, the values you're describing are contained in the OscMessage.Data property. This is an array of Objects — which means each actual entry in the array will be any of of the supported data types: floats, doubles, ints (32-bit and 64-bit), strings, and byte arrays.

You can retrieve those objects by accessing the OscMessage.Data property by index (e.g. e.Message.Data(1)) or through the OscMessage.At() method (e.g. e.Message.At(Of Integer)(1)). If you wanted to simply iterate through the list of values, you could write code such as:

For Each value As Object In e.Message.Data

Console.WriteLine(String.Format("Type: {0} Value: {1}", value.GetType(), value))

Next

Paul

 

10:54 am
April 12, 2011


Mazvydas

Guest

Post edited 10:55 am – April 12, 2011 by Mazvydas


I am shocked. Honestly, I have'nt seen such a swift, informative and concrete support for a long time.

Thank you A LOT!!

12:58 pm
April 12, 2011


Mazvydas

Guest

One more little question to ask. I think this is going to be based more on vb.net coding itself rather than the library.

I wanted to make the program to check for a message and then indicate whether the value is '1'. Then, if these were true, it would do some coding.  My current code looks like this :

 

If e.Message.Address = "/1/push1" And e.Message.Data(1) = True Then

'code

End If

 But the vb.net gives me this error:

" Index was outside the bounds of the array. "

 

I am probably using the   e.Message.Data    wrong.

Sorry for stupid questions, I am only starting to understand the whole vb.net programing thing and I really appreciate your help.

Thanks.

2:30 pm
April 12, 2011


Paul

Admin

posts 49

Hi Mazyvdas,

Arrays start at index zero (0) and run to Array.Length. If you specify an index to an array less than zero or greather than Length, you'll get the exception you're describing. So, assuming your "/1/push1" OSC message contains at least one value, you'll access it through e.Message.Data(0).

Just be sure not to access the Data property past e.Message.Data.Length.

Also, I noticed in your code that you're testing e.Message.Data(1) — which you'll likely change to access Data(0) — against the value True. This implies that your value is a Boolean. Boolean values are either True or False and there is not implicit conversion between integers and Booleans. What I mean is, if your iPhone app is sending an integer value 1, your test against True will always fail. Likewise, the integer 0 is not False. If you're interested in testing for a specific integer than you need to compare integers to integers.

Likewise, if you're uncertain of the data type of the value, it's a bad idea just to assume that a comparison will succeed. For instance, in your example, if e.Message.Data(0) was a string, then a string comparison against a Boolean or an integer will throw an InvalidCastException.

You can test the data type of an object with code such as:

If TypeOf (e.Message.Data(0)) Is Integer Then

End If

Paul

No Tags

About the Bespoke Software forum



No Comment

Comments are closed.