Example #1
0
 public PdOperation(string filePath)
 {
     _patchHandle = LibPD.OpenPatch(filePath);
     LibPD.Bang  += LibPD_Bang;
     LibPD.Subscribe(DoneReceiver);
     LibPD.OpenAudio(0, 2, SampleRate);
     LibPD.ComputeAudio(true);
 }
Example #2
0
 void Dispose(bool isDisposing)
 {
     LibPD.Unsubscribe(DoneReceiver);
     LibPD.ComputeAudio(false);
     if (_patchHandle > 0)
     {
         LibPD.ClosePatch(_patchHandle);
     }
 }
Example #3
0
        public static void loadPatch()
        {
            SDllHandle = LoadLibrary("libpdcsharp.dll");
            LibPD.ReInit();

            LibPD.OpenAudio(2, 3, 44100);
            SPatch = LibPD.OpenPatch(@"..\..\test_csharp.pd");
            LibPD.ComputeAudio(true);
        }
Example #4
0
 public void Open(params string[] patchesName)
 {
     foreach (string patchName in patchesName)
     {
         string path = GetPatchPath(patchName);
         patches[Path.GetFileName(patchName)] = LibPD.OpenPatch(path);
         pdPlayer.communicator.Initialize();
         pdPlayer.itemManager.Initialize();
     }
     LibPD.ComputeAudio(true);
 }
Example #5
0
 /// <summary>
 /// Sets up communication with libPd.
 /// </summary>
 void SetUpPd()
 {
     // Open Pd file
     _patchHandle = LibPD.OpenPatch("../../pd/test.pd");
     // Subscribe to receiver
     LibPD.Float += LibPd_Float;
     LibPD.Subscribe(CursorReceiver);
     // Set up audio format for Pd
     LibPD.OpenAudio(0, 2, SampleRate);
     // Start audio
     LibPD.ComputeAudio(true);
 }
Example #6
0
        public static void loadPatch()
        {
            if (loader == null)
            {
                loader = IsLinux() ? (IDllLoader) new LinuxDllLoader() : (IDllLoader) new WindowsDllLoader();
            }
            SDllHandle = loader.LoadLibrary("libpdcsharp." + (IsLinux() ? "so" : "dll"));
            LibPD.ReInit();

            LibPD.OpenAudio(2, 3, 44100);
            SPatch = LibPD.OpenPatch(@"../../test_csharp.pd");
            LibPD.ComputeAudio(true);
        }
Example #7
0
 void Dispose(bool isDisposing)
 {
     // Unsubscribe from all message receivers
     LibPD.Unsubscribe(CursorReceiver);
     LibPD.Float -= LibPd_Float;
     // Disable audio
     LibPD.ComputeAudio(false);
     if (_patchHandle > 0)
     {
         // Close patch
         LibPD.ClosePatch(_patchHandle);
     }
     LibPD.Release();
 }
Example #8
0
        void IProcessorConfig.Init()
        {
            string mainPatchName = "empty.pd";

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidForceLoad();
#endif
            ResolvePath();
            OpenPd();
            patchSystemId = LoadPatch(mainPatchName);
            LibPD.ComputeAudio(true);
            pureDataProcessor = new PureDataProcessor();
            pureDataProcessor.Init(mainPatchName, numberOfTicks, new Messaging());
        }
    public void loadPatch()
    {
        Debug.Log("Load patch:" + path);

        // we can also work in stereo or more: LibPD.OpenAudio (2, 2, 48000);
        if (!islibpdready)
        {
            LibPD.OpenAudio(1, 1, 48000);
        }
        SPatch = LibPD.OpenPatch(path);
        LibPD.ComputeAudio(true);
        islibpdready = true;

        //LibPD.Print += Receive;
    }
Example #10
0
 public void Open(params string[] patchesName)
 {
     foreach (string patchName in patchesName)
     {
         if (!patchIdDict.ContainsKey(Path.GetFileName(patchName)))
         {
             string path = GetPatchPath(patchName);
             patchIdDict[Path.GetFileName(patchName)] = LibPD.OpenPatch(path);
             pureData.communicator.Initialize();
             pureData.busManager.Update();
             pureData.spatializerManager.Update();
         }
     }
     LibPD.ComputeAudio(true);
 }
Example #11
0
    // Pd initialisation and patch open on game awake
    void Awake()
    {
        PluginUtils.ResolvePath();

        // Delegate for 'print'
        LibPD.Print += ReceivePrint;

        // Follow this sequence of initialisation to avoid destruction of the universe
        if (!islibpdready)
        {
            if (openPd() == 0)
            {
                SPatch = loadPatch(nameOfPatch);
                LibPD.ComputeAudio(true);
            }
            else
            {
                Debug.LogError("Error opening libpd");
            }
        }
    }
Example #12
0
        // Startup audio engine
        public static void Startup()
        {
            LibPD.ReInit();

            LibPD.Print += printCallback;

            LibPD.Float += floatCallback;
            LibPD.Bang  += bangCallback;

            LibPD.OpenAudio(1, 2, 44100);
            LibPD.ComputeAudio(true);
            handle = LibPD.OpenPatch("patch/soundsystem.pd");

            PortAudio.Pa_Initialize();
            PortAudio.Pa_OpenDefaultStream(out stream, 1, 2, (uint)PortAudio.PaSampleFormat.paFloat32,
                                           44100,
                                           256,
                                           renderCallback,
                                           (IntPtr)null);
            PortAudio.Pa_StartStream(stream);
        }
Example #13
0
 public void Start()
 {
     LibPD.OpenPatch(pdPlayer.folderPath + "PDPlayer" + Path.AltDirectorySeparatorChar + "initialize~.pd");
     LibPD.ComputeAudio(true);
 }
Example #14
0
 void Start()
 {
     initPd();
     patchHandle = LibPD.OpenPatch(Application.streamingAssetsPath + "/randomOsc.pd");
     LibPD.ComputeAudio(true);
 }