Git Product home page Git Product logo

p5live's Introduction

P5LIVE

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

SHORTCUTS

P5LIVE (default)

CTRL + ENTER softCompile
CTRL + SHIFT + ENTER hardCompile
CTRL + E editor toggle
CTRL + N new sketch
CTRL + SHIFT + C clone sketch
CTRL + A autocompile toggle
CTRL + , settings toggle
CTRL + R references toggle
CTRL + B chalkboard toggle
CTRL + T tidy code
CTRL + SPACE autocomplete
CTRL + + increase fontsize
CTRL + - decrease fontsize
CTRL + S save png [ + code ]
CTRL + 1, 2, 3...0 jump to first 10 sketches
CTRL + SHIFT + ⇡⇣ jump to previous/next sketch
CTRL + SHIFT + DELETE delete current sketch

Customize shortcut keys within the Settings panel

Ace Editor

ALT + UP/DOWN shift lines up/down
META + ALT + UP/DOWN duplicate lines up/down
META + D delete line

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

GETTING STARTED

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

  • Create New Sketch or CTRL + N and start coding!
  • Live-coding active by default, CTRL + ENTER to force recompile.
  • Sketches are auto-saved to localStorage on every keystroke.

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 () 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

  • About, 👋 you're reading me now.
  • Settings, adjust editor settings + shortcuts.
  • Reference, CTRL + R, toggle embeded p5.js reference.
  • Chalkboard, CTRL + B, toggle chalkboard over for annotations.
  • Visuals-only Popup, for projecting canvas output without code + interace.
  • Export, click to reveal sub-menu:

  • Save .png, CTRL + S, exports image [+ code if active in settings].
  • Share code as URL (links to online version at p5live.org).
  • Save .html, export single page website (re-link paths to any offline assets).

SETTINGS PANEL

  • Reset Settings to defaults
  • Import Settings
  • Export Settings

Options

  • Live Coding, [500ms], auto-compile error-free code on keyup, with set delay.
  • Console, display console messages, [auto/show] to hide or keep visible.
  • Eco Render, noLoop() if window loses focus (save computer resources).
  • Menu Tab, toggle menu tab. (hide if visible while VJ'ing).
  • Snapshot Code, export current code with each image snapshot.
  • Line Numbers, display code line numbers (and gutter features).
  • Recompile Pulse, flash compiled section of code.
  • Auto Autocomplete, useful for learning, or use CTRL + SPACE on demand.
  • Pass Editor Keys, keypresses from editor to p5 canvas (hide editor otherwise).
  • Notifications, display notifications (shortcut settings + chat).
  • Tooltips, displays extra info on hover.
  • Multi-P5LIVE Warning, if opened multiple times can lose sync of sketches.
  • Timestamp Exports, adds _YYYYMMDD_HHMMSS to filenames.
  • COCODING Flags, show cursor flags or only with mouseover userlist.
  • COCODING Autosave, autosave session code if server/internet lost.
  • Check Updates, check Github for updates (offline-mode only).
  • Backup, [off], saves/downloads P5LIVE (sketches + settings) at intervals. Now - on demand. Set Daily in offline-mode.
  • Code Size, 15pt adjust font size of editor.
  • Theme, [Green on Black], select custom styling of editor.
  • Background, toggle + set color behind lines of code.
  • Text, toggle + override unstyled text in code.
  • Active-line, toggle + set active-line color.
  • Keybinding, [ace], select alternative keybindings of editor.
  • Snippets, Launch Editor, to open snippets editor.
  • SoniCode, plays oscillator/midi on every keystroke.

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

  • Completely reset P5LIVE = deletes all sketches + settings!
    Don't forget to export sketches first.

COCODING PANEL

See dedicated COCODING section below for details.

RECODING PANEL

See dedicated RECODING section below for details.

SKETCHES PANEL

  • New sketch.
  • Clone sketch, duplicates active sketch.
  • New folder, nest sketches/folders within others.
  • Import, select JSON files from export (single/folder/all).
  • Export, exports entire sketches list for import/backup.

Filter

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

  • Load Sketch, click on name.
  • Click on loaded sketch (green) to rename.
  • Hover to view contextual options
    • Inspect, view/edit code as popup.
    • Rename, give sketch new name.
    • Export, export single sketch as JSON file.
    • Remove, delete sketch after confirmation.
  • Sort, click + hold + drag to desired order.
  • Place in folder, slowly drag + drop into/over folder.

Folder

  • Expand/collapse Folder, click on name.
  • Hover to view contextual options
    • Rename, give folder new name.
    • Sub-folder, create a new folder within existing one.
    • Export, export folder + contents as JSON file.
    • Remove, delete folder + contents after confirmation.
  • Sort, click + hold + drag to desired order.

FEATURES

COMPILING

There are two modes of compiling in P5LIVE:

  • softCompile, CTRL + ENTER, (default) replaces changed functions (smooth refresh).
  • hardCompile, CTRL + SHIFT + ENTER, forces entire sketch to recompile.

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!

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 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 to surprise yourself and view a random reference.

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.

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

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 Chalkboard from the P5LIVE Panel or shortcut CTRL + B.

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

  • ALT + SHIFT + S, toggle Snippets Editor, create, modify.
  • CTRL + SHIFT + S, toggle Snippets Selector, apply.
  • Use arrow keys, tab, enter to apply snippets by keyboard only.

Default shortcut keys can be customized within Settings

Snippet Editor

  • Select snippet to edit or 'new' to create a new one
  • Apply selected snippet.
  • Clone snippet, ie, 'Save As...'.
  • Import an exported snippet.
  • Save changes to a custom shortcut.
  • Rename a custom shortcut.
  • Export a custom shortcut.
  • Delete a custom shortcut.

New Snippet

  • Toggle Snippets Editor.
  • Select 'new' to create a new snippet.
  • Add code within the global top, setup bottom, draw top, draw bottom, global bottom
  • Clone Snippet and give a custom name to save snippet.

Snippet Selector

  • Select snippet to apply.
  • Apply selected snippet.
  • Edit selected snippet.

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):

  • libs, inserts code for loading external libraries.
  • p5, adds p5 template incase removed
  • hydraonly, replace all code with this to only use hydra-synth
  • sandbox, adds //sandbox start/stop for eval hydra code
  • hy5, load HY5 library and sandbox for hydra code
  • hy5-p5-hydra, template for sending p5 into hydra
  • hy5-hydra-p5, template for sending hydra into p5
  • hy5-hydra-p5-x4, template for sending 4x hydra tex to p5
  • hy5-hydra-p5-x4-demo, demo for sending 4x hydra tex to p5

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 = [
	""
	,""
];

p5 or p5.sound

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/...):

  • Remotely from a CORS friendly server (imgbb/glitch.com images/videos, GitHub raw for ~anything)
    loadImage('https://i.imgur.com/ijQzwsx.jpeg');
  • Locally, if running offline-mode create a /data folder
    loadImage('data/images/fish.png'); (don't add anything to /includes!)

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:

  • COCODING, /?cc=*****&edit=0
  • Solo, /?edit=0

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 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

  • MIDI works online/offline and is implemented with webmidi.js
    For example, demos/_input/_input_midi
  • OSC works offline.
    For example, demos/_input/_input_osc and run Processing sketch, p5live_osc_setup
    or use the OSC snippet (CTRL + SHIFT + O) and set host/in/out ports.

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:

  • Add #bug to URL and press ENTER.
    Stops compiler, loads a new sketch and opens inspector to fix issue and save.
  • Add #new to URL and press ENTER.
    Loads a new sketch.
  • If the browser has completely hung, (rare [old] issue between MBP/Chrome/libraries)
    sudo killall coreaudiod (first take off headphones + turndown stereo!)

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:

  • ease(inValue, outVariable, easeValue) smooth values.
  • println(foo) Compatibility with Processing.
  • windowResize() is set by default to keep your sketch fullscreen. To disable, add windowResized = null; in the setup() or overwrite with custom function.

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

  • Press to start a COCODING session and share new URL with friends.

  • COCODING # of users - ⇡⇣ syncing up/down-stream.
  • Exit, click the green 'power' button.
  • Clone sketch, saves current co-code to local sketches within session folder.
  • SyncData, custom code to sync local data (mouse, midi,...) with peers.
  • Lockdown (admin), limit editing, toggle write privledges per user.
  • Broadcast (admin + lockdown), sync mouseX/Y/frameCount/recompile with users.

  • Click on your name (very top) to select a new nickname and color.
  • If admin left, you'll have option within this panel to claim it.

Lockdown (user)

  • Request write-access, click edit button and wait for admin to allow.

Lockdown (admin)

  • Grant write-access, toggle requested write-access from glowing users.

  • Toggle write-access, admin can always toggle write access per user.

Chat

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

SyncData

launches SyncData window.

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

  • template guide for making your own.
  • mouseXY, facetracker + midi, shares those signals with others.
    Be sure to enter unique userID's.
  • Save Preset for storing current SyncData editor (pre-existing name replaces it).
  • Remove Preset is available after selecting a custom preset.

Buttons

  • ► RUN activates SyncData, injecting code at end of COCODE on each recompile.
  • ► RE-RUN updates any changes made within SyncData editor.
  • ↓ COCODE (admin) adds code following /* 2 - COCODE */ into COCODING session.
  • ◼ STOP deactivates SyncData (stops adding local code to recompile).

When active, your own turns green, along with any user who is sending data.
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

  • Press to start a RECODING session and record your live coding process.

RECODING PANEL

  • RECODING #/# step of steps in recording.
  • / Pause/Continue recording.
  • / Play/Pause playback.
  • Playback settings toggle.
  • Export recording.
  • Reset RECODING.
  • Slider to scrub between recorded steps.

PLAYBACK SETTINGS

  • Loop, repeat playback.
  • Max Gap, max time between keystrokes in seconds.
  • CatMode, any key presses next keystroke
  • Speed, overall playback speed

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 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

  • ?recoding=recoding_filepath.json
  • &loop=true
  • &gaps=true
  • &gapsmax=5
  • &speed=1
  • &menu=false
  • &editor=true
  • &catmode=false

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).

  • Download P5LIVE or Clone in Github Desktop
  • Install node.js + npm package (binary installers)
  • MacOS – open Terminal // Windows – open command prompt
  • type cd + SPACEBAR + drag/drop P5LIVE folder into window, press ENTER
  • type npm install, press ENTER
  • type npm start, press ENTER (for custom port: npm start ####)
  • P5LIVE is live! visit » http://localhost:5001
  • type CTRL + C, to stop server.

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):

  • Start P5LIVE with npm start https, or custom port npm start #### https
  • HTTPS port is automatically 1 digit higher than P5LIVE (5000 » 5001).
  • Share https address displayed in Terminal, ie: https://xxxxx.local:5001
  • Connected peers must accept 'unsecure' (self-gen) certificate with Advanced button upon loading URL. Certificates are generative + cached, renewing after 60 days.
  • Enjoy offline local peers COCODING!

Remote (anyone across internet w/ ngrok!):

Especially useful for COCODING with your own assets within /data

  • Start P5LIVE offline server (see above)
  • Download ngrok
  • Open another tab in Terminal, cd to the folder containing ngrok
  • Type ./ngrok http 5000 and press ENTER (tunnels to localhost:5000)
  • Check output forwarding URL to share with remote peers (add COCODING channel):
    https://**********.ngrok.io/?cc=*****
  • Enjoy offline remote peers COCODING!

TOOLS USED

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

INSPIRATION

SOURCE

p5live's People

Contributors

ffd8 avatar guidobouman avatar junshern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p5live's Issues

feature: don't erase canvas during recompile

It would be nice for some performance to not have the canvas erased during a recompile. This might require hacking on the underlying p5 code to preserve the canvas if it exists.

typo Midi Demo

In the parseMidi function, it says contol, should say control

"code": "/*\t\n\t_input_midi v2 - 07.04.20\n\tv1 initated at p5.js contributors conference 2019 // Music+Code in Performance track\n\tFrank-Ratchye STUDIO for Creative Inquiry at CMU + NEA\n\tSee Javascript Console after running setup for device IDs + Names\n*/\n\n/* PREFS */\nlet midiDeviceIn = 0; // [ID] or \"device name\"\nlet midiDeviceOut = 0; // [ID] or \"device name\"\nlet midiThru = false; // optionally pass all in -> out\n\nlet loadScripts = [\"includes/js/webmidi.min.js\"];\nlet midiInput, midiOutput, midiMsg = {};\n\nfunction setup() {\n\tcreateCanvas(windowWidth, windowHeight);\n\tbackground(0);\n\tsetupMidi(midiDeviceIn, midiDeviceOut); // deviceIn, deviceOut\n}\n\nfunction draw() {\n\tbackground(0, 15);\n\n}\n\nfunction noteOn(note) {\n\t// use note.type, .channel, .name, .number, .octave, .velocity\n\tlet x = map(note.number, 0, 128, 0, width);\n\tlet h = map(note.velocity, 0, 128, 0, height);\n\tpush();\n\tnoStroke();\n\tfill(note.velocity * 2);\n\trectMode(CENTER);\n\trect(x, height / 2, width / 128, h);\n\tpop();\n}\n\nfunction noteOff(note) {\n\t// use note.type, .channel, .name, .number, .octave, .velocity\n}\n\nfunction pitchBend(pitch) {\n\t// use pitch.type, .channel, .value\n}\n\nfunction controlChange(control) {\n\t// use control.type, .channel, .controllerNumber, .controllerName, .value\n}\n\nfunction midiToFreq(noteNumber) {\n\treturn 440 * Math.pow(2, (noteNumber - 69) / 12);\n}\n\n\nfunction mousePressed() {\n\t// example of sending midi note\n\t// sendNote(1, \"C\", 3, 1000, 127); // channel, note, octave, duration, velocity\n}\n\nfunction sendNote(channel, note, octave, duration, velocity) {\n\tmidiOutput.playNote(note + octave, channel, {\n\t\tduration: duration,\n\t\tvelocity: parseFloat(velocity) / 127.0\n\t});\n}\n\nfunction parseMidi(mm) {\n\t//print(mm);\n\tif(mm.note != undefined) {\n\t\tswitch (mm.note.type) {\n\t\t\tcase 'noteon':\n\t\t\t\tnoteOn(mm.note);\n\t\t\t\tbreak;\n\t\t\tcase 'noteoff':\n\t\t\t\tnoteOff(mm.note);\n\t\t\t\tbreak;\n\t\t}\n\t} else if(mm.pitch != undefined) {\n\t\tpitchBend(mm.pitch);\n\t} else if(mm.control != undefined) {\n\t\tcontrolChange(mm.contol);\n\t}\n}\n\nfunction setupMidi(idIn, idOut) {\n\tWebMidi.enable(function(err) {\n\t\tif(err) {\n\t\t\tconsole.log(\"WebMidi could not be enabled.\", err);\n\t\t}\n\n\t\t// Print to console available MIDI in/out id/names\n\t\tWebMidi.inputs.forEach(function(element, c) {\n\t\t\tprint(\"in \\[\" + c + \"\\] \" + element.name);\n\t\t});\n\t\tWebMidi.outputs.forEach(function(element, c) {\n\t\t\tprint(\"out \\[\" + c + \"\\] \" + element.name);\n\t\t});\n\n\t\t// assign in channel:\n\t\tif(typeof idIn === 'number') {\n\t\t\tmidiInput = WebMidi.inputs[idIn];\n\t\t} else {\n\t\t\tmidiInput = WebMidi.getInputByName(idIn);\n\t\t}\n\n\t\tif(typeof idOut === 'number') {\n\t\t\tmidiOutput = WebMidi.outputs[idOut];\n\t\t} else {\n\t\t\tmidiOutput - WebMidi.getOutputByName(idOut);\n\t\t}\n\n\t\tmidiInput.addListener('midimessage', 'all', function(e) {\n\t\t\tif(midiThru) {\n\t\t\t\tif(e.data.length == 3) {\n\t\t\t\t\tmidiOutput.send(e.data[0], [e.data[1], e.data[2]]);\n\t\t\t\t} else {\n\t\t\t\t\tmidiOutput.send(e.data[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmidiMsg = {};\n\t\t\tmidiMsg.data = e.data;\n\t\t\tmidiMsg.timestamp = e.timestamp;\n\t\t\t// parseMidi(midiMsg) // optionally send raw only\n\t\t});\n\n\t\t// noteOn\n\t\tmidiInput.addListener('noteon', \"all\", function(e) {\n\t\t\tlet note = {\n\t\t\t\ttype: 'noteon'\n\t\t\t};\n\t\t\tnote.channel = e.channel;\n\t\t\tnote.number = e.note.number;\n\t\t\tnote.name = e.note.name;\n\t\t\tnote.octave = e.note.octave;\n\t\t\tnote.velocity = floor(127 * e.velocity);\n\n\t\t\tmidiMsg.note = note;\n\t\t\tparseMidi(midiMsg);\n\t\t});\n\n\t\t// noteOff\n\t\tmidiInput.addListener('noteoff', \"all\", function(e) {\n\t\t\tlet note = {\n\t\t\t\ttype: 'noteoff'\n\t\t\t};\n\t\t\tnote.channel = e.channel;\n\t\t\tnote.number = e.note.number;\n\t\t\tnote.name = e.note.name;\n\t\t\tnote.octave = e.note.octave;\n\t\t\tnote.velocity = 0;\n\n\t\t\tmidiMsg.note = note;\n\t\t\tparseMidi(midiMsg);\n\t\t});\n\n\t\t// pitchBend\n\t\tmidiInput.addListener('pitchbend', \"all\", function(e) {\n\t\t\tlet pitch = {\n\t\t\t\ttype: 'pitchbend'\n\t\t\t};\n\t\t\tpitch.channel = e.channel;\n\t\t\tpitch.value = floor(127 * e.value);\n\n\t\t\tmidiMsg.pitch = pitch;\n\t\t\tparseMidi(midiMsg);\n\t\t});\n\n\t\t// controlChange\n\t\tmidiInput.addListener('controlchange', \"all\", function(e) {\n\t\t\tlet control = {\n\t\t\t\ttype: 'controlchange'\n\t\t\t};\n\t\t\tcontrol.channel = e.channel;\n\t\t\tcontrol.controllerNumber = e.controller.number;\n\t\t\tcontrol.controllerName = e.controller.name;\n\t\t\tcontrol.value = e.value\n\n\t\t\tmidiMsg.control = control;\n\t\t\tparseMidi(midiMsg);\n\t\t});\n\n\t});\n}"

obsolete socket.io contains a high severity vulnerability (Resource exhaustion in engine.io)

npm audit returns the following

# npm audit report

engine.io  <4.0.0
Severity: high
Resource exhaustion in engine.io  - https://github.com/advisories/GHSA-j4f2-536g-r55m
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/engine.io
  socket.io  1.0.0-pre - 2.4.1
  Depends on vulnerable versions of engine.io
  node_modules/socket.io

2 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

P5LIVE – video tutorial series

Beginning summer '21, a thorough video tutorial series, walking people through P5LIVE's features, functions and workflow will be created and disseminated for free streaming. This work is supported by a 2021 Processing Foundation Teaching Fellowship. The videos aim to accompany the loong README, while demonstrating beyond its text form and slipping in p5.js tips/tricks/collabs along the way. This issue will live as a place to organize these ideas, host random discussion when discovered (by you?? 👋 ) and eventually link to the series as it's made.

» P5LIVE-WALKTHROUGH YouTube Playlist

TOC


At the moment, keeping videos short and modular, so they can be re-recorded as needed due to updates/changes of P5LIVE and allowing views to jump right to a necessary topic rather than jumping to exact moment of a longer video.

[√]- GETTING STARTED

- necessary shortcuts
	- recompile, toggle editor + menu
- getting started (min need to know)
	- new sketch + coding
	- concept of live coding + fullscreen
	- changing sketches
- meta sketch of P5LIVE
- unique features that can confuse
	- soft vs hard compile, background page set, fullscreen default, shortcuts (pc + win)

[√]- MENU » P5LIVE

	- about
	- settings (later)
	- references
	- chalkboard (later)
	- visuals only (quick demo)
	- export (later)

[√]- MENU » SKETCHES

	- new
	- cloning multiple times
	- folder (organizing)
	- importing/exporting files
	- sketches/folders 
		- contextual menu
		- rename/export/inspect
		- re-arranging
	- filtering to find + organize

[√]- SETTINGS PANEL

- reset / import/export settings
- walkthrough options
- backups
- shortcuts
- reset P5LIVE

[√]- SHORTCUTS

- overview of all
- customizing

[√]- EXPORTING / IMPORTING / SHARING

- backup all (switch browsers + online/offline)
- export folder, sketches, all sketches
- importing (button + drag/drop)
- snapshot (w/ w/o code)
- URL sharing
- 1 page HTML

[ ]- COCODING

- init session + sharing link (+ sharing view-only)
- ending / cloning / sync data (later) / lockdown / broadcast
- users list (renaming + color)
- toggling/requesting edit-rights
- chat

[ ]- SYNCDATA

- concept
- basic setup + activating
- details of sharing + admin roles (limited edit)
- demos
- new preset + overwriting one
- (detail they live within settings)

[√]- OFFLINE MODE

- installation (basic vs fancy)
	- download vs github clone
- /data assets folder

[√]- LIBRARIES + ASSETS

- importing libs (CDN + local)
- images/fonts (CORS + local)

[ ]- VJ + PERFORMANCE

- audio reactive demo + snippet
- midi example
- osc example

[ ]- LEARNING P5.JS WITH P5LIVE

- references
- auto-complete
- demos
- cocoding with a peer

[ ]- TEACHING P5.JS WITH P5LIVE

- chalkboard
- cocoding with class / breakouts
- exporting/sharing folder of demos
- sketch » 1 page website

[ ]- SPECIAL TOPICS

- hydra (sandbox, pass-back, scoped)

[ ]- CLASSROOM (pending dev)

- ... coming fall/winter

QUESTIONS


Here are a few of the questions I'm considering and contemplating while planning and shooting

w/[o] portrait in the corner?

update: using a p5 sketch in WEBGL for fancy cam as texture

how helpful/necessary is it to see the person talking while watching screen?

  • 1 take vs edits?
    update: 1 take, but still edit quickly for audio post-production

ideally captured as a 1-take (multiple times) walk through for simplicity.. are edits/zooms necessary?

  • record with quicktime/obs vs HDMI out to PVR?
    update: quicktime screen recording makes best quality for filesize

tech question for framerate/smoothness/quality– ease vs gear?

  • how/when/who to collab (remotely vs locally) for demos on OSC (music, kinect), COCODING, SyncData

opportunity to invite/work with others, takes their time, lag in remote vs local?

  • ...

where can i upload different fonts

hello, I'm enjoying p5 live and thanks so much for this amazing website!
I tried to figure out how to upload new font files, but couldn't.

Based on typo examples, it seems like the code loads font files from this directory.
font = loadFont("includes/demos-data/fonts/RobotoMono-Regular.otf");
Could someone help me how to find this directory and upload a file?

Thanks!

P.S. I know that I can also load google fonts as an alternative, but looking for direct upload, if possible. Thanks!

function googleFont(fontName) {
	let link = document.createElement("link");
	link.href = "https://fonts.googleapis.com/css?family=" + encodeURI(fontName) + '&display=swap';
	link.rel = "stylesheet";
	document.head.appendChild(link);
	return fontName;
}

Does not load on Firefox

Hi there! About to start my new class using p5.js and was looking into also using P5LIVE.

On Firefox 69.0 under macOS 10.13.6 the site stays with the initial spinning P5LIVE logo forever. Not sure what's going on. In the console, it gives me this:

20190926-133032_Screenshot_Firefox

Cocoding dosn't load

Hello. I was super excited to use this but cocoding doesn't work at all for me.

Do I need an accout or to do something first for it to work?

I followed your videos and the tutorials here and on the site.

All it says it press cocoding and it will work.

When I press it just says loading and never starts.

How do i use this, what am i doing wrong.

Thanks for making this, I really wish I could figure out how to use it.

Visuals-only Pop-up

Started coding few days ago with this awsome tool, i'm planning to project visuals with it.
I'm facing some frame-rate issue with the visuals-only pop up, its working really slow (nothing else running on my macbook pro 2,7 GHz i5 8go RAM).. Any advice ?

Soft compile function-matching edge cases

Hey @ffd8, thanks for this awesome and exciting environment!

I'm taking a dive into your develop branch where I see that you've been working on the soft compile feature (mentioned in #19).

I'm super keen to get this feature working for my use-cases, and I fixed a few small bugs I came across while using it (#23 and #22), but I can still see a few more issues which are a bit trickier to solve.

For example, this example illustrates three cases:

let dots = [];
function setup() {
	createCanvas(windowWidth, windowHeight);
	noStroke();
	for (let i=0; i<100; i++) {
		let dot = new Dot();
		dots.push(dot);
	}
}

function draw() {
	background(0);
	dots.forEach(function (dot) {
		dot.draw();
		dot.size += random(-2, 2);
	});
}

class Dot {
	constructor() {
		this.pos = createVector(random(width), random(height));
		this.size = 10;
		this.color = [random(255), random(255), random(255)];
	}
	
	draw() {
		ellipse(this.pos.x, this.pos.y, this.size, this.size);
	}
}
  1. Unnamed functions

At the current moment, running a soft-compile on the following line actually crashes the program:

	dots.forEach(function (dot) {

As far as I can tell, this is because of the unnamed function. If instead I change the line to

	dots.forEach(function f(dot) {

Then the program doesn't crash. So this workaround works, but it would be nice to support unnamed functions since they are a big part of JavaScript.

  1. Class methods

In the example, I have a class Dot which has a method called draw().

Since the current implementation relies on the function keyword, this method isn't recognized as a function and so changing things inside Dot.draw() triggers a hard recompile, which is not ideal since we should be able to just update the method and do a soft compile.

  1. Support for same function names in different scope/contexts

I haven't explored this one fully yet, but I see a potential issue being that my method Dot.draw() and the main draw() have the same name. This is legal since they exist in different scopes, but at the moment the parser would treat them as the same function (?). Again, not yet tested since anyway class methods are not yet working for the soft compile.


At the end of the day, there are still workarounds which require the user to design their programs to not have these edge cases, but I just wanted to draw your attention to these so that we might get these issues resolved further down the road.

Again, thanks so much for the great work on this platform! 💯

osc server crash...

node.js server crashes at odd times (usually on page refresh) when using the develop branch w/ OSC implementation. pretty sure it has to do with osc server/port not being properly disconnected.. but maybe it's an issue with the node-osc module?

error message:

dgram.js:827
    throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
    ^

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
....

Feature request: Support multiple files

When doing a hackathon with multiple artists, the main sketch gets a rather big quite quickly:

  • Actual animation (simple dot animations based on lissajous demo)
  • Multiple shaders (rgb split, scanlines, blur, bloom)
  • MIDI sharing (with SyncData)
  • Variable persistence (custom local cache)

The option to split the code into different files like with p5.js online editor would be really nice!

How do you think that could work?

Some Hydra examples are not working properly

Hi!

I am on Windows 11 + Chrome and I was testing hydra examples but are not being rendered. I seems that it is a name conflict between hydra functions and javascript function names. For instance:

osc().sub(osc(6)).out(o0)
osc().shift(0.1,0.9,0.3).out(o0)

Would it be possible to avoid this?

Also, when doing the soft compile of some sorts of code I am getting a repetitive glitch and not the intended result. When doing the hard compilation it works fine. In this case, chaging the paremeters will lead to glitch:

src(o0).modulate(noise(1),0.005).blend(shape(4),0.01).out(o0)

Thanks a lot!

Terminal error when starting offline

Hi. Thank you so much for creating p5-live. I've been using it problem-free for many months but a few days ago, in the command prompt when I enter 'npm start', I get this error message everytime:

C:\Users\aidah\OneDrive\Desktop\P5LIVE-main\P5LIVE-main\server.js:79
iop = require('socket.io', {transports: ['WebSocket'] }).listen(8082);
^

TypeError: require(...).listen is not a function
at Object. (C:\Users\aidah\OneDrive\Desktop\P5LIVE-main\P5LIVE-main\server.js:79:59)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47

what could the problem be here?

MIDI example

Hello!
I've been trying to use the MIDI implementation but I can't understand completely how to use it, or the example is not running correctly. Is there any video-tutorial available ?
Thanks so much!

Feature request : Coding arena

I'm interested in developing P5Live so that each person codes in their own window. So they each have their own function to work in. drawTim() drawNicola() . Then all the functions are drawn in order to the screen. This way there is more space for everyone to breath. Each user just sees their window and the shared space. Plus icons for the other users to see into each others windows, but to minimize them as needed. Then there would be a shared space where all the drawings go. There would be some conventions about global variables, and built in collision detection.

So P5Live becomes more like a coding arena. This could lead to interesting multiplayer dynamics, coded games, battles, collaborative drawing puzzles etc..

Does this sound doable? How would I start on this? Would it make sense to branch from P5Live, or just pull out the parsing + networking code from P5Live (which I think is the main thing I need) and use it in a new program.
I've not used github much - coded lots in Processing and quite a bit in P5JS.

Tim

Question: Import sketch with configurations

Hey Ted,

First off, thanks for making P5Live. Just fell over it yesterday, while researching how to get 3D into Hydra with P5 and now I see that you've made it possible to get Hydra into P5 in a much more effective way :) Super impressive! Sorry for creating my question as an issue here. Do you have a discord or some other forum you'd prefer discussions to happen?

My question: Is it possible to import a separate sketch into a main sketch? (without hosting it outside P5Live)

I've been working on a setup for algoraves and one thing I wanted was to use my midi controller (MidiFighter) in an elegant way throughout my performance. I figured out how to use midi inside P5Live. It's super nice, but the setup I'm thinking of would look rather dry and overwhelming for an audience as the first thing they see, so I would like to separate that part of the configuration from my performance code. I would like to create a separate file where I configure all the midi signals into meaningful variables or arrays, that I can then import into all of my projects and easily jam with without having to look at it. Basically so my live code doesn't get polluted by basic configurations.

Hope you're having a great weekend

Is there a way to load external scripts / other libraries

I would like to make a test with p5.xr among other libraries. Is there an official way to do this?

I'm thinking of doing something like this if not

function addScript(src) {
  const script = document.createElement('script');
  script.src = src;
  document.head.appendChild(script);
}

addScript("path/to/your/script.js");

_gui_slidersGrid example not working

Sliders are off the screen (which is a easy fix) but the sliders are also not focusable (which i dont know how to fix). Would be nice to have some example of how to create focusable GUI elements like buttons etc.

Data stored in offline mode missing

I've always been using the offline mode.
It seems like my Chrome updated version or something. All my sketches are gone and I had backup a while back.
Is there anyway to restore the sketch if this happened

feature: global variables that persist sketch recompiles

It would be useful to be able to define variables that persist between sketch recompiles and calls to buildSketch(), similar to the way the p5vars.frameCount does. Some applications for this are to be able to have a countdown timer for the performance or to keep animations going non-stop rather than having to always restart from zero.

[feature request] linting / prettier

Hi!

Ended up making my own fork of P5LIVE for easier tracking/experiments, but it would be awesome if this was more crowd-friendly someday.

A simple ask for now:

Would it be possible for you to add some sort of prettier (or other) formatting configuration to the repository and run it for the core files, so our editors could agree on styling?

Shouldn't take long and would make life much easier when you release new features and I need to merge, or if people make PRs :) My editor made around 20K row changes when saving index.html and server.js 💥

Scrollbars in full screen mod

Screenshot from 2019-11-14 16-44-12

In both firefox and chrome (on Linux) there are horizontal and vertical scrollbars in windowed or full screen mode.

Co-coding users' cursors are not visible

In co-coding mode, my coding partners' cursors appears briefly at the start of a session then disappear almost instantly and cannot be seen again.

OS: Windows 10
Browser: Chrome Version 100.0.4896.127

Keyboard shortcuts in Windows and Linux

Hi, me again!

I may be missing something very obvious, but I have been struggling to get a hang of keyboard shortcuts in P5LIVE.

In particular, I have been unable to get the following keyboard shortcuts (which I expect to be universal) to work:

  • Copy (Ctrl + C)
  • Jump to line start (Home)
  • Jump to line end (End)

I have tested these on my own local hosted P5LIVE setup and http://p5live.org, on both Chrome and Firefox, as well as in both Linux and Windows environments.

In all environments tested so far, the 3 commands above do nothing. But strangely, their close relatives are working fine for me:

  • Paste (Ctrl + V) works!
  • Selection to line start (Shift + Home) works!
  • Selection to line end (Shift + End) works!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.