Live

cam(...) — the camera, as a picture and as signals

cam() shows the camera on the stage and measures its picture: how much of it moves, how bright it is, where the movement is, and each burst of movement, for follow() and trig: as a sound's signals are.

cam()                                   the camera, the whole view, mirrored (as a selfie view)
cam(uid:eye, at:[0.75, 0.3], size:0.3)  in a corner: at: 0..1 of the view, size: a share of it
cam(eye, cell:5)                        in a cell of the grid (grid(3, 2) first)
cam(flip:0)                             not mirrored
cam(fit:contain)                        the whole picture in its frame, bars round it (cover by default: filled, cropped)
cam(opacity:0.4)                        faint; opacity:follow(bass.level, 0.2, 1)
cam(show:0)                             not drawn: its signals only
cam(uid:eye, off:1)                     that one gone
cam(off)                                every camera gone, and the camera let go

The name (uid:, or the first word: cam(eye, ...)) is cam when none is given. Every cam() shows the same camera; the browser asks for it once.

Signals

Published under its name, about 30 times a second:

signal
cam.motion the share of the picture that moved since the last frame, 0..1 -- up at once, down over about half a second
cam.level the same against its own most lately, 0..1, as a sound's level: follow(cam.level, lo, hi) reaches hi in any room
cam.bright how bright the picture is, on average, 0..1
cam.x, cam.y where the movement is: 0..1 across (as shown: mirrored unless flip:0) and down; kept where they were while nothing moves
cam.hit a burst of movement: motion rising well above what it has been lately -- trig:cam.hit, every(4, cam.hit)
cam.n the bursts counted

The picture is measured on a 32 x 24 copy of each frame. A spot counts as moving when its brightness changes by more than about a twelfth: a camera's own flicker is not movement, so a still room reads 0.

synth(uid:air, wave:pink, filter:{type:bp, freq:follow(cam.y, 3000, 150), q:8}, amp:follow(cam.level, 0, 0.12))
synth(uid:pad, wave:saw, freq:110, pan:follow(cam.x, -1, 1), amp:0.03)
stars > rotate(rand(0, 360), dur:0.3, trig:cam.hit)
grid(shuffle, trig:every(4, cam.hit))
screen(kaleido:6, turn:follow(cam.x, 0, 360))
screen(hue:follow(cam.bright, 0, 360))

On the stage

gui() gives the picture a box's effects, as it does a picture of image():

gui(eye, hue:120, blur:4, pixel:8, warp:20)
gui(cam, invert:follow(cam.hit, 0, 1))

screen()'s effects take it with the rest of the stage. For screen(kaleido:N) on a wide screen, give the camera a frame bigger than the screen -- cam(size:2.4): the fold takes its wedge from the top of the stage, which ends short of the corners, and the part of the picture past the edge fills them.

A grid's shuffle and turn move a camera in a cell as they move the rest.

Asking for the camera

The browser asks the performer for the camera the first time, and only after something they did -- a click, a key, a line run from the console. A cam() the playhead fires as the page loads may be refused; start it from a button() or the console. What went wrong is said in plain words (in the console's output in Oscilla Live): no camera, the camera refused (allow it at the left of the address bar), the camera held by another program, or a page that is not secure (http on another machine: open it over https, or on localhost).

The camera's own sound is not used: for sound in, see adc().

Tip: use ← → or ↑ ↓ to navigate the docs