private async void OSCClient_OnReceive(OSCPacket message) { #if DEBUG var t = Task.Factory.StartNew(() => { if (!(_disableDebugOutput)) Debug.WriteLine(String.Format("Received from Device, Address: {0}, Value: {1}", message.Address, message.Value<object>())); }); #endif if (message.Address.StartsWith("/meters")) await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => HandleMeters(message)); if (Application.ReceiveFromDevice(message.Address, message.Value<object>())) return; }
private void HandleMeters(OSCPacket message) { MemoryStream stream = message.Value<MemoryStream>(); var reader = new BinaryReader(stream); int size = reader.ReadInt32(); float[] data = new float[size]; for (int i = 0; i < size; i++) data[i] = reader.ReadInt16() / 256 + 80; reader.Dispose(); stream.Dispose(); for (int i = 0; i < 8; i++) { Application.Channels[i].Meter = data[i]; } }