open-audiovisual
Search GitHub

oav-p5 reference · Loading options

link#

optionoav-p5
?oav_link=a room name

Joins a room: oav-p5 pages with the same room hear what each other's programs play, over the relay. A room name, or empty for none.

Every oav-p5 page with the same room (another tab, another computer) gets what this page's programs play into the virtual MIDI output (notes, controllers and the clock), over the phone relay, and plays it at the moment it sounds here. On the other side, OAVp5.last.source is 'link'. Nothing it receives is sent on, so two pages cannot loop. The room is also the phones' room, so one QR code plays every linked page.

OAVp5.link.info tells you the room, whether it is connected and how many other pages were heard. The 🎹 grows a 🔗: green when another page is there, yellow while connecting or alone, red when the relay is gone. linkdelay adds a buffer.

Type
String
Values
a room name
default
'' (no room)

Only letters, digits, _ and - are kept, and only the first 32 characters.

Before it has a value

A network connection to the relay (relay, wss://remote.cheyuwu.com/relay unless you set another). Without it the 🔗 is red and nothing is shared.

Notes

  • Set it before oav-p5 loads. window.OAV_P5 = { link: … }; above the loader line wins, then ?oav_link=… on the page address, then ?link=… on the script's own URL. Values in window.OAV_P5 are turned into text, so write 'off', not false. On OpenProcessing the page address takes ?sketch_oav_link=… (the project's README says OpenProcessing forwards it to the sketch).

Examples

js
window.OAV_P5 = { link: 'my-room' };

function setup() {
  createCanvas(400, 300);
}

function draw() {
  background(20);
  fill(255);
  const info = OAVp5.link.info;
  text('room: ' + OAVp5.options.link, 20, 30);
  text('state: ' + (info ? info.state + ', ' + info.peers + ' other page(s)' : 'not linked'), 20, 60);
}
static Open the same address in two tabs: each shows the room and, once connected, one other page. Anything one tab's program plays into OAV Virtual MIDI is heard by the other.

To be confirmed

The headless check cannot reach a relay, so this example is not run. Behaviour between two pages was read from the code and the project's README, not seen here.

Related

  • OAVp5.link What the link to other oav-p5 pages in the same room is doing: only OAVp5.link.info, and null unless a room is set.
  • OAVp5.link.info The state of the link: its room, state (connecting, open, closed), how many other pages are there, and the trip time. null when no room is set.
  • linkdelay Extra milliseconds of buffer on the notes a linked page receives, to smooth out an uneven network: 0 to 2000.
  • relay The address of the relay that phones and link rooms talk through: a WebSocket URL.
  • room The name of the room phones join to play this page: by default one made up per browser.

p5/oav-p5.js, line 156

↑ Back to top · All names