void OnDataReceive(string address, OscDataHandle data) { lock (_queue) _queue.Enqueue(new Vector3(data.GetElementAsFloat(0), data.GetElementAsFloat(1), data.GetElementAsFloat(2))); }
/// <summary> /// This is the message handler for every OSC message we receive /// </summary> /// <param name="address">The URL path where this message was received</param> /// <param name="handle">A handle to access the value of the message</param> protected void PrimaryCallback(string address, OscDataHandle handle) { #if RESOLINK_DEBUG_OSC Debug.Log(address + " " + handle.GetElementAsString(0)); #endif if (m_AddressesToIgnore.Contains(address)) { return; } if (!AddressHandlers.TryGetValue(address, out var actionPair)) { // if we find a match in the template handlers, add a handler, otherwise ignore this address if (m_NewTemplateChecker.Process(address, out var newActionPair)) { AddCallbacks(address, newActionPair); actionPair = newActionPair; } else { m_AddressesToIgnore.Add(address); return; } } // immediately read the value from the OSC buffer to prevent values going to the wrong controls actionPair.ValueRead(handle); // queue user action here and call them next frame, on the main thread. // if the callback is null, that means it's a compound control, which will fire its own user callback if (actionPair.UserCallback != null) { m_ActionInvocationBuffer.Add(actionPair.UserCallback); } }
void OnMessageReceived(string address, OscDataHandle data) { var subAddressStartIndex = address.IndexOf('/', 1); var subAddress = address.Substring(subAddressStartIndex, address.Length - subAddressStartIndex).Split('/'); if (subAddress[1] == Values["Track"]) { switch (subAddress[2]) { case "azim": Angle = data.GetElementAsFloat(0).Map(-180, 180, -1, 1); break; case "ad": Angle = data.GetElementAsFloat(0); break; } } else if (data.GetElementAsString(0) != null && data.GetElementAsString(0) == Values["Track"]) { switch (subAddress[1]) { case "energy": var incomingEnergy = ((data.GetElementAsFloat(1) * Scale) - GainReduction).Clamp(0, 1); if (Energy == 0 && incomingEnergy > 0) { Onset = true; OnsetAngle = Angle; } Energy = incomingEnergy; break; } } }
void OnDataReceive(string address, OscDataHandle data) { lock (_floatQueue) { for (int i = 0; i < MAX_OSC_PARAMS; i++) { _floatQueue.Enqueue(data.GetElementAsFloat(i)); } } }
void CmdMsgCallback(string address, OscDataHandle data) { Debug.Log("Got OSC: " + address); // Debug.Log(string.Format("({0}, {1})", data.GetElementAsFloat(0), data.GetElementAsFloat(1))); string cmd = data.GetElementAsString(0); switch (cmd) { case "recenter": bRecvRecenter = true; break; default: Debug.Log("got unknown command: " + cmd); break; } }
void OnDataReceive(string address, OscDataHandle data) => BangCount++;
void OnDataReceive(string address, OscDataHandle data) { lock (_queue) _queue.Enqueue(data.GetElementAsFloat(0)); }
protected override float GetMessageValue(OscDataHandle dataHandle) { return(dataHandle.GetElementAsFloat(0)); }
protected override string GetMessageValue(OscDataHandle dataHandle) { return(dataHandle.GetElementAsString(0)); }
private void OnDataReceive(string address, OscDataHandle data) { var command = data.GetElementAsString(0); switch (command) { case "alive": for (var i = 1; i < data.GetElementCount(); i++) { var aliveId = data.GetElementAsInt(i); _addedCursors.Add(aliveId); } foreach (var value in cursors.Where(value => !_addedCursors.Contains(value.Key))) { _removedCursors.Add(value.Key); } break; case "set": if (data.GetElementCount() < 7) { return; } var id = data.GetElementAsInt(1); if (!cursors.TryGetValue(id, out var cursor)) { cursor = new CCTuioCursor(id); } cursor.Update( data.GetElementAsFloat(2), data.GetElementAsFloat(3), data.GetElementAsFloat(4), data.GetElementAsFloat(5), data.GetElementAsFloat(6) ); _updatedCursors.Add(cursor); break; case "fseq": if (data.GetElementCount() < 2) { return; } frameNumber = data.GetElementAsInt(1); _updatedCursors.ForEach(updatedCursor => { _addedCursors.ForEach(i => Debug.Log(i)); if (_addedCursors.Contains(updatedCursor.Id) && !cursors.ContainsKey(updatedCursor.Id)) { cursors.Add(updatedCursor.Id, updatedCursor); _addQueue.Enqueue(updatedCursor); } else { _updateQueue.Enqueue(updatedCursor); } }); _removedCursors.ForEach(cursorId => { _removeQueue.Enqueue(cursors[cursorId]); cursors.Remove(cursorId); }); _addedCursors.Clear(); _removedCursors.Clear(); _updatedCursors.Clear(); break; } }
public void InvokeFromHandle(OscDataHandle dataHandle) { Event.Invoke(GetMessageValue(dataHandle)); }
/// <summary> /// Extract a typed value from a data handle. /// </summary> /// <param name="dataHandle">The handle to extract from</param> /// <returns>The message value</returns> protected abstract T GetMessageValue(OscDataHandle dataHandle);
protected override bool GetMessageValue(OscDataHandle dataHandle) { return(dataHandle.GetElementAsInt(0) > 0); }