Beispiel #1
0
        /*
         * @}
         */

        /// <summary>
        /// Constructs the appropriate channel subclass based on the properties of the provided ChannelInfo object.
        /// Used primarily by AddChannel as called from Refresh().
        /// </summary>
        /// <param name="info">the ChannelInfo object from which to construct a channel object</param>
        /// <returns></returns>
        private Csound6Channel CreateChannelFromInfo(ChannelInfo info)
        {
            Csound6Channel channel = null;

            switch (info.Type)
            {
            case ChannelType.Control:
                channel = new Csound6ControlChannel(info.Name, info.Direction, m_csound);
                // info.Hints;
                break;

            case ChannelType.String:
                channel = new Csound6StringChannel(info.Name, info.Direction, m_csound);
                break;

            case ChannelType.Audio:
                channel = new Csound6AudioChannel(info.Name, info.Direction, m_csound);
                break;

            case ChannelType.Pvs:
//                    channel = new Csound6PvsChannel(info.Name, info.Direction, m_csound);//not supported yet
                break;

            case ChannelType.Var:

            default:
                break;
            }
            return(channel);
        }
Beispiel #2
0
        /// <summary>
        /// Supports responding to an InputChannelCallback event by providing a method to
        /// communicate a value back to csound appropriate to the channel.
        /// The "invalue" opcode, which is the only opcode to trigger this event,
        /// only supports receiving strings and MYFLT (double) control values.
        /// </summary>
        /// <param name="value"></param>
        public void SetCsoundValue(Csound6NetRealtime csound, object value)
        {
            if (m_pObject != IntPtr.Zero)
            {
                switch (Type)
                {
                case ChannelType.Control:
                    Marshal.StructureToPtr((double)value, m_pObject, false);
                    break;

                case ChannelType.String:
                    byte[] buf = new byte[Csound6Channel.GetChannelDataSize(csound, Name)];
                    string s   = value.ToString();
                    if (s.Length + 1 > buf.Length)
                    {
                        s = s.Substring(0, buf.Length - 1);
                    }
                    ASCIIEncoding.ASCII.GetBytes(s, 0, s.Length, buf, 0);
                    buf[s.Length + 1] = 0;
                    Marshal.Copy(buf, 0, m_pObject, buf.Length);
                    break;

                default:      //other types not supported in csound: pvs, audio, var
                    break;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Removes from the software bus the channel object with the provided name.
        /// It is not deleted from csound, however.
        /// </summary>
        /// <param name="name">name of the channel to remove from the bus's collection</param>
        /// <returns>the removed channel or null when there is no channel with the provided name</returns>
        public Csound6Channel RemoveChannel(string name)
        {
            Csound6Channel channel = null;

            if (HasChannel(name))
            {
                channel = m_channels[name];
                m_channels.Remove(name);
            }
            return(channel);
        }