Пример #1
0
        public virtual unsafe void testArrayAccess()
        {
            int n = 128;

            Assert.AreEqual(n, LibPD.ArraySize("array1"));

            float[] u = new float[n];
            float[] v = new float[n];
            for (int i = 0; i < n; i++)
            {
                u [i] = i;
            }

            LibPD.WriteArray("array1", 0, u, n);
            LibPD.ReadArray(v, "array1", 0, n);
            for (int i = 0; i < n; i++)
            {
                Assert.AreEqual(u [i], v [i], 0);
            }

            fixed(float *vp = v)
            {
                LibPD.ReadArray(&vp [5], "array1", 50, 10);
                for (int i = 0; i < n; i++)
                {
                    if (i < 5 || i >= 15)
                    {
                        Assert.AreEqual(u [i], v [i], 0);
                    }
                    else
                    {
                        Assert.AreEqual(u [i + 45], v [i], 0);
                    }
                }
            }

            fixed(float *up = u)
            {
                LibPD.WriteArray("array1", 10, &up [25], 30);
            }

            LibPD.ReadArray(v, "array1", 0, n);
            for (int i = 0; i < n; i++)
            {
                if (i < 10 || i >= 40)
                {
                    Assert.AreEqual(u [i], v [i], 0);
                }
                else
                {
                    Assert.AreEqual(u [i + 15], v [i], 0);
                }
            }
        }
Пример #2
0
        public bool WriteArray(string arrayName, int offset, float[] data, int amountOfValues)
        {
            if (!LibPD.Exists(arrayName))
            {
                return(false);
            }

            if (LibPD.ArraySize(arrayName) != amountOfValues)
            {
                ResizeArray(arrayName, amountOfValues);
            }

            int success = LibPD.WriteArray(arrayName, offset, data, amountOfValues);

            return(success == 0);
        }
Пример #3
0
 public static void SendArray(string array, int offset, float[] source, int n)
 {
     LibPD.WriteArray(array, offset, source, n);
 }