{"id":18369842,"url":"https://github.com/cawfree/react-native-pure-data","last_synced_at":"2025-04-06T18:32:34.798Z","repository":{"id":38868418,"uuid":"277278462","full_name":"cawfree/react-native-pure-data","owner":"cawfree","description":"🔈 ⚡ Synthesize algorithmic sound at runtime in React Native. ","archived":false,"fork":false,"pushed_at":"2023-01-26T21:54:46.000Z","size":1917,"stargazers_count":29,"open_issues_count":35,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T13:14:02.163Z","etag":null,"topics":["generator","pure-data","react-native","sound","synthesis","synthesizer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cawfree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-05T10:28:10.000Z","updated_at":"2024-12-03T09:36:58.000Z","dependencies_parsed_at":"2023-02-05T22:31:57.866Z","dependency_job_id":null,"html_url":"https://github.com/cawfree/react-native-pure-data","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-pure-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-pure-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-pure-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cawfree%2Freact-native-pure-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cawfree","download_url":"https://codeload.github.com/cawfree/react-native-pure-data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247531336,"owners_count":20953937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","pure-data","react-native","sound","synthesis","synthesizer"],"created_at":"2024-11-05T23:32:31.821Z","updated_at":"2025-04-06T18:32:33.075Z","avatar_url":"https://github.com/cawfree.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-pure-data\n\n\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"./public/logo.png\"\n  /\u003e\n\u003c/p\u003e\n\n\u003cimg alt=\"code style: prettier\" src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\"/\u003e\n\nA native wrapper for [`libpd-ios`](https://github.com/libpd/pd-for-ios) and [`libpd-android`](https://github.com/libpd/pd-for-android), which enables you to rapidly prototype [**DSP**](https://en.wikipedia.org/wiki/Digital_signal_processing) algorithms described using [**Pure Data**](https://puredata.info/), an industry standard open source visual programming language capable of synthesising audiovisual effects.\n\n[`react-native-pure-data`](https://github.com/cawfree/react-native-pure-data) enables the synthesis of generative audio, which helps developers achieve dynamic sound at runtime. This is useful for games, music production and [communications](https://github.com/cawfree/OpenChirp).\n\n### Key Features\n\n  - [**Patches**](https://puredata.info/community/member-downloads/patches) in Pure Data can be interacted with via [**React**]() component props.\n  - Simultaneous patch execution.\n  - Supports [**hot reloading**](https://reactnative.dev/blog/2016/03/24/introducing-hot-reloading.html), so DSP algorithms can be prototyped directly using Pure Data's interface and then executed concurrently on an Android/iOS device or emulator.\n  - Loaded patches respect the [**Component Lifecycle**](https://reactjs.org/docs/state-and-lifecycle.html), so they can be mounted or unmounted as expected.\n\n## ⚠️ Warning\n\n**Please be extremely cautious when prototyping using this library.**\n\nPd is capable of generating high amplitude sound waves, which can [**damage your hearing if you choose to listen using headphones**](https://www.reddit.com/r/puredata/comments/gc06aa/is_it_true_that_using_pure_data_with_earphones_is/).\n\nPlease take care to minimize the risk of hearing damage or loss as much as possible by playing back on external speakers at a reduced volume whenever prototyping with new patches or props. In addition, you must **always** consider the volume of the end user's device.\n\nAnd remember,\n\n\u003e With great power, comes great responsibility.\n\u003e [- Linus Torvalds](https://en.wikipedia.org/wiki/Linus_Torvalds)\n\n\n## 🚀 Getting Started\n\n### 1. Installing\n\nUsing [`npm`](https://www.npmjs.com/):\n\n```bash\nnpm install --save react-native-pure-data\n```\n\nUsing [`yarn`](https://classic.yarnpkg.com/en/):\n\n```bash\nyarn add react-native-pure-data\n```\n\nFor versions of [**React Native**](https://reactnative.dev/) less than [**0.60**](https://reactnative.dev/blog/2019/07/03/version-60), after installation has complete you must execute `react-native link` to make the native library dependencies visible to your compiled application.\n\n### 2. Update `metro.config.js`\n\nOnce installed, you'll [need to](https://github.com/facebook/metro/issues/367) update your [`metro.config.js`](./example/metro.config.js) to help the [**Metro Bundler**](https://github.com/facebook/metro) load your patches:\n\n```diff\n+const metroDefault = require('metro-config/src/defaults/defaults.js');\n\n module.exports = {\n   resolver: {\n+    assetExts: metroDefault.assetExts.concat(['pd']),\n   },\n };\n```\n\nThis will enable **hot loading**, so you can modify your patches even whilst they're being rendered by the app.\n\nAfter making this change, you'll need to **restart the bundler.**\n\n### 3. Runtime Specific\n\n#### 3.1 iOS\n\nAfter installing this library, you'll need reinstall the iOS cocoapods. First, enter your app's `/ios` directory. Then use:\n\n```bash\npod install # update cocoapods\ncd ..\nreact-native run-ios\n```\n\n#### 3.2 Android\n\nAndroid is not yet supported, but will be released **this weekend**.\n\n## ✍️ Example\n\n[`react-native-pure-data`](https://github.com/cawfree/react-native-pure-data) exposes just two [**Component**](https://reactjs.org/docs/react-component.html)s; `AudioController` and `Patch`. The former is used for general sound output configuration, and the latter is used to load and interact with a patch written in Pure Data.\n\nThe simplest example is a patch which does not rely on any data from your `App.js`; you'll see here, that all we need to do is define an `\u003cAudioController /\u003e` at the root of the application, and declare the `Patch`'s file source.\n\n```javascript\nimport React from \"react\";\nimport {AudioController, Patch} from \"react-native-pure-data\";\n\nimport SomePatch from \"./patches/some-patch.pd\";\n\nexport default () =\u003e (\n  \u003cAudioController\n    active\n  \u003e\n    \u003cPatch\n      source={SomePatch}\n    /\u003e\n  \u003c/AudioController\u003e\n);\n```\n\nHowever, Pure Data is uses an asynchronous, [**message-driven**](https://en.wikipedia.org/wiki/Flow-based_programming) protocol. This normally means that imported patches will need to be either triggered or configured by your runtime logic.\n\nTo communicate with a loaded patch from your app, all you have to do is specify additional props on the `Patch` component. These will be synchronously routed to corresponding receivers in the Pure Data patch whenever the component is re-rendered:\n\n```javascript\nimport React, {useState, useEffect} from \"react\";\nimport {AudioController, Patch} from \"react-native-pure-data\";\n\nimport SomePatch from \"./patches/some-patch.pd\";\n\nexport default () =\u003e {\n  const [frequency, setFrequency] = useState(440);\n  useEffect(\n    () =\u003e {\n      /* every 1000ms, set a new frequency */\n      const i = setInterval(\n        () =\u003e setFrequency(Math.random() * 1000),\n        1000,\n      );\n      return () =\u003e clearInterval(i);\n    },\n    [],\n  );\n  return (\n    \u003cAudioController\n      active\n    \u003e\n      \u003cPatch\n        source={SomePatch}\n        nextFrequency={frequency}\n      /\u003e\n    \u003c/AudioController\u003e\n  );\n};\n```\n\nIn the example above, a random frequency will be calculated and transmitted to the corresponding receiver on the diagram. In this case, the receiver would be called \"nextFrequency\", which would be declared using a Pure Data [**Object**](https://puredata.info/docs/ListOfPdExternals) with the definition `[r nextFrequency]`:\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg\n    src=\"./public/example.png\"\n  /\u003e\n\u003c/p\u003e\n\nThe convention used here is that for every numeric prop, the name of that prop corresponds to the message receiver within the patch.\n\nTherefore, if we defined an additional prop named `someOtherFrequency={Math.random()}`, whenever the component is re-rendered we would send a message to the receiver `[r someOtherFrequency]` that existed within the patch. If the receiver does not exist, this is a [**noop**](https://en.wikipedia.org/wiki/NOP_(code)).\n\nPlease check out the [**Example App**](https://github.com/cawfree/react-native-pure-data/tree/master/example) for further details.\n\n## ✨ Resources \n\n  - [**Awesome Pure Data**](https://github.com/virtualtam/awesome-puredata)\n  - [**PatchStorage**](https://patchstorage.com)\n  - [**PdPatchRepo**](http://pdpatchrepo.info/patches/patch/14)\n\n## ✌️ Licence\n[**MIT**](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-native-pure-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcawfree%2Freact-native-pure-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcawfree%2Freact-native-pure-data/lists"}