And in combination with G-Audio you could create real cool audio media installations
I try to setup some demos to show how convenience it is to use TouchOSC to control Unity. And G-Audio is one of the assets on my example list .
I’m extending UniOSCEventTarget, how do I receive all messages for the port, regardless of the address?
The keyboard in touch OSC communicates key index through the address parameter:
/8/push24 for example, where 8 is the current tab, push the instruction, 24 the index of the key. Data is just 0 or 1 ( press / release ).
Any classes in UniOSC that help parsing addresses, before I go along and code something myself? It seems mapping is only for the data parameter, anything for the address? It’d be great to setup in the inspector the address root and the message type: /8/push*, and just get 24 on or off in an override.
This is gonna be fun, I really need to make some time to dig into it further.
Actually, all you need to do is to make the _IsDispatchable method protected virtual instead of private. It would make sense to let users override this, and dispatch further themselves.
Gregzo
Edit: it seems you do have a receiveAllAddresses flag, it simply doesn’t show up in the inspector.
Should be an easy fix.
As you mentioned you should set the receiveAllAddresses flag ,so you don’t have to write all the OSC addresses you want to receive by yourself.
Then in the OnOSCMessageReceived method you can do something like this:
public override void OnOSCMessageReceived(UniOSCEventArgs args) {
if(args.Address.Equals(YOUR_ADDRESS_STRING_A)){}
if(args.Address.Equals(YOUR_ADDRESS_STRING_B)){}
.....
(Or a loop if you want to prevent too much if clauses)
}
I think this is the easiest way to parse different addresses with one script.
In general you have two options to receive multiple OSC addresses in a script.
If you look at the UniOSCChangeColor.cs script you see a variant where you filter addresses:
If you set the receiveAllAddresses flag to false you have to add your addresse before base.OnEnable() is called.
The other way is like above where you set receiveAllAddresses = true;
I know that it is easier to let receiveAllAddresses always true as you have to filter the addresses in the OnOSCMessageReceived method anyway, but I thought it would be better for performance if you could filter in an earlier step so OnOSCMessageReceived is not called everytime.
Don’t know if this is ‘overengineering’
Yeah, just seemed that since there’s a toggle for listenToAllPorts, one for receiveAllAddresses would make sense too ( in the inspector I mean ).
The way I’m doing it for these push messages is to find out if the string contains “push”, and parse the number after that.
string.Split( ‘/’ ) is also nice to retrieve tab index.
One other question: I’m getting very variable latency, from very good to very bad ( up to a few seconds, and sometimes messages dropped altogether ). Your videos seem to run at a stable, pretty decent latency - is my router to blame? Using TouchOSC on iPad 3. Getting the issue both in the editor and in builds, sending messages from the iPad to an iMac.
Could it be a UDP issue? In your videos, you’re demonstrating constant input mostly, not so much unique messages as in key presses.
I’ll try on another network to make sure. In the meantime, any insights are welcome!
I will make this option in the next release adjustable in the inspector. (Right now you could comment out [HideInInspector] in the UniOSCEventTarget.cs class.)
In the documentation I mentioned a point under ‘Common pitfalls’:
‘When you use the gyro data from TouchOSC other OSC controlled objects that listen on the same port canbegin to react sluggish. It’s best to use a separate device for the gyro and use another device on another port
for the other GameObjects.’
Perhaps this causes the latency. Don’t know if this is an general TouchOSC issue or if there are problems in my implementation. I will investigate that, but I suspect that this is an TouchOSC issue as it seems to work when you use a explicit port for the gyro.
Thanks! Good to hear that the setup is easy for others.
Great news!
I will update the documentation so others are directed into the right solution.
Many thanks for the review and the feedback ! It’s good to know that UniOSC is also an useful tool for others.
Feel free to post a video with your results. As UniOSCs benefit is a little bit of abstract it’s always good for other to see how you can change your workflow in the editor or at runtime.
Good job.
Was surprised to see my OSCsharp library within the files q:
And you are right, it has a problem with iOS and WP8… it doesn’t really work there.
Just submitted version 1.1 :
Session file support:
– Store the latest data that comes with a OSC message
– Send all data to update the GUI state of an external app like TouchOSC
Change in OSCsharp lib: made the TypeTag property of a OSC message accessible
-Type of the OSC data could now be verified with the Typetag string. (No GetType() necessary if you have performance problems)
receiveAllAddresses property is now accessible via the component inspector
UniOSCEventArgs could now be filtered by Group, AddressRoot or AddressIndex if the OSC address matches a specific pattern
Documentation update
I will make a video of the session feature so you can see how useful it is to update the GUI of TouchOSC to your last settings.
Submitted a hotfix version 1.1.1:
Scenes could not be published.
Method SelectObjectInHierachyFromGUID with editor related calls where moved to another section inside UniOSCUtils.cs