Exemple #1
0
        public virtual void AudioOutSizeTest()
        {
            int blocksize = _pd.BlockSize;
            int ticks     = 2;

            float[] inBuffer = new float[ticks * _inputs * blocksize];
            for (int i = 0; i < inBuffer.Length; i++)
            {
                inBuffer [i] = i;
            }
            float[] outBuffer = new float[ticks * _outputs * blocksize];
            _pd.Process(ticks, inBuffer, outBuffer);
            Assert.AreEqual(ticks * _outputs * blocksize, outBuffer.Length);
        }
 /// <summary>
 /// Let libPd compute data, while the CircularBuffer has less than _minBuffer bytes available.
 /// </summary>
 void RefillBuffer()
 {
     while (_circularBuffer.Count < _minBuffer)
     {
         // Compute audio. Take care of the array sizes for audio in and out.z
         _pd.Process(Ticks, new float[0], _pdBuffer);
         _circularBuffer.Write(PcmFromFloat(_pdBuffer), 0, _pdBuffer.Length * 4);
     }
 }
Exemple #3
0
        public virtual void FloatFormattingTest()
        {
            using (Patch patch = _pd.LoadPatch(@"../../test_float.pd")) {
                int     blocksize = _pd.BlockSize;
                int     ticks     = 2;
                float[] inBuffer  = new float[ticks * _inputs * blocksize];
                for (int i = 0; i < inBuffer.Length; i++)
                {
                    inBuffer [i] = i;
                }

                _pd.Start();
                float[] outBuffer = new float[ticks * _outputs * blocksize];
                _pd.Process(ticks, inBuffer, outBuffer);

                for (int i = 0; i < outBuffer.Length / 3; i++)
                {
                    Assert.AreEqual(i, outBuffer [3 * i], 0.0001);
                    Assert.AreEqual(i + 0.5, outBuffer [3 * i + 1], 0.0001);
                    Assert.AreEqual(0, outBuffer [3 * i + 2], 0.0001);
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// Function to do the process audio in pure data, pass the input buffers and output buffers.
 /// </summary>
 /// <param name="length">Size of buffer in unity.</param>
 /// <param name="channels">Number of channels ouput of unity.</param>
 /// <param name="input">Buffer of input pass to pure data.</param>
 /// <returns> Buffer of audio processed from pure data. </returns>
 public void Process_Audio(int length, int channels, float[] input, float[] output)
 {
     PD.Process((int)(length / PD.BlockSize / channels), input, output);
 }