Home

Awesome

P5LIVE

v 1.5.1
cc teddavis.org – 2019 - 2024
p5.js collaborative live-coding vj environment!

SHORTCUTS

P5LIVE (default)

CTRL + ENTERsoftCompile
CTRL + SHIFT + ENTERhardCompile
CTRL + Eeditor toggle
CTRL + Nnew sketch
CTRL + SHIFT + Cclone sketch
CTRL + Aautocompile toggle
CTRL + ,settings toggle
CTRL + Rreferences toggle
CTRL + Bchalkboard toggle
CTRL + Ttidy code
CTRL + SPACEautocomplete
CTRL + +increase fontsize
CTRL + -decrease fontsize
CTRL + Ssave png [ + code ]
CTRL + 1, 2, 3...0jump to first 10 sketches
CTRL + SHIFT + ⇡⇣jump to previous/next sketch
CTRL + SHIFT + DELETEdelete current sketch

Customize shortcut keys within the Settings panel

Ace Editor

ALT + UP/DOWNshift lines up/down
META + ALT + UP/DOWNduplicate lines up/down
META + Ddelete line

(META = CMD on MacOS, CTRL on Windows/Linux)

GETTING STARTED

LIVE-CODE IN 3... 2... 1...

<img src="includes/images/menu-sketches-new-7.png" width="220px">

INSTALL

Online »  p5live.org
Offline » github.com/ffd8/p5live (or see below for instructions)

SAVING

Sketches are ONLY saved in your browser's localStorage(!).
Export all (<img class="svg" src="includes/icons/download.svg" height="12px">) sketches + settings regularly.
Clearing browser history/data will likely erase all sketches + settings.

localStorage is unique and isolated per http[s] / domain / port,
so export/import all sketches to migrate between online / offline / browsers.
Simply use Settings Panel» Backup » Now to export all settings + sketches.

Automatic Backups

See Settings Panel » Backup to automatically export a P5LIVE backup file at varying intervals. If using Offline Server, it will save these backups to your P5LIVE/_backups folder rather than downloads.

MENU

P5LIVE PANEL

<img src="includes/images/menu-p5live-10.png" width="220px"> <img src="includes/images/menu-p5live-export-2.png" width="220px">

SETTINGS PANEL

<img src="includes/images/menu-settings-nav-3.png" width="220px">

Options

<!--- [x] Lock Code on Drag, locks code editor on mouse drag to prevent displacing code. (temp remove)-->

SoniCode

Want to sonify your coding process?! Activate this toggle to generate sounds based on every keystroke (mapping keyCode to sample note). There are built in oscillators, however one can also select midi to send midi notes (channel 1) out to a DAW of choice for more complex samples.

Shortcuts

Customize keyboard shortcuts by clicking on name + press a new key combination.

Reset P5LIVE

COCODING PANEL

<img src="includes/images/menu-cocoding-inactive-7.png" width="220px">

See dedicated COCODING section below for details.

RECODING PANEL

<img src="includes/images/menu-recoding-inactive-1.png" width="220px">

See dedicated RECODING section below for details.

SKETCHES PANEL

<img src="includes/images/menu-sketches-7.png" width="220px">

Filter

<img src="includes/images/menu-sketch-filter-blank-2.png" width="220px"> <img src="includes/images/menu-sketch-filter-2.png" width="220px">

Lost the overview of your sketches?
Type in keywords to match names of sketches and folders, filtering only those results. Use separate words for an and search, ie. 3d webgl text. To organize, add a new folder containing that word, and drag + drop items into it.

Optionally, toggle <> to search through source code of all sketches.

Sketch

<img src="includes/images/menu-sketch-nav-9.png" width="209px"> <img src="includes/images/menu-sketch-nav-expanded-9.png" width="209px">

Folder

<img src="includes/images/menu-folder-nav-9.png" width="209px"> <img src="includes/images/menu-folder-nav-expanded-9.png" width="209px">

FEATURES

COMPILING

There are two modes of compiling in P5LIVE:

Changes to global variables and setup()/preload() automatically perform a hardCompile since the entire sketch needs it. If your change only occurs within the draw() and custom functions (that aren't used in setup()), you should see a smooth transition. This is especially useful if using preloaded assets or drawing without a background during a performance, as it allows things to keep flowing. Classes are also softCompiled, but remember that each instance will still hold the old variables/methods, so replace each instance to see changes.

A recompile when nothing has changed (and live-coding active), triggers a hardCompile, which is useful for clearing the background or class instances.

If in doubt or not seeing changes, run a hardCompile, CTRL + SHIFT + ENTER.

frameCount, mouseX, mouseY are continous per recompile for smooth refreshes.

AUTOCOMPLETE

Custom autocomplete with p5.js functions and constants has been implemented!

<img src="includes/images/autocomplete-2.png" width="400px">

To activate, enter the first few characters of a function and press CTRL + SPACE, then select function alone or with parameters. If selecting with parameters, use TAB to cycle through each one. Optionally activate Auto Autocomplete in the Settings to have suggestions on every keystroke.

The auto-compiler of live-coding pauses whenever the auto-complete panel is active.

If you forget the name of a function, simply view the p5.js references CTRL + R.

REFERENCES

After an overhaul, the built-in <img class="svg" src="includes/icons/book-open-references.svg" height="12px"> References, CTRL + R, now include nearly all information found on the official p5.js reference website, embedded for easy lookup while potentially VJ'ing... meta-visuals! Use the <img class="svg" src="includes/icons/gift.svg" height="12px"> to surprise yourself and view a random reference.

<img src="includes/images/refs-search-2.png" width="230px">

Use Search... with keyup instant filtering to find functions you're after.
Separate words for an and search, ie. material light.
References keep full opacity once viewed, helping note which ones you've read.

<img src="includes/images/refs-params-3.png" width="500px">

Hover over functions for parameters tooltip, click to read the full detailed reference.

<img src="includes/images/refs-example-1.png" width="230px">

Beyond params and descriptions, the example's code is now embedded with js highlighting.

CHALKBOARD

Teaching a class with P5LIVE and need to explain a mathematical concept or highlight code?
Toggle a <img class="svg" src="includes/icons/edit.svg" height="12px"> Chalkboard from the P5LIVE Panel or shortcut CTRL + B.

<img src="includes/images/chalkboard-2.png" width="500px">

Use DRAWINGS pulldown to activate 1 of 10 isolated layers to draw on. All drawings remain until either pressing the 🗑️ clear button, DELETE key or refreshing the page. Toggle between ✏️ DRAW / 🔤 TEXT / 🧽 ERASE to do exactly that. In Text mode, DELETE removes one character at a time, allowing you to rubber-stamp text. Adjust COLOR, WEIGHT, OPACITY of the CHALK, separately adjust the COLOR and OPACITY of the board (background). This enables you to completely cover up the editor/visuals below for explaining concepts. Dim the BOARD if annotating or highlighting code (dim opacity of CHALK).

You can even access the drawings within your p5 sketch!

p5live.chalkboard() // grabs active drawing
p5live.chalkboard(#) // grab specific drawing (0 – 9)
p5live.chalkboard(frameCount * .25) // cycle all ten (% in backend!)

This drawing can then be displayed and played with as a manual drawing layer within your sketch:

image(p5live.chalkboard(), 0, 0);

For examples, see DEMOS » _CANVAS » _canvas_chalkboard + ..._animation

SNIPPETS

Snippets allow automatically adding chunks of code to your sketch within specific areas: global space, setup, draw – so you can quickly incorporate the necessary code for repeated workflows. Previously it was manually added to a .JSON file, but now there's a snippet editor built it!

Shortcuts

Default shortcut keys can be customized within Settings

Snippet Editor

<img src="includes/images/snippets-editor.png" height="50px">

New Snippet

Snippet Selector

<img src="includes/images/snippets-selector.png" height="50px">

When performing, this can be down entirely with the keyboard, CTRL + SHIFT + S to toggle the Snippet Selector, down/up arrowkey to select a preferred snippet, tab to move focus to the 'Apply Snippet' button, Enter to activate that button.

Ace Snippets

Ace Editor also has the ability to have autocomplete snippets of code blocks. To activate, type one out (can also use auto-complete to help you), then press tab. The following have been implemented (eventually this may also be easily customizable):

LIBRARIES

P5LIVE loads p5.js + p5.sound libraries by default. For additional libraries, load them remotely via CDN host or locally if running offline (ie. create /data/libs/). Can also be used within SyncData!

Add this snippet to the top of your sketch, placing one path per array item:

let libs = [
	""
	,""
];

<span style="text-decoration:line-through">p5 or p5.sound</span>

To exclude libraries p5.js (ie. testing other versions) or p5.sound (ie. for Tone.js), add //no p5 or // no p5sound anywhere in your code.
See _audio_gen_tonejs demo for an example.

SANDBOX

Sometimes you want to adjust global JS code that won't cause p5.js to recompile, ie. hydra-synth. To do so, write such code within 2x // sandbox comments. Any changes within that space are processed using eval(), however won't trigger a P5LIVE hardCompile.

HYDRA

The main use case for this, is hydra-synth, which is included within the P5LIVE libs.
After importing the library, any changes made within the following tags:

// sandbox - start
osc().out() // ... your hydra code here
// sandbox - stop

– will only update the hydra-synth engine and won't effect p5.js recompiles!
See DEMOS » HY5 + DEMOS » _HYDRA for additional examples.

ASSETS

Loading custom assets (image/font/obj/audio/...):

VIEW ONLY MODE

By special request (P5LIVE for remote meditation sessions?!), there's a view only mode, meaning everything is hidden (code + menu) and you'll only see the sketch running. Intended for COCODING sessions, where the admin can live-code while attendees enjoy and optionally interact with the visuals using their own mic or mouse. Anytime code is recompiled, the same happens here too. Add edit=0 to your URL:

Similarly you can also use ?readonly=1, for a readonly editor.
Incase of exhibit, use ?exhibit=1, to disable links.

You can also load a sketch by URL (for media installation), just add sketch=name_of_sketch !
Example: _meta_P5LIVE

VISUALS-ONLY POPUP

Incase you want to project or stream the visuals-only (no code + interface) from P5LIVE, press <img class="svg" src="includes/icons/monitor.svg" height="12px"> within the P5LIVE Panel to launch a popup with a video feed of your P5LIVE canvas. Also great for PIP if running multiple instances of offline-mode.

EXPORT / IMPORT

Beyond exporting all sketches regularly (backup!) – you can export single sketches and/or entire folders (click the export icon next to their name). To re-import, click the import button in the Sketches panel or simply drag + drop the P5L_*****.js/P5L_*****.json into the browser. Single sketches are now imported and exported as plain .js for embedding anywhere.

See Settings Panel » Backup to automatically export a P5LIVE backup file at varying intervals.

PERFORMANCE

Lagging or retina display creates too large of a canvas?
Use pixelDensity(1); in setup() to prevent retina scaling.

MIDI/OSC

BUG/CRASH?!

Infinite loop? Broken code? P5LIVE now includes an infinite loop breaker, thus rendering previous tricks more or less obsolete... nevertheless, these may still be useful:

Incase you need a loop to run more than 10000 times || 1 second,
add // noprotect anywhere in your code.
(except during COCODING sessions to protect peers)

EXTRA FUNCTIONS

Additional custom functions are available in P5LIVE sketches:

COCODING

Use COCODING to code together friends locally and remotely! The code is synced while the visuals are rendered locally. If the remote server isn't working, please make an issue on Github!

COCODING PANEL DETAIL

<img src="includes/images/menu-cocoding-inactive-7.png" width="220px"> <img src="includes/images/menu-cocoding-active-9.png" width="220px"> <img src="includes/images/menu-cocoding-req-pre-8.png" width="220px">

Lockdown (user)

<img src="includes/images/menu-cocoding-req-9.png" width="220px">

Lockdown (admin)

<img src="includes/images/menu-cocoding-admin-vote-8.png" width="220px"> <img src="includes/images/menu-cocoding-admin-allow-8.png" width="220px">

Chat

<img src="includes/images/menu-cocoding-chat-2.png" width="220px">

Within chat, links are parsed, ie. share sketch from p5.js editor.
Incoming chats displayed as notification (if active) when menu is hidden.

SyncData

<img src="includes/images/menu-cocoding-syncdata-2.png" width="220px">

<img class="svg" src="includes/icons/radio.svg" height="12px"> launches SyncData window.

<img src="includes/images/menu-cocoding-syncdata-window-2.png" width="400px">

Use the SyncData window to send local data (as objects), by entering custom code that's executed locally in parallel to the shared COCODING session. Latest changes to the SyncData editor are stored in your local settings. Selecting a new preset replaces its contents, so use Save Preset to store anything long-term.

Presets

Buttons

<img src="includes/images/menu-cocoding-syncdata-radio-1.png" width="220px">

When active, your own <img class="svg" src="includes/icons/radio.svg" height="12px"> turns green, along with any user who is sending data.
<img class="svg" src="includes/icons/lock.svg" height="12px"> Lockdown mode, suspends SyncData for all users, unless given write-access.

All data sent, uses parseData() in COCODING session to access it. Events can be fired immediately, or pass values to global vars for use within draw(). Furthermore you can use getData() within COCODING session, for unique local processing within your own SyncData window and code. See midi preset for use-case, where midiThru receives incoming signals and passes them onward to your own gear.

Be kind to your peers, keep data size and intervals within reasonable values.
Have fun COCODING with keyboards, EEG-headsets, eye-trackers, ....?!

RECODING

RECODING PANEL DETAIL

<img src="includes/images/menu-recoding-inactive-1.png" width="220px"> <img src="includes/images/menu-recoding-extended-2.png" width="220px">

RECODING PANEL

PLAYBACK SETTINGS

RECODING EXPLAINED

RECODING allows you to record, playback, scrub and share your live coding process! Simply press record and all changes to the editor are saved with timestamps as a temporary history. Pausing the recording, enables playback, which switches to the recoding sandbox within demos to prevent data loss on the active sketch. To save changes midway from a RECODING step, use the <img class="svg" src="includes/icons/copy.svg" height="12px"> Clone Sketch button. Export your RECODING to share or playing back later. So long as the browser window is open, your history remains available until you press the Reset button, allowing you to start a new RECODING.

RECODING API

Dynamically load RECODING files via URL params for automated playback!
Booleans accept true/false or 1/0

ie. https://p5live.org/?recoding=includes/demos-data/recoding/demo.json&gaps=true&gapsmax=0.1

OFFLINE MODE

Install offline-mode to live-code without internet, load local assets, and communicate with software using OSC. Once installing offline-mode, you'll likely never need online-mode unless COCODING with remote peers (you can use offline COCODING with peers on local network!). If updating, just replace all contents within your existing folder (only store assets in your own /data folder or similar).

Port 5001 is now default since MacOS activated 5000 for AirPlay in 2021. If you've used P5LIVE offline in the past, start in a custom port, ie npm start 5000, do a complete backup from the Settings panel, then startup again with npm start and reimport that file for sketches and settings.

Alternatively, you can run multiple instances of P5LIVE offline (strange experiments galore!?) by adding any other port number to npm start command above, ie: npm start 5010. Remember P5LIVE sketches are stored in localStorage which is unique and isolated per domain:port.

HTTPS

If using offline server, you may want to COCODE with peers on the same local network or even remotely around the world. With p5.sound always enabled, a localhost or https connection is now required regardless of mic being active. While you access via localhost, all connected peers are simply http by default, therefore we can use an http-proxy to tunnel https traffic to our localhost!

Local (same network, works offline):

Remote (anyone across internet w/ ngrok!):

Especially useful for COCODING with your own assets within /data

TOOLS USED

P5LIVE is possible thanks to these amazing open-source projects.
Listed in order of adoption:

INSPIRATION

SOURCE