Пример #1
0
        void OnAudioFilterRead(float[] data, int channels)
        {
            if (dataPtr == IntPtr.Zero)
            {
                dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
                dataPtr    = dataHandle.AddrOfPinnedObject();
            }

            if (PDGainManager.soundNameVoice.Count > 0 && !readerSwitch)
            {
                readerSwitch = true;
                pdPlayer.communicator.SendValue("UReaderSwitch", 1);
            }
            else if (PDGainManager.soundNameVoice.Count == 0 && readerSwitch)
            {
                readerSwitch = false;
                pdPlayer.communicator.SendValue("UReaderSwitch", 0);
            }

            if (pdPlayer.bridge.initialized)
            {
                pdPlayer.communicator.WriteArray("UMasterReceive", dataSum);
                LibPD.Process(pdPlayer.bridge.ticks, dataPtr, dataPtr);
            }
        }
Пример #2
0
 public void Process(float[] output, int ticks)
 {
     if (LibPD.Process(ticks, new float[0], output) == 0 && BufferReady != null)
     {
         BufferReady(this, new BufferReadyEventArgs(output));
     }
 }
Пример #3
0
 /// <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.
         LibPD.Process(Ticks, new float[0], _buffer);
         _circularBuffer.Write(PcmFromFloat(_buffer), 0, _buffer.Length * 4);
     }
 }
Пример #4
0
        public void SetOutput(float[] output, int ticks)
        {
            while (LibPD.Process(ticks, new float[0], output) == 0)
            {
                if (BufferReady != null)
                {
                    BufferReady(this, new BufferReadyEventArgs(output));
                }

                Thread.Sleep(999 * BlockSize * ticks / SampleRate);
            }
        }
Пример #5
0
    // Unity audio callback
    public void OnAudioFilterRead(float[] data, int channels)
    {
        if (dataPtr == IntPtr.Zero)
        {
            dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            dataPtr    = dataHandle.AddrOfPinnedObject();
        }

        if (islibpdready)
        {
            LibPD.Process(numberOfTicks, dataPtr, dataPtr);
        }
    }
        void OnAudioFilterRead(float[] data, int channels)
        {
            if (dataPtr == IntPtr.Zero)
            {
                dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
                dataPtr    = dataHandle.AddrOfPinnedObject();
            }

            if (pureData.bridge.initialized && focused && !paused && !pureData.editorHelper.editorPaused)
            {
                LibPD.Process(pureData.bridge.ticks, dataPtr, dataPtr);
            }
        }
Пример #7
0
        // Audio render callback
        static PortAudio.PaStreamCallbackResult AudioCallback(
            IntPtr input,
            IntPtr output,
            uint frameCount,
            ref PortAudio.PaStreamCallbackTimeInfo timeInfo,
            PortAudio.PaStreamCallbackFlags statusFlags,
            IntPtr userData)
        {
            unsafe
            {
                LibPD.Process((int)frameCount / LibPD.BlockSize, (float *)input.ToPointer(), (float *)output.ToPointer());
            }

            return(PortAudio.PaStreamCallbackResult.paContinue);
        }
Пример #8
0
    public void OnAudioFilterRead(float[] data, int channels)
    {
        if (dataPtr == IntPtr.Zero)
        {
            dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
            dataPtr    = dataHandle.AddrOfPinnedObject();
        }

        if (islibpdready)
        {
            LibPD.SendFloat(SPatch + "freq", send_freq);
            LibPD.SendFloat(SPatch + "turn", 1f);
            LibPD.Process(32, dataPtr, dataPtr);
            LibPD.SendFloat(SPatch + "turn", 0f);
        }
    }
Пример #9
0
        public virtual void testAudio()
        {
            float[] inBuffer  = new float[256];
            float[] outBuffer = new float[768];
            for (int i = 0; i < 256; i++)
            {
                inBuffer [i] = i;
            }
            int err = LibPD.Process(2, inBuffer, outBuffer);

            Assert.AreEqual(0, err);
            for (int i = 0; i < 128; i++)
            {
                Assert.AreEqual(2 * i, outBuffer [3 * i], 0.0001);
                Assert.AreEqual(-6 * i, outBuffer [3 * i + 1], 0.0001);
                Assert.AreEqual(Math.Cos(2 * Math.PI * 440 / 44100 * i), outBuffer [3 * i + 2], 0.0001);
            }
            for (int i = 384; i < 768; i++)
            {
                Assert.AreEqual(0, outBuffer [i], 0);
            }
        }
Пример #10
0
 // Unity audio callback
 public void OnAudioFilterRead(float[] data, int channels)
 {
     LibPD.Process(numberOfTicks, data, data);
 }
 void IProcessor.Process(float[] data, int channels)
 {
     LibPD.Process(numberOfTicks, emptyInput, data);
 }