示例#1
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;
                }
            }
        }
示例#2
0
 protected virtual void Dispose(bool disposing)
 {
     foreach (var nvpair in m_channels)
     {
         var chan = nvpair.Value;
         chan.Dispose();//release channel's unmanaged memory
     }
     m_channels.Clear();
     m_csound = null;
 }
示例#3
0
        /// <summary>
        /// Returns the channel type for the channel defined by the provided name
        /// </summary>
        /// <param name="csound">A reference to the Csound6NetRealtime where the channel is defined</param>
        /// <param name="name">The name of the channel as defined to csound</param>
        /// <returns>A member of the ChannelType enumeration corresponding to the provided name</returns>
        public static ChannelType GetChannelTypeForName(Csound6NetRealtime csound, string name)
        {
            IntPtr pNothing = IntPtr.Zero;
            int    type     = NativeMethods.csoundGetChannelPtr(csound.Engine, out pNothing, name, 0);

            if (type > 0)
            {
                return((ChannelType)(type & ChannelTypeMask));
            }
            return(ChannelType.None); //doesn't exist or memory error
        }
示例#4
0
        /**
         * \addtogroup PERFTHREAD
         * @{
         */

        /// <summary>
        /// Constructor for creating a performance thread.
        /// </summary>
        /// <param name="csound"></param>
        public Csound6PerformanceThread(Csound6NetRealtime csound)
        {
            m_csound    = csound;
            IsPaused    = true;
            IsRunning   = false;
            Status      = CsoundStatus.MemoryAllocationFailure;
            m_queue     = new Queue <Csound6PerfThreadMessage>();
            m_queueLock = new Csound6Mutex();
            if (m_queueLock != null)
            {
                m_pauseLock = new Csound6ThreadLock();
            }
            if (m_pauseLock != null)
            {
                m_flushLock = new Csound6ThreadLock();
            }
            if (m_flushLock != null)
            {
                Status = CsoundStatus.Success;
            }
        }
示例#5
0
 /**
  * \addtogroup CHANNELS
  * @{
  */
 /// <summary>
 /// Provides the current unmanaged memory size in bytes of the channel defined by the provided name
 /// </summary>
 /// <param name="csound">A reference to the Csound6NetRealtime where the channel is defined</param>
 /// <param name="name">The name of the channel as defined to csound</param>
 /// <returns>the size in bytes of the named channel</returns>
 public static int GetChannelDataSize(Csound6NetRealtime csound, string name)
 {
     return(NativeMethods.csoundGetChannelDatasize(csound.Engine, name));
 }
示例#6
0
 /**
  * \addtogroup CHANNELS
  * @{
  */
 /// <summary>
 /// Creates a software bus already loaded with all channels known to csound.
 /// This is only useful after having compiled an orchestra.
 /// If created before compiling, the bus will be empty, but can be filled later
 /// by calling its Refresh() method.
 /// </summary>
 /// <param name="csound">the instance of csound to associate with this bus.</param>
 public Csound6SoftwareBus(Csound6NetRealtime csound)
 {
     m_csound   = csound;
     m_channels = new Dictionary <string, Csound6Channel>();
     Refresh();
 }
示例#7
0
 public Csound6ThreadedProcessEventArgs(Csound6NetRealtime _csound)
 {
     Csound = _csound;
 }