本文整理汇总了C#中OscMessage类的典型用法代码示例。如果您正苦于以下问题:C# OscMessage类的具体用法?C# OscMessage怎么用?C# OscMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OscMessage类属于命名空间,在下文中一共展示了OscMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Broadcast
private void Broadcast(OscMessage message)
{
foreach (var oscSender in this.oscSenders)
{
oscSender.Send(message);
}
}
示例2: WiiMoteOscMsgHandler
public void WiiMoteOscMsgHandler(OscMessage oscMeg)
{
//Debug.Log (oscMeg.Address);
ArrayList values = oscMeg.Values;
string[] strings;
if (!initialFlag)
initialFlag = true;
for (int i = 0; i < values.Count; i++) {
strings = values[i].ToString().Split(':');
Debug.Log (i + ": "+ values[i]);
if(int.Parse(strings[1]) == 1)
ir_state[i] = true;
else
ir_state[i] = false;
string[] positionStrings = strings[2].Split(',');
float positionX = float.Parse(positionStrings[0]);
float positionY = float.Parse(positionStrings[1]);
ir_position[i] = new Vector2(positionX,positionY);
WiiVRUpdate();
}
}
示例3: OSCCallback
public void OSCCallback(OscMessage m)
{
if (verbose) {
string command = (string) m.Values[0];
string osc_report_string = "";
//print("OSC command is " + command);
for (int i = 0; i < m.Values.Count; i++) {
osc_report_string = osc_report_string + "Values[" + i + "]: " + m.Values[i] + "***";
}
//print("osc_report_string: " + osc_report_string + "\n");
}
oscMessagesToSend.Add(m);
//obsolete code, but we do need to figure out how to better handle MIDI notes,
//or if we should even handle them at all (and instead only use CC)
/*
if(command == "midievent") {
midiEventReceiver((string)m.Values[1], (int)m.Values[2], (int)m.Values[3]);
}
else if (command == "scenechange") {
if (verbose) {
Debug.Log("SCENE CHANGE!!!!!!!!!");
}
sceneChange = (int) m.Values[1];
}
else if (command == "cc") {
//string messageName = "onCC";
}
*/
}
示例4: AllMessageHandler
public void AllMessageHandler(OscMessage message){
Debug.Log(message);
Debug.Log("stuff sent");
string msgAddress = message.Address; //the message parameters
string msgString = Osc.OscMessageToString(message); //the message and value combined
float myValue = (float)message.Values[0];
int iValue = Mathf.RoundToInt(myValue);
yRot = iValue;
Debug.Log(msgAddress);
//FUNCTIONS YOU WANT CALLED WHEN A SPECIFIC MESSAGE IS RECEIVED
switch (msgAddress){
case "/1/push1":
xRot = iValue;
break;
case "/1/push2":
yRot = iValue;
break;
case "/1/push3":
zRot = iValue;
break;
case "/1/fader1":
scaleVal = 1+iValue;
break;
default:
//
break;
}
}
示例5: CreateTestBundle
private static OscBundle CreateTestBundle()
{
IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
OscBundle bundle = new OscBundle(sourceEndPoint);
OscBundle nestedBundle = new OscBundle(sourceEndPoint);
OscMessage nestedMessage = new OscMessage(sourceEndPoint, TestMethod);
nestedMessage.AppendNil();
nestedMessage.Append("Some String");
nestedMessage.Append(10);
nestedMessage.Append(100000L);
nestedMessage.Append(1234.567f);
nestedMessage.Append(10.0012345);
nestedMessage.Append(new byte[] { 1, 2, 3, 4 });
nestedMessage.Append(new OscTimeTag());
nestedMessage.Append('c');
nestedMessage.Append(Color.DarkGoldenrod);
nestedMessage.Append(true);
nestedMessage.Append(false);
nestedMessage.Append(float.PositiveInfinity);
nestedBundle.Append(nestedMessage);
bundle.Append(nestedBundle);
OscMessage message = new OscMessage(sourceEndPoint, AliveMethod);
message.Append(9876.543f);
bundle.Append(message);
return bundle;
}
示例6: ReceiveMessage
protected override void ReceiveMessage(OscMessage message)
{
// Debug.Log(message);
/* // addresses must be listed in Inspector/Osc Addresses
if (message.Address.Equals("/vicon/Position0"))
{
var v = new Vector3((float)(double)message[0], (float)(double)message[2] - 1, (float)(double)message[1]);
playerController.transform.localPosition = v;
}
else if (message.Address.Equals("/vicon/Quaternion0"))
{
//var q = new Quaternion((float)(double)message[0], (float)(double)message[1], (float)(double)message[2], (float)(double)message[3]);
}
else*/ if (message.Address.Equals("/niw/client/aggregator/floorcontact"))
{
// Floor input
int id = (int)message[1];
float x = (((float)message[2]) / 6.0f);
float z = (((float)message[3]) / 6.0f);
var position = new Vector3(x, 0, z);
Debug.Log(position);
RacketObject.GetComponent<Racket>().SendMessage("SetPosition", new Vector3(0, 0, x));
}
}
示例7: BuildBeatMessage
private void BuildBeatMessage(int[][] score, OscMessage m)
{
for (var trackCount = 0; trackCount < numberOfTracks; trackCount++)
{
BuildTrackMessage(score, m, trackCount);
}
}
示例8: MessageHandler
// called every time Unity receives a message
public void MessageHandler(OscMessage message)
{
// string msgString = Osc.OscMessageToString(message);
//MainDebug.WriteLine(msgString); // writing out the message to see if everything works correctly
//Debug.Log (msgString);
// clean debug message
string debugLine = "received for adress : ";
debugLine += message.Address + " with values : ";
int j = 0;
foreach (object o in message.Values) {
debugLine += o.ToString () + ", ";
OSCvalues [j] = float.Parse (message.Values [j].ToString ());
j++;
}
Debug.Log (debugLine);
if (message.Address == "/gain"){
float gain = float.Parse(message.Values[0].ToString());
colorCorrect.gain = Mathf.Pow (10,(gain*2));
}
if (message.Address == "/gamma"){
float gamma = float.Parse(message.Values[0].ToString());
colorCorrect.gamma = 1/(gamma*2);
}
if (message.Address == "/black"){
colorCorrect.black = float.Parse(message.Values[0].ToString());
}
}
示例9: Update
void Update()
{
// If we are going to send 'as bundle', then we would like OSC io
// to add the timetag to the messeges contained in the bundle.
oscIn.addTimeTagsToBundledMessages = sendAsBundle;
// Create a messege
OscMessage message = new OscMessage( address );
// Create a timetag. Default time is DateTime.Now.
OscTimeTag timetag = new OscTimeTag();
// Make it 1 milisecond into the future.
timetag.time = timetag.time.AddMilliseconds( 1 );
// Two possible methods for sending timetags ...
if( sendAsBundle )
{
// Either create a bundle with the timetag, add the message and send.
OscBundle bundle = new OscBundle( timetag );
bundle.Add( message );
oscOut.Send( bundle );
} else {
// Or add the timetag to message and send it.
message.Add( timetag );
oscOut.Send( message );
}
// Update label.
sendLabel.text = timetag.time + ":" + timetag.time.Millisecond;
}
示例10: AllMessageHandler
public void AllMessageHandler(OscMessage oscMessage) {
string msg = Osc.OscMessageToString (oscMessage).Substring (1);
string[] _vals = msg.Split (' ');
float[] vals = new float[_vals.Length];
for (int i = 0; i < vals.Length; i++)
vals[i] = float.Parse(_vals[i]);
}
示例11: OSCMessageReceiver
public override void OSCMessageReceiver(OscMessage message)
{
if (emit) {
emitter.Emit();
}
Debug.Log("Message...");
}
示例12: SendMessage
private void SendMessage(Action<OscMessage> appendAction)
{
var message = new OscMessage(endPoint, "/");
appendAction(message);
message.Send(endPoint);
}
示例13: Send
public void Send(OscMessage msg)
{
if (m_SendController != null)
{
// Send the message
m_SendController.Sender.Send(msg);
}
}
示例14: MetaHandler
public void MetaHandler(OscMessage oscMessage)
{
library.step = (int)oscMessage.Values[0];
library.numSteps = (int)oscMessage.Values[1];
int numPatterns = (int)oscMessage.Values[2];
library.SetNumPatterns(numPatterns);
Debug.Log("Meta found");
}
示例15: OnMessageReceived
void OnMessageReceived( OscMessage message )
{
// Get the time tag.
OscTimeTag timeTag;
if( !message.TryGet( 0, out timeTag ) ) return;
// Update label.
receiveLabel.text = timeTag.time + ":" + timeTag.time.Millisecond;
}