コード例 #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
ファイル: LibPdFilterRead.cs プロジェクト: AVUIs/wat
    // 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);
        }
    }
コード例 #6
0
        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
ファイル: LibPDTests.cs プロジェクト: wincentbalin/libpd
        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
ファイル: PatchPlayer.cs プロジェクト: ozansarier/unipd
 // Unity audio callback
 public void OnAudioFilterRead(float[] data, int channels)
 {
     LibPD.Process(numberOfTicks, data, data);
 }
コード例 #11
0
 void IProcessor.Process(float[] data, int channels)
 {
     LibPD.Process(numberOfTicks, emptyInput, data);
 }