Exemple #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);
                }
            }
        }
Exemple #2
0
 public bool ReadArray(string arrayName, float[] data)
 {
     return(LibPD.ReadArray(data, arrayName, 0, data.Length) == 0);
 }
Exemple #3
0
 public float[] Get()
 {
     LibPD.ReadArray(data_, name_, 0, data_.Length);
     return(data_);
 }