/// <summary> /// Transforms data, if necessary, before sending it to a connected OSC device</summary> /// <param name="data">The data taken from 'common', using 'info'</param> /// <param name="common">The object whose properties or data are being broadcast. This would have /// come from ObservableToCommon().</param> /// <param name="info">The OSC address info for this data</param> /// <returns>The transformed data, ready to be sent</returns> protected override object PrepareDataForSending(object data, object common, OscAddressInfo info) { // This is a Liine Lemur specific conversion of booleans to floats, even though OSC has a boolean type. if (data is bool) return (bool)data ? 1.0f : 0.0f; return base.PrepareDataForSending(data, common, info); }
/// <summary> /// Transforms data, if necessary, before sending it to a connected OSC device</summary> /// <param name="data">The data taken from 'common', using 'info'</param> /// <param name="common">The object whose properties or data are being broadcast. This would have /// come from ObservableToCommon().</param> /// <param name="info">The OSC address info for this data</param> /// <returns>The transformed data, ready to be sent</returns> protected override object PrepareDataForSending(object data, object common, OscAddressInfo info) { // This is a Liine Lemur specific conversion of booleans to floats, even though OSC has a boolean type. if (data is bool) { return((bool)data ? 1.0f : 0.0f); } return(base.PrepareDataForSending(data, common, info)); }
private void AddToDomTypeCache(DomNodeType owningDomNodeType, OscAddressInfo info) { // If QueryDomTypeCache has been called and has modified the list of OscAddressInfo // objects in m_domTypeToInfo, then we need to clear the cache and rebuild it, at // least for every DomNodeType that derives from this one. if (m_domCacheHasBeenQueried) throw new InvalidOperationException("New OSC addresses can't currently be added after start-up"); List<OscAddressInfo> infos; if (!m_domTypeToInfo.TryGetValue(owningDomNodeType, out infos)) { infos = new List<OscAddressInfo>(); m_domTypeToInfo[owningDomNodeType] = infos; } infos.Add(info); }
/// <summary> /// Sets a value on an OSC-addressable property</summary> /// <param name="oscAddress">Original OSC address that might be different than OscAddressInfo's Address /// due to wild card matching.</param> /// <param name="addressable">Object that contains a property that matches 'oscAddress'</param> /// <param name="value">The new value to set the property to</param> /// <param name="info">The matching OscAddressInfo object which knows how to set the value on the addressable object</param> protected virtual void SetValue(string oscAddress, object addressable, object value, OscAddressInfo info) { info.SetValue(addressable, value); }
// To do: handle the wild card characters, '*' and '?', robustly. Add unit tests. Use a tree structure? private void AddOscAddress(string oscAddress, OscAddressInfo info) { m_oscAddressToInfo[oscAddress] = info; if (oscAddress.EndsWith("*")) m_wildCards[oscAddress] = info; }
public ValueSettingInfo(string oscAddress, object addressable, object convertedData, OscAddressInfo oscAddressInfo) { OscAddress = oscAddress; Addressable = addressable; ConvertedData = convertedData; OscAddressInfo = oscAddressInfo; }
/// <summary> /// Transforms data, if necessary, before sending it to a connected OSC device</summary> /// <param name="data">The data taken from 'common', using 'info'</param> /// <param name="common">The object whose properties or data are being broadcast. This would have /// come from ObservableToCommon().</param> /// <param name="info">The OSC address info for this data</param> /// <returns>The transformed data, ready to be sent</returns> protected virtual object PrepareDataForSending(object data, object common, OscAddressInfo info) { return data; }
/// <summary> /// Adds an association of an OSC address with a property descriptor</summary> /// <param name="descriptor">A .NET property descriptor that can get or set values</param> /// <param name="oscAddress">A properly formatted OSC address. If it's not correct, it /// will be fixed and the corrected version will be returned.</param> /// <returns>The possibly fixed oscAddress, if there were illegal characters in /// it or if it was a duplicate</returns> public string AddPropertyAddress(PropertyDescriptor descriptor, string oscAddress) { oscAddress = OscServices.FixPropertyAddress(oscAddress); oscAddress = m_namer.Name(oscAddress); var info = new OscAddressInfo(oscAddress, descriptor); AddOscAddress(oscAddress, info); // Special DOM handling for greatly improved performance. var attrPropDesc = descriptor as AttributePropertyDescriptor; if (attrPropDesc != null) { DomNodeType owningDomNodeType; var childAttrPropDesc = attrPropDesc as ChildAttributePropertyDescriptor; if (childAttrPropDesc != null) owningDomNodeType = childAttrPropDesc.Path.First().OwningType; else owningDomNodeType = attrPropDesc.AttributeInfo.OwningType; AddToDomTypeCache(owningDomNodeType, info); } return oscAddress; }
/// <summary> /// Adds an association of an OSC address with a particular C# property</summary> /// <param name="propertyInfo"></param> /// <param name="oscAddress"></param> /// <returns>The possibly fixed oscAddress, if there were illegal characters in /// it or if it was a duplicate</returns> public string AddPropertyAddress(PropertyInfo propertyInfo, string oscAddress) { oscAddress = OscServices.FixPropertyAddress(oscAddress); oscAddress = m_namer.Name(oscAddress); var info = new OscAddressInfo(oscAddress, propertyInfo); AddOscAddress(oscAddress, info); return oscAddress; }