/// <summary> /// Provides a dictionary of all currently defined channels resulting from compilation of an orchestra /// containing channel definitions. /// Entries, keyed by name, are polymorphically assigned to their correct data type: control, audio, string, pvc. /// Used by the Csound6SoftwareBus class to initialize its contents. /// </summary> /// <returns>a dictionary of all currently defined channels keyed by their name to its ChannelInfo</returns> public IDictionary <string, ChannelInfo> GetChannelList() { IDictionary <string, ChannelInfo> channels = new SortedDictionary <string, ChannelInfo>(); IntPtr ppChannels = IntPtr.Zero; int size = NativeMethods.csoundListChannels(Engine, out ppChannels); if ((ppChannels != IntPtr.Zero) && (size >= 0)) { int proxySize = Marshal.SizeOf(typeof(ChannelInfoProxy)); for (int i = 0; i < size; i++) { var proxy = Marshal.PtrToStructure(ppChannels + (i * proxySize), typeof(ChannelInfoProxy)) as ChannelInfoProxy; string chanName = Marshal.PtrToStringAnsi(proxy.name); ChannelInfo info = new ChannelInfo(chanName, (ChannelType)(proxy.type & 15), (ChannelDirection)(proxy.type >> 4)); var hintProxy = proxy.hints; var hints = new ChannelHints((ChannelBehavior)hintProxy.behav, hintProxy.dflt, hintProxy.min, hintProxy.max); hints.x = hintProxy.x; hints.y = hintProxy.y; hints.height = hintProxy.height; hints.width = hintProxy.width; hints.attributes = (hintProxy.attributes != IntPtr.Zero) ? Marshal.PtrToStringAnsi(hintProxy.attributes) : null; info.Hints = hints; channels.Add(chanName, info); } NativeMethods.csoundDeleteChannelList(Engine, ppChannels); } return(channels); }
public ChannelHintsProxy(ChannelHints hints) { behav = (int)hints.behav; dflt = hints.dflt; min = hints.min; max = hints.max; x = hints.x; y = hints.y; height = hints.height; width = hints.width; attributes = IntPtr.Zero; }
//~Csound6ControlChannel() //not needed since nothing to do calling Dispose(false) //{ // Dispose(false); //} protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { m_hint = null; }//no managed resources }
/// <summary> /// Returns the current content of this channel's controlChannelHints_t structure. /// Most of these values are available as properties of this control channel's object. /// </summary> /// <returns>A managed version of the unmanaged controlChannelHints_t structure for this channel</returns> public ChannelHints GetControlChannelHints() { if (m_hint == null) { IntPtr pHints = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NativeMethods.ChannelHintsProxy))); NativeMethods.csoundGetControlChannelHints(m_csound.Engine, Name, pHints); var proxy = (NativeMethods.ChannelHintsProxy)Marshal.PtrToStructure(pHints, typeof(NativeMethods.ChannelHintsProxy)); m_hint = new ChannelHints((ChannelBehavior)proxy.behav, proxy.dflt, proxy.min, proxy.max); m_hint.x = proxy.x; m_hint.y = proxy.y; m_hint.height = proxy.height; m_hint.width = proxy.width; m_hint.attributes = (proxy.attributes != IntPtr.Zero) ? Marshal.PtrToStringAnsi(proxy.attributes) : null; Marshal.FreeHGlobal(pHints); } return(m_hint); }
/// <summary> /// Updates this channel's controlChannelHints_t structure with the provided ChannelHints /// contents. Use to revise any or all of the values of a control channels hints properties. /// Used internally to update individual properties. /// </summary> /// <param name="hints">A ChannelHints object with the desired current values</param> public void SetControlChannelHints(ChannelHints hints) { m_hint = hints; var xprox = new NativeMethods.ChannelHintsProxy(hints); int result = NativeMethods.csoundSetControlChannelHints(m_csound.Engine, Name, xprox); }
/// <summary> /// Creates a control channel object using the provided name, direction, channel hints and csound instance /// </summary> /// <param name="name"></param> /// <param name="direction"></param> /// <param name="hints"></param> /// <param name="csound"></param> public Csound6ControlChannel(string name, ChannelDirection direction, ChannelHints hints, Csound6Net csound) : base(name, direction, csound) { m_hint = hints; SetControlChannelHints(hints); }